diff --git a/packages/nextjs/app/admin/_components/SubmissionCard.tsx b/packages/nextjs/app/admin/_components/SubmissionCard.tsx index e3a66d4..b6305ae 100644 --- a/packages/nextjs/app/admin/_components/SubmissionCard.tsx +++ b/packages/nextjs/app/admin/_components/SubmissionCard.tsx @@ -2,26 +2,23 @@ import { useRouter } from "next/navigation"; import { SubmissionComments } from "./SubmissionComments"; +import { SubmissionEligible } from "./SubmissionEligible"; import "./submission-rating.css"; import { useMutation } from "@tanstack/react-query"; +import clsx from "clsx"; import { useAccount } from "wagmi"; import { Address } from "~~/components/scaffold-eth"; import { Submission } from "~~/services/database/repositories/submissions"; -import { getFormattedDateTime } from "~~/utils/date"; import { postMutationFetcher } from "~~/utils/react-query"; import { notification } from "~~/utils/scaffold-eth"; export const SubmissionCard = ({ submission }: { submission: Submission }) => { const { address: connectedAddress } = useAccount(); - const { mutateAsync: postNewVote } = useMutation({ + const { mutateAsync: postNewVote, isPending: isVotePending } = useMutation({ mutationFn: (newVote: { score: number }) => postMutationFetcher(`/api/submissions/${submission.id}/votes`, { body: newVote }), }); - const { mutateAsync: postNewEligible } = useMutation({ - mutationFn: (newEligible: { eligible: boolean; clear: boolean }) => - postMutationFetcher(`/api/submissions/${submission.id}/eligible`, { body: newEligible }), - }); const { refresh } = useRouter(); const vote = async (newScore: number) => { @@ -44,36 +41,6 @@ export const SubmissionCard = ({ submission }: { submission: Submission }) => { } }; - const setEligible = async (newEligible: boolean) => { - try { - const result = await postNewEligible({ eligible: newEligible, clear: false }); - - notification.success(result.message); - refresh(); - } catch (error: any) { - if (error instanceof Error) { - notification.error(error.message); - return; - } - notification.error("Something went wrong"); - } - }; - - const clearEligible = async () => { - try { - const result = await postNewEligible({ eligible: false, clear: true }); - - notification.success(result.message); - refresh(); - } catch (error: any) { - if (error instanceof Error) { - notification.error(error.message); - return; - } - notification.error("Something went wrong"); - } - }; - const scoreAvg = submission.votes.length > 0 ? (submission.votes.map(vote => vote.score).reduce((a, b) => a + b, 0) / submission.votes.length).toFixed(2) @@ -85,60 +52,10 @@ export const SubmissionCard = ({ submission }: { submission: Submission }) => { return (
{submission.description}
- {submission.feedback &&Extensions feedback: {submission.feedback}
} + {submission.feedback &&Extensions Feedback: {submission.feedback}
} + +