From 65a22fc24889c9aa8724bbb99da76ca2d9411a7c Mon Sep 17 00:00:00 2001 From: Meriem-BM Date: Wed, 30 Oct 2024 13:13:38 +0100 Subject: [PATCH 1/3] add attestation link --- .../components/CategoryAllocation.tsx | 4 ++- .../ProgressCards/VotedCategory.tsx | 28 +++++++++++-------- .../utils/data-fetching/categories.ts | 1 + 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/allocation/components/CategoryAllocation.tsx b/app/allocation/components/CategoryAllocation.tsx index a4ce180..5614a0d 100644 --- a/app/allocation/components/CategoryAllocation.tsx +++ b/app/allocation/components/CategoryAllocation.tsx @@ -53,6 +53,7 @@ const CategoryAllocation: FC = ({ allocationPercentage, allocationBudget, locked, + attestationLink, delegations, loading, username, @@ -97,6 +98,7 @@ const CategoryAllocation: FC = ({ return ( @@ -104,7 +106,7 @@ const CategoryAllocation: FC = ({ case CollectionProgressStatusEnum.Finished: return ; case CollectionProgressStatusEnum.Attested: - return ; + return ; case CollectionProgressStatusEnum.Pending: default: return ( diff --git a/app/allocation/components/ProgressCards/VotedCategory.tsx b/app/allocation/components/ProgressCards/VotedCategory.tsx index 1d71b41..2c3d8c8 100644 --- a/app/allocation/components/ProgressCards/VotedCategory.tsx +++ b/app/allocation/components/ProgressCards/VotedCategory.tsx @@ -5,11 +5,13 @@ import { CheckIcon } from '@/public/assets/icon-components/Check'; type TVotedCategoryProps = { id: number isAutoConnecting: boolean + attestationLink?: string | null }; const VotedCategory = ({ id, isAutoConnecting, + attestationLink, }: TVotedCategoryProps) => { const router = useRouter(); @@ -21,17 +23,21 @@ const VotedCategory = ({ > Edit -
-

Voted

- -
- + {attestationLink != null && ( +
+

Voted

+ +
+ )} + {attestationLink && ( + + )} ); }; diff --git a/app/comparison/utils/data-fetching/categories.ts b/app/comparison/utils/data-fetching/categories.ts index 83cdcec..c34bffa 100644 --- a/app/comparison/utils/data-fetching/categories.ts +++ b/app/comparison/utils/data-fetching/categories.ts @@ -9,6 +9,7 @@ export type TCategory = { image: string projectCount: number progress: CollectionProgressStatus + attestationLink: string | null }; export const getCategories = async (): Promise => { From 6e00b29896e4b609dbcf4e6cdb1d531009c926c3 Mon Sep 17 00:00:00 2001 From: Meriem-BM Date: Wed, 30 Oct 2024 13:50:14 +0100 Subject: [PATCH 2/3] add submit votes loading & disabled view --- app/allocation/[category]/page.tsx | 64 +++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 15 deletions(-) diff --git a/app/allocation/[category]/page.tsx b/app/allocation/[category]/page.tsx index 3455493..74cf2f2 100644 --- a/app/allocation/[category]/page.tsx +++ b/app/allocation/[category]/page.tsx @@ -58,7 +58,9 @@ const RankingPage = () => { const category = categorySlugIdMap.get((params?.category as string) || ''); // const [search, setSearch] = useState(""); - const [attestationState, setAttestationState] = useState(AttestationState.Initial); + const [attestationState, setAttestationState] = useState( + AttestationState.Initial + ); const [attestationLink, setAttestationLink] = useState(); const [checkedItems, setCheckedItems] = useState([]); const [projects, setProjects] = useState(null); @@ -68,6 +70,7 @@ const RankingPage = () => { const [isLocked, setIsLocked] = useState(false); const [isUnlocked, setIsUnlocked] = useState(false); const [allocationBudget, setAllocationBudget] = useState(0); + const [isSubmitting, setIsSubmitting] = useState(false); const { data: categoryRankings, isLoading: rankingLoading } = useCategoryRankings(); @@ -120,8 +123,8 @@ const RankingPage = () => { projects.map(project => ({ ...project, share: - (newRanking.find(el => el.id === project.projectId) - ?.percentage || 0) / 100, + (newRanking.find(el => el.id === project.projectId) + ?.percentage || 0) / 100, })) ); @@ -201,7 +204,8 @@ const RankingPage = () => { }; const submitVotes = async () => { - console.log('Projects,', projects); + setIsSubmitting(true); + if (!projects) return; const rankingArray = projects.map(project => ({ @@ -213,14 +217,29 @@ const RankingPage = () => { await updateProjectRanking(); + console.log("requirement not met for attestation", wallet, ranking, signer); if (!wallet || !ranking || !signer) { console.error('Requirements not met for attestations'); + setIsSubmitting(false); return; } - await attest({ ranking: { id: ranking.id, name: ranking.name, - ranking: projects.map(el => ({ RF6Id: el.project.RF6Id, share: el.share })) }, - setAttestationLink, setAttestationState, signer, wallet }); + await attest({ + ranking: { + id: ranking.id, + name: ranking.name, + ranking: projects.map(el => ({ + RF6Id: el.project.RF6Id, + share: el.share, + })), + }, + setAttestationLink, + setAttestationState, + signer, + wallet, + }); + + setIsSubmitting(false); }; const handleAttestationModalClose = () => { @@ -296,9 +315,7 @@ const RankingPage = () => { return (
@@ -308,8 +325,12 @@ const RankingPage = () => { onClose={() => setAttestationState(AttestationState.Initial)} /> )} - {attestationState === AttestationState.Loading && } - {attestationState === AttestationState.Error && } + {attestationState === AttestationState.Loading && ( + + )} + {attestationState === AttestationState.Error && ( + + )}
@@ -441,12 +462,25 @@ const RankingPage = () => { Back to Categories
From 7ac8512710a97302b2b40343c6bdfb05ee326b53 Mon Sep 17 00:00:00 2001 From: Meriem-BM Date: Wed, 30 Oct 2024 13:51:47 +0100 Subject: [PATCH 3/3] remove console log --- app/allocation/[category]/page.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/app/allocation/[category]/page.tsx b/app/allocation/[category]/page.tsx index 74cf2f2..70a07ad 100644 --- a/app/allocation/[category]/page.tsx +++ b/app/allocation/[category]/page.tsx @@ -217,7 +217,6 @@ const RankingPage = () => { await updateProjectRanking(); - console.log("requirement not met for attestation", wallet, ranking, signer); if (!wallet || !ranking || !signer) { console.error('Requirements not met for attestations'); setIsSubmitting(false);