Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yashgo0018 committed May 16, 2024
1 parent 9faef19 commit 57d7b8e
Show file tree
Hide file tree
Showing 42 changed files with 178 additions and 1,355 deletions.
12 changes: 9 additions & 3 deletions packages/nextjs/app/_components/RegisterButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export default function RegisterButton() {

if (!keypair) {
return (
<button className="border border-slate-600 bg-primary px-3 py-2 rounded-lg font-bold" onClick={generateKeypair}>
<button
className="border border-slate-600 rounded-lg font-bold bg-yellow-500 text-black px-20 py-3 text-lg"
onClick={generateKeypair}
>
Login
</button>
);
Expand All @@ -33,8 +36,11 @@ export default function RegisterButton() {
return (
<>
(You are not registered yet)
<button className="border border-slate-600 bg-primary px-3 py-2 rounded-lg font-bold" onClick={register}>
Register
<button
className="border border-slate-600 rounded-lg font-bold bg-yellow-500 text-black px-20 py-3 text-lg"
onClick={register}
>
Register Here
</button>
</>
);
Expand Down
133 changes: 70 additions & 63 deletions packages/nextjs/app/admin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { redirect } from "next/navigation";
import CreatePollModal from "./_components/CreatePollModal";
import PollStatusModal from "./_components/PollStatusModal";
import { useAccount } from "wagmi";
import { Header } from "~~/components/Header";
import Paginator from "~~/components/Paginator";
import { useScaffoldContractRead } from "~~/hooks/scaffold-eth";
import { useFetchPolls } from "~~/hooks/useFetchPolls";
Expand All @@ -30,72 +31,78 @@ export default function AdminPage() {
}, [address, admin]);

return (
<div className="container mx-auto pt-10">
<div className="flex">
<div className="flex-1 text-2xl">Polls</div>
<button
className="border border-slate-600 bg-primary px-3 py-2 rounded-lg font-bold"
onClick={() => setOpenCreatePollModal(true)}
>
Create Poll
</button>
</div>
<>
<Header />
<div className="container mx-auto pt-10">
<div className="flex">
<div className="flex-1 text-2xl">Polls</div>
<button
className="border border-slate-600 bg-primary px-3 py-2 rounded-lg font-bold"
onClick={() => setOpenCreatePollModal(true)}
>
Create Poll
</button>
</div>

{polls && polls.length !== 0 ? (
<>
<table className="border-separate w-full mt-7 mb-4">
<thead>
<tr className="text-lg font-extralight">
<th className="border border-slate-600 bg-primary">Poll Name</th>
<th className="border border-slate-600 bg-primary">Start Time</th>
<th className="border border-slate-600 bg-primary">End Time</th>
<th className="border border-slate-600 bg-primary">Status</th>
</tr>
</thead>
<tbody>
{polls.map(poll => (
<tr key={poll.id} className="pt-10 text-center">
<td>{poll.name}</td>
<td>{new Date(Number(poll.startTime) * 1000).toLocaleString()}</td>
<td>{new Date(Number(poll.endTime) * 1000).toLocaleString()}</td>
<td>
{poll.status == PollStatus.CLOSED ? (
<>
{poll.status}{" "}
<button className=" text-accent underline" onClick={() => setSelectedPollForStatusModal(poll)}>
(Required Actions)
</button>
</>
) : poll.status == PollStatus.RESULT_COMPUTED ? (
<>
{poll.status}{" "}
<Link href={`/polls/${poll.id}`} className="text-accent underline">
(View Results)
</Link>
</>
) : (
poll.status
)}
</td>
{polls && polls.length !== 0 ? (
<>
<table className="border-separate w-full mt-7 mb-4">
<thead>
<tr className="text-lg font-extralight">
<th className="border border-slate-600 bg-primary">Poll Name</th>
<th className="border border-slate-600 bg-primary">Start Time</th>
<th className="border border-slate-600 bg-primary">End Time</th>
<th className="border border-slate-600 bg-primary">Status</th>
</tr>
))}
</tbody>
</table>
{totalPages > 1 && (
<Paginator currentPage={currentPage} totalPages={totalPages} setPageNumber={setCurrentPage} />
)}
</>
) : (
<div>No polls found</div>
)}
</thead>
<tbody>
{polls.map(poll => (
<tr key={poll.id} className="pt-10 text-center">
<td>{poll.name}</td>
<td>{new Date(Number(poll.startTime) * 1000).toLocaleString()}</td>
<td>{new Date(Number(poll.endTime) * 1000).toLocaleString()}</td>
<td>
{poll.status == PollStatus.CLOSED ? (
<>
{poll.status}{" "}
<button
className=" text-accent underline"
onClick={() => setSelectedPollForStatusModal(poll)}
>
(Required Actions)
</button>
</>
) : poll.status == PollStatus.RESULT_COMPUTED ? (
<>
{poll.status}{" "}
<Link href={`/polls/${poll.id}`} className="text-accent underline">
(View Results)
</Link>
</>
) : (
poll.status
)}
</td>
</tr>
))}
</tbody>
</table>
{totalPages > 1 && (
<Paginator currentPage={currentPage} totalPages={totalPages} setPageNumber={setCurrentPage} />
)}
</>
) : (
<div>No polls found</div>
)}

<CreatePollModal refetchPolls={refetchPolls} show={openCreatePollModal} setOpen={setOpenCreatePollModal} />
<CreatePollModal refetchPolls={refetchPolls} show={openCreatePollModal} setOpen={setOpenCreatePollModal} />

<PollStatusModal
poll={selectedPollForStatusModal}
setOpen={() => setSelectedPollForStatusModal(undefined)}
show={Boolean(selectedPollForStatusModal)}
/>
</div>
<PollStatusModal
poll={selectedPollForStatusModal}
setOpen={() => setSelectedPollForStatusModal(undefined)}
show={Boolean(selectedPollForStatusModal)}
/>
</div>
</>
);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from "fs";
import path from "path";
import { hardhat } from "viem/chains";
import { AddressComponent } from "~~/app/blockexplorer/_components/AddressComponent";
import { AddressComponent } from "~~/app/blockexplorer-testing-only/_components/AddressComponent";
import deployedContracts from "~~/contracts/deployedContracts";
import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract";

Expand Down
File renamed without changes.
66 changes: 0 additions & 66 deletions packages/nextjs/app/debug/_components/DebugContracts.tsx

This file was deleted.

84 changes: 0 additions & 84 deletions packages/nextjs/app/debug/_components/contract/ContractInput.tsx

This file was deleted.

This file was deleted.

Loading

0 comments on commit 57d7b8e

Please sign in to comment.