134 lines
5.0 KiB
Plaintext
134 lines
5.0 KiB
Plaintext
<div class="min-h-screen bg-gray-50">
|
|
<!-- Hero Section -->
|
|
<div class="relative isolate px-6 pt-14 lg:px-8">
|
|
<div class="mx-auto max-w-2xl py-8 sm:py-12">
|
|
<div class="text-center">
|
|
<h1 class="text-4xl font-bold tracking-tight text-gray-900 sm:text-6xl">
|
|
Decentralized Voting System
|
|
</h1>
|
|
<p class="mt-6 text-lg leading-8 text-gray-600">
|
|
Secure, transparent, and immutable voting powered by the æternity blockchain.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Main Content -->
|
|
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
|
|
<div class="grid grid-cols-1 gap-8 lg:grid-cols-2">
|
|
<!-- Voting Form -->
|
|
<div class="bg-white shadow-lg rounded-lg p-6">
|
|
<h2 class="text-2xl font-semibold mb-6">Cast Your Vote</h2>
|
|
|
|
<form id="vote-form" method="post" action={~p"/vote"} class="space-y-6">
|
|
<input type="hidden" name="_csrf_token" value={get_csrf_token()}>
|
|
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700">
|
|
Select your option
|
|
</label>
|
|
<select name="option"
|
|
class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300
|
|
focus:outline-none focus:ring-indigo-500 focus:border-indigo-500
|
|
sm:text-sm rounded-md">
|
|
<option value="option_a">Option A</option>
|
|
<option value="option_b">Option B</option>
|
|
</select>
|
|
</div>
|
|
|
|
<button type="submit"
|
|
class="w-full flex justify-center py-2 px-4 border border-transparent
|
|
rounded-md shadow-sm text-sm font-medium text-white
|
|
bg-indigo-600 hover:bg-indigo-700 focus:outline-none
|
|
focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
|
|
Submit Vote
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Results Display -->
|
|
<div class="bg-white shadow-lg rounded-lg p-6">
|
|
<h2 class="text-2xl font-semibold mb-6">Current Results</h2>
|
|
|
|
<div class="space-y-4">
|
|
<!-- Option A -->
|
|
<div>
|
|
<div class="flex justify-between mb-1">
|
|
<span class="text-sm font-medium text-gray-700">Option A</span>
|
|
<span class="text-sm font-medium text-gray-700">
|
|
<%= @votes["option_a"] %> votes
|
|
</span>
|
|
</div>
|
|
<div class="w-full bg-gray-200 rounded-full h-2.5">
|
|
<div class="bg-indigo-600 h-2.5 rounded-full transition-all duration-500"
|
|
style={"width: #{percentage_a(@votes)}%"}>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Option B -->
|
|
<div>
|
|
<div class="flex justify-between mb-1">
|
|
<span class="text-sm font-medium text-gray-700">Option B</span>
|
|
<span class="text-sm font-medium text-gray-700">
|
|
<%= @votes["option_b"] %> votes
|
|
</span>
|
|
</div>
|
|
<div class="w-full bg-gray-200 rounded-full h-2.5">
|
|
<div class="bg-indigo-600 h-2.5 rounded-full transition-all duration-500"
|
|
style={"width: #{percentage_b(@votes)}%"}>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Total Votes -->
|
|
<div class="mt-6 pt-6 border-t border-gray-200">
|
|
<div class="flex justify-between">
|
|
<span class="text-sm font-medium text-gray-700">Total Votes</span>
|
|
<span class="text-sm font-medium text-gray-900">
|
|
<%= total_votes(@votes) %>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Blockchain Status -->
|
|
<div class="mt-8 bg-white shadow-lg rounded-lg p-6">
|
|
<h2 class="text-2xl font-semibold mb-6">Blockchain Status</h2>
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
<div class="p-4 bg-gray-50 rounded-lg">
|
|
<dt class="text-sm font-medium text-gray-500">Latest Block</dt>
|
|
<dd class="mt-1 text-2xl font-semibold text-gray-900">
|
|
#<%= @blockchain_stats.latest_block %>
|
|
</dd>
|
|
</div>
|
|
|
|
<div class="p-4 bg-gray-50 rounded-lg">
|
|
<dt class="text-sm font-medium text-gray-500">Network</dt>
|
|
<dd class="mt-1 text-2xl font-semibold text-gray-900">
|
|
<%= @blockchain_stats.network_status %>
|
|
</dd>
|
|
</div>
|
|
|
|
<div class="p-4 bg-gray-50 rounded-lg">
|
|
<dt class="text-sm font-medium text-gray-500">Wallet Status</dt>
|
|
<dd class="mt-1">
|
|
<%= if @wallet_connected do %>
|
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
|
|
Connected
|
|
</span>
|
|
<% else %>
|
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-800">
|
|
Not Connected
|
|
</span>
|
|
<% end %>
|
|
</dd>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|