diff --git a/packages/nextjs/app/admin/_components/SubmissionCard.tsx b/packages/nextjs/app/admin/_components/SubmissionCard.tsx index 2f8eecd..9b87443 100644 --- a/packages/nextjs/app/admin/_components/SubmissionCard.tsx +++ b/packages/nextjs/app/admin/_components/SubmissionCard.tsx @@ -13,7 +13,7 @@ import { SubmissionWithAvg } from "~~/services/database/repositories/submissions import { postMutationFetcher } from "~~/utils/react-query"; import { notification } from "~~/utils/scaffold-eth"; -export const SubmissionCard = ({ submission }: { submission: SubmissionWithAvg }) => { +export const SubmissionCard = ({ submission, tabName }: { submission: SubmissionWithAvg; tabName: string }) => { const { votingEnabled } = scaffoldConfig; const { address: connectedAddress } = useAccount(); @@ -91,8 +91,8 @@ export const SubmissionCard = ({ submission }: { submission: SubmissionWithAvg }
vote(0)} @@ -100,7 +100,7 @@ export const SubmissionCard = ({ submission }: { submission: SubmissionWithAvg } {[...Array(10)].map((_e, i) => ( Clear diff --git a/packages/nextjs/app/admin/_components/SubmissionTabs.tsx b/packages/nextjs/app/admin/_components/SubmissionTabs.tsx index c6b1c40..903ad26 100644 --- a/packages/nextjs/app/admin/_components/SubmissionTabs.tsx +++ b/packages/nextjs/app/admin/_components/SubmissionTabs.tsx @@ -9,9 +9,8 @@ const skeletonClasses = "animate-pulse bg-gray-200 rounded-none w-full h-96"; export const SubmissionTabs = ({ submissions }: { submissions: Submission[] }) => { const { address: connectedAddress } = useAccount(); - const { voted, notVoted } = submissions.reduce( + const { voted, notVoted, all } = submissions.reduce( (acc, submission) => { - // Connected address has voted const currentVote = submission.votes.find(vote => vote.builder === connectedAddress); const avgScore = @@ -21,6 +20,8 @@ export const SubmissionTabs = ({ submissions }: { submissions: Submission[] }) = const submissionWithAvg = { ...submission, avgScore }; + acc.all.push(submissionWithAvg); + if (currentVote) { acc.voted.push(submissionWithAvg); } else { @@ -32,15 +33,18 @@ export const SubmissionTabs = ({ submissions }: { submissions: Submission[] }) = { voted: [] as SubmissionWithAvg[], notVoted: [] as SubmissionWithAvg[], + all: [] as SubmissionWithAvg[], }, ); const votedLabel = connectedAddress ? `Voted (${voted.length})` : "Voted (-)"; const notVotedLabel = connectedAddress ? `Not Voted (${notVoted.length})` : "Not Voted (-)"; + const allLabel = `All Submissions (${all.length})`; return (
+ {/* Not Voted Tab */} ) : ( notVoted.map(submission => { - return ; + return ; }) )} {notVoted.length === 0 && ( @@ -70,6 +74,7 @@ export const SubmissionTabs = ({ submissions }: { submissions: Submission[] }) =
+ {/* Voted Tab */} b.avgScore - a.avgScore) .map(submission => { - return ; + return ; })}
+ + {/* All Submissions Tab */} + +
+
+ {all.length === 0 ? ( +
+ There are no submissions yet. +
+ ) : ( + all + .sort((a, b) => b.avgScore - a.avgScore) + .map(submission => ) + )} +
+
);