Skip to content

Commit

Permalink
Merge pull request #97 from GeneralMagicio/fix/feedback_issues
Browse files Browse the repository at this point in the history
Fix: remaining issues
  • Loading branch information
Meriem-BM authored Oct 31, 2024
2 parents fc348ff + acfdc37 commit 066b70f
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/allocation/[category]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions app/allocation/components/BudgetAllocation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,13 @@ const BudgetAllocation: React.FC<IBudgetAllocationProps> = ({

const renderProgressState = useMemo(() => {
switch (progress) {
case CollectionProgressStatusEnum.Finished:
return <VotedCategory id={id} isAutoConnecting={isAutoConnecting} />;
case CollectionProgressStatusEnum.Attested:
return (
<VotedCategory
budgetEditHandle={onScore}
id={id}
isAutoConnecting={isAutoConnecting}
attestationLink={attestationLink}
attestationLink={attestationLink || ''}
/>
);
case CollectionProgressStatusEnum.Delegated:
Expand All @@ -67,6 +65,7 @@ const BudgetAllocation: React.FC<IBudgetAllocationProps> = ({
username={username}
/>
);
case CollectionProgressStatusEnum.Finished:
case CollectionProgressStatusEnum.Pending:
default:
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const PendingCategory = ({
</p>
</div>
)}
{progress === 'WIP'
{(progress === 'WIP' || progress === 'Finished')
&& !(isBadgeholder && bhCategory !== categorySlug) && (
<div className="flex w-full justify-center gap-2 rounded-xl border border-[#FFA15A] bg-[#FFF7ED] py-1">
<p className="text-xs font-medium text-[#FFA15A]">Voting</p>
Expand Down
19 changes: 17 additions & 2 deletions app/allocation/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ const AllocationPage = () => {
= useState<Pick<ICategory, 'id' | 'name'>>();
const [targetDelegate, setTargetDelegate] = useState<TargetDelegate>();

const [rankingProgress, setRankingProgress]
= useState<CollectionProgressStatusEnum>(
CollectionProgressStatusEnum.Pending
);

const { mutateAsync: updateCategoriesRanking } = useUpdateCategoriesRanking({
budget: totalValue,
allocationPercentages:
Expand Down Expand Up @@ -304,6 +309,12 @@ const AllocationPage = () => {
);
};

useEffect(() => {
if (categoryRankings) {
setRankingProgress(categoryRankings.progress);
}
}, [categoryRankings]);

useEffect(() => {
if (delegations) {
const budgetDelegateFromYou = delegations?.fromYou?.budget;
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions app/comparison/card/GithubBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ const GithubBox: FC<Props> = ({ repo }) => {
{isExpanded
? (
<div className="flex items-center gap-2">
<span> Hide metrics </span>
{'metrics' in repo && repo.metrics && <span> Hide metrics </span>}
<ArrowUpIcon />
</div>
)
: (
<div className="flex items-center gap-2">
<span> View metrics </span>
{'metrics' in repo && repo.metrics && <span> View metrics </span>}
<ArrowDownIcon />
</div>
)}
Expand Down
8 changes: 4 additions & 4 deletions app/comparison/card/ProjectCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ export const ProjectCard: React.FC<Props> = ({

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);
}
};

Expand Down Expand Up @@ -241,7 +241,7 @@ export const ProjectCard: React.FC<Props> = ({
coi || coiLoading ? 'brightness-50' : ''
}`}
>
<div ref={parentRef} className="h-[78vh] gap-10 overflow-y-auto p-2">
<div ref={parentRef} className="h-[78vh] gap-10 overflow-y-auto">
<div className="mr-4">
{/* Cover Image and Profile Avatar */}
<div className="relative h-40">
Expand Down Expand Up @@ -424,7 +424,7 @@ export const ProjectCard: React.FC<Props> = ({
/>
{project.testimonials?.length && (
<SimpleInfoBox
title={`https://www.metricsgarden.xyz/projects/${project.projectId}/contributions/${project.projectId}`}
title={`https://www.metricsgarden.xyz/projects/${project.projectId}/?tab=insights`}
description=""
type="link"
showIcon={false}
Expand Down
6 changes: 3 additions & 3 deletions app/comparison/utils/data-fetching/ranking.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,7 +21,7 @@ export interface IProjectsRankingResponse {
hasRanking: boolean
isFinished: boolean
attestationLink?: string
progress: CollectionProgressStatus
progress: CollectionProgressStatusEnum
budget: number
name: string
share: number
Expand Down Expand Up @@ -55,7 +55,7 @@ export const useCategoryRankings = () => {
export const getProjectsRankingByCategoryId = async (
cid: number | undefined
): Promise<IProjectsRankingResponse> => {
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}
Expand Down

0 comments on commit 066b70f

Please sign in to comment.