From 420dfc4b857ff2bf131874b345ed66043934f48e Mon Sep 17 00:00:00 2001 From: Meriem-BM Date: Thu, 31 Oct 2024 14:14:10 +0100 Subject: [PATCH 1/6] fix: bulk lock issue --- app/allocation/[category]/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/allocation/[category]/page.tsx b/app/allocation/[category]/page.tsx index 217abb8..c324a4e 100644 --- a/app/allocation/[category]/page.tsx +++ b/app/allocation/[category]/page.tsx @@ -172,7 +172,7 @@ const RankingPage = () => { const lockSelection = () => { if (!projects) return; - if (checkedItems.length > projects?.length - 2) { + if (checkedItems.length > projects?.length - 2 || lockedItems.length >= projects?.length - 2) { setTotalShareError('At least two projects must be unlocked'); window.scrollTo(0, document.body.scrollHeight); return; From 068187a9037fe8748b53186d7ac510955717c520 Mon Sep 17 00:00:00 2001 From: Meriem-BM Date: Thu, 31 Oct 2024 17:38:16 +0100 Subject: [PATCH 2/6] fix: budget category view issue --- .../components/BudgetAllocation.tsx | 5 ++--- app/allocation/page.tsx | 19 +++++++++++++++++-- app/comparison/utils/data-fetching/ranking.ts | 6 +++--- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/app/allocation/components/BudgetAllocation.tsx b/app/allocation/components/BudgetAllocation.tsx index 4629e20..44fd730 100644 --- a/app/allocation/components/BudgetAllocation.tsx +++ b/app/allocation/components/BudgetAllocation.tsx @@ -48,15 +48,13 @@ const BudgetAllocation: React.FC = ({ const renderProgressState = useMemo(() => { switch (progress) { - case CollectionProgressStatusEnum.Finished: - return ; case CollectionProgressStatusEnum.Attested: return ( ); case CollectionProgressStatusEnum.Delegated: @@ -67,6 +65,7 @@ const BudgetAllocation: React.FC = ({ username={username} /> ); + case CollectionProgressStatusEnum.Finished: case CollectionProgressStatusEnum.Pending: default: return ( diff --git a/app/allocation/page.tsx b/app/allocation/page.tsx index 2cb56a5..28c1544 100644 --- a/app/allocation/page.tsx +++ b/app/allocation/page.tsx @@ -133,6 +133,11 @@ const AllocationPage = () => { = useState>(); const [targetDelegate, setTargetDelegate] = useState(); + const [rankingProgress, setRankingProgress] + = useState( + CollectionProgressStatusEnum.Pending + ); + const { mutateAsync: updateCategoriesRanking } = useUpdateCategoriesRanking({ budget: totalValue, allocationPercentages: @@ -304,6 +309,12 @@ const AllocationPage = () => { ); }; + useEffect(() => { + if (categoryRankings) { + setRankingProgress(categoryRankings.progress); + } + }, [categoryRankings]); + useEffect(() => { if (delegations) { const budgetDelegateFromYou = delegations?.fromYou?.budget; @@ -315,10 +326,14 @@ const AllocationPage = () => { }, [delegations]); useEffect(() => { - if (categoryRankings && categoryRankings.progress === 'Attested' && dbudgetProgress === CollectionProgressStatusEnum.Pending) { + if ( + rankingProgress === CollectionProgressStatusEnum.Attested + && dbudgetProgress === CollectionProgressStatusEnum.Pending + ) { setDbudgetProgress(CollectionProgressStatusEnum.Attested); } - }, [categoryRankings, dbudgetProgress]); + else setDbudgetProgress(CollectionProgressStatusEnum.Pending); + }, [rankingProgress]); useEffect(() => { if (categoryRankings) { diff --git a/app/comparison/utils/data-fetching/ranking.ts b/app/comparison/utils/data-fetching/ranking.ts index 45d29e8..ddb68e5 100644 --- a/app/comparison/utils/data-fetching/ranking.ts +++ b/app/comparison/utils/data-fetching/ranking.ts @@ -1,6 +1,6 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { axiosInstance } from '@/app/utils/axiosInstance'; -import { IProjectRanking, ICategory, IProject, CollectionProgressStatus } from '@/app/comparison/utils/types'; +import { IProjectRanking, ICategory, IProject, CollectionProgressStatusEnum } from '@/app/comparison/utils/types'; type TCategoryRanking = { project: IProject @@ -21,7 +21,7 @@ export interface IProjectsRankingResponse { hasRanking: boolean isFinished: boolean attestationLink?: string - progress: CollectionProgressStatus + progress: CollectionProgressStatusEnum budget: number name: string share: number @@ -55,7 +55,7 @@ export const useCategoryRankings = () => { export const getProjectsRankingByCategoryId = async ( cid: number | undefined ): Promise => { - if (!cid) return { ranking: [], hasRanking: false, isFinished: false, progress: 'Pending', attestationLink: '', budget: 0, name: '', share: 0, id: 0 }; + if (!cid) return { ranking: [], hasRanking: false, isFinished: false, progress: CollectionProgressStatusEnum.Pending, attestationLink: '', budget: 0, name: '', share: 0, id: 0 }; return ( await axiosInstance.get(`flow/ranking?cid=${cid} From 85d25235c77571928e8c89db5d2c86deafa0e9b1 Mon Sep 17 00:00:00 2001 From: Meriem-BM Date: Thu, 31 Oct 2024 18:26:04 +0100 Subject: [PATCH 3/6] fix: testimonial link broken & header flashing --- app/comparison/card/ProjectCard.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/comparison/card/ProjectCard.tsx b/app/comparison/card/ProjectCard.tsx index dca3b03..d6b5d0d 100644 --- a/app/comparison/card/ProjectCard.tsx +++ b/app/comparison/card/ProjectCard.tsx @@ -161,9 +161,9 @@ export const ProjectCard: React.FC = ({ const handleScroll = () => { if (parentRef.current && titleRef.current) { - const rect = titleRef.current.getBoundingClientRect(); + const rect = titleRef.current.getBoundingClientRect()?.top; const offset = parentRef.current.getBoundingClientRect()?.top; - setIsSticky(rect.top <= offset && rect.top >= -offset); + setIsSticky(rect <= offset && rect >= -offset); } }; @@ -241,7 +241,7 @@ export const ProjectCard: React.FC = ({ coi || coiLoading ? 'brightness-50' : '' }`} > -
+
{/* Cover Image and Profile Avatar */}
@@ -424,7 +424,7 @@ export const ProjectCard: React.FC = ({ /> {project.testimonials?.length && ( Date: Thu, 31 Oct 2024 18:31:34 +0100 Subject: [PATCH 4/6] fix: show only if repo has metrics --- app/comparison/card/GithubBox.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/comparison/card/GithubBox.tsx b/app/comparison/card/GithubBox.tsx index 14f6ee0..7cf2d3c 100644 --- a/app/comparison/card/GithubBox.tsx +++ b/app/comparison/card/GithubBox.tsx @@ -55,13 +55,13 @@ const GithubBox: FC = ({ repo }) => { {isExpanded ? (
- Hide metrics + {'metrics' in repo && repo.metrics && Hide metrics }
) : (
- View metrics + {'metrics' in repo && repo.metrics && View metrics }
)} From 717c1fbee67ba2ee38d7a1b3d3a37a0399051c23 Mon Sep 17 00:00:00 2001 From: Meriem-BM Date: Thu, 31 Oct 2024 18:37:26 +0100 Subject: [PATCH 5/6] fix: show status for non attested projects --- app/allocation/components/ProgressCards/PendingCategory.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/allocation/components/ProgressCards/PendingCategory.tsx b/app/allocation/components/ProgressCards/PendingCategory.tsx index 516ee6b..9280180 100644 --- a/app/allocation/components/ProgressCards/PendingCategory.tsx +++ b/app/allocation/components/ProgressCards/PendingCategory.tsx @@ -63,7 +63,7 @@ const PendingCategory = ({

)} - {progress === 'WIP' + {progress === 'WIP' || progress === 'Finished' && !(isBadgeholder && bhCategory !== categorySlug) && (

Voting

From acfdc37909d2d89298a0aa87b59ff7fef36a522b Mon Sep 17 00:00:00 2001 From: Meriem-BM Date: Thu, 31 Oct 2024 18:40:57 +0100 Subject: [PATCH 6/6] chore: linting errors --- app/allocation/components/ProgressCards/PendingCategory.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/allocation/components/ProgressCards/PendingCategory.tsx b/app/allocation/components/ProgressCards/PendingCategory.tsx index 9280180..7b9bd3e 100644 --- a/app/allocation/components/ProgressCards/PendingCategory.tsx +++ b/app/allocation/components/ProgressCards/PendingCategory.tsx @@ -63,7 +63,7 @@ const PendingCategory = ({

)} - {progress === 'WIP' || progress === 'Finished' + {(progress === 'WIP' || progress === 'Finished') && !(isBadgeholder && bhCategory !== categorySlug) && (

Voting