Skip to content

Commit

Permalink
add loading state to eligible picker
Browse files Browse the repository at this point in the history
  • Loading branch information
ChangoMan committed Aug 29, 2024
1 parent 7772dea commit 1361678
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/nextjs/app/admin/_components/SubmissionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ export const SubmissionCard = ({ submission }: { submission: Submission }) => {
))}
</div>
{score > 0 && (
<div className="flex items-center">
<div className="flex items-center gap-2">
{isVotePending && <span className="loading loading-xs"></span>}
<label
className={clsx("cursor-pointer underline text-sm ml-2 hover:no-underline", {
className={clsx("cursor-pointer underline text-sm hover:no-underline", {
"text-gray-400 cursor-not-allowed": isVotePending,
})}
htmlFor={`rating_${submission.id}_0`}
Expand Down
16 changes: 12 additions & 4 deletions packages/nextjs/app/admin/_components/SubmissionEligible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { notification } from "~~/utils/scaffold-eth";
const eligibleLabelStyles = "label cursor-pointer text-sm justify-start gap-2";

export const SubmissionEligible = ({ submission }: { submission: Submission }) => {
const { mutateAsync: postNewEligible } = useMutation({
const { mutateAsync: postNewEligible, isPending } = useMutation({
mutationFn: (newEligible: { eligible: boolean; clear: boolean }) =>
postMutationFetcher(`/api/submissions/${submission.id}/eligible`, { body: newEligible }),
});
Expand Down Expand Up @@ -101,9 +101,17 @@ export const SubmissionEligible = ({ submission }: { submission: Submission }) =
</div>
<div className="flex items-center justify-between gap-3 p-2">
{submission.eligible !== undefined && (
<button className="cursor-pointer underline text-sm hover:no-underline" onClick={clearEligible}>
Clear
</button>
<div className="flex items-center gap-2">
<button
className={clsx("cursor-pointer underline text-sm hover:no-underline", {
"text-gray-400 cursor-not-allowed": isPending,
})}
onClick={clearEligible}
>
Clear
</button>
{isPending && <span className="loading loading-xs"></span>}
</div>
)}

{submission.eligible === false && (
Expand Down

0 comments on commit 1361678

Please sign in to comment.