Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 67a82ac

Browse files
authored
fix : add approve/reject list in main checker page (#68)
fix : add approve/reject list in main checker page + ui fixes + invalidate queries
1 parent dac96ec commit 67a82ac

File tree

8 files changed

+159
-66
lines changed

8 files changed

+159
-66
lines changed

src/features/checker/components/ProjectEvaluationList/ProjectEvaluationList.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const ProjectEvaluationList = ({
6767
position: "center",
6868
render: (item) => (
6969
<div className="flex items-center justify-center">
70-
<CircleStat value={item.scoreAverage.toFixed(1)} />
70+
<CircleStat value={item.scoreAverage.toFixed(0)} />
7171
</div>
7272
),
7373
},

src/features/checker/components/ProjectReviewList/ProjectReviewList.tsx

+27-10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Address } from "viem";
2+
13
import { DefaultLogo } from "@/assets";
24
import { IconLabel } from "@/components/IconLabel";
35
import { Button } from "@/primitives/Button";
@@ -10,12 +12,21 @@ import { getReviewsCount } from "~checker/utils/getReviewsCount";
1012
import { ReviewsCounterLabel } from "../ReviewsCounterLabel";
1113

1214
export interface ProjectReviewListProps {
13-
reviewer: `0x${string}`;
1415
projects: ProjectReview[];
16+
17+
reviewer?: Address;
1518
action?: (projectId: string) => void;
19+
actionLabel?: string;
20+
keepAction?: boolean;
1621
}
1722

18-
export const ProjectReviewList = ({ reviewer, projects, action }: ProjectReviewListProps) => {
23+
export const ProjectReviewList = ({
24+
reviewer,
25+
projects,
26+
action,
27+
actionLabel,
28+
keepAction,
29+
}: ProjectReviewListProps) => {
1930
const columns: ListGridColumn<ProjectReview>[] = [
2031
{
2132
header: "Project",
@@ -38,7 +49,7 @@ export const ProjectReviewList = ({ reviewer, projects, action }: ProjectReviewL
3849
{
3950
header: "Date Submitted",
4051
key: "date",
41-
width: "1fr",
52+
width: "1.3fr",
4253
render: (item) => <IconLabel type="date" date={item.date} />,
4354
},
4455
{
@@ -53,17 +64,23 @@ export const ProjectReviewList = ({ reviewer, projects, action }: ProjectReviewL
5364
{
5465
header: "AI Suggestion",
5566
key: "aiSuggestion",
56-
width: "1fr",
57-
render: (item) => <IconLabel type="ai-evaluation" percent={item.aiSuggestion} />,
67+
width: "0.9fr",
68+
render: (item) => {
69+
return item.aiSuggestion !== 0 ? (
70+
<IconLabel type="ai-evaluation" percent={item.aiSuggestion} />
71+
) : (
72+
<ReviewsCounterLabel negativeReviews={0} positiveReviews={0} />
73+
);
74+
},
5875
},
5976
{
6077
header: "Score Average",
6178
key: "scoreAverage",
62-
width: "1fr",
79+
width: "0.8fr",
6380
position: "center",
6481
render: (item) => (
6582
<div className="flex items-center justify-center">
66-
<CircleStat value={item.scoreAverage.toFixed(1)} />
83+
<CircleStat value={item.scoreAverage.toFixed(0)} />
6784
</div>
6885
),
6986
},
@@ -73,13 +90,13 @@ export const ProjectReviewList = ({ reviewer, projects, action }: ProjectReviewL
7390
width: "1fr",
7491
position: "center",
7592
render: (item) => {
76-
const isReviewed = item.reviews.some((review) => review.reviewer === reviewer);
93+
const isReviewed = item.reviews.some((review) => review.reviewer === reviewer) || !reviewer;
7794
return (
7895
<div className="flex items-center justify-center">
7996
<Button
8097
variant="outlined-secondary"
81-
value="Evaluate project"
82-
disabled={isReviewed}
98+
value={actionLabel ?? "Evaluate project"}
99+
disabled={keepAction ? false : isReviewed}
83100
onClick={() => {
84101
if (action) {
85102
action(item.id);

src/features/checker/pages/ApplicationEvaluationOverviewPage/ApplicationEvaluationOverviewPage.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ export const ApplicationEvaluationOverviewPage = ({
5050
poolId={poolId}
5151
strategyName={application.round.strategyName}
5252
name={application.round.roundMetadata.name}
53-
registerStartDate={new Date()}
54-
registerEndDate={new Date()}
55-
allocationStartDate={new Date()}
56-
allocationEndDate={new Date()}
53+
registerStartDate={new Date(application.round.applicationsStartTime)}
54+
registerEndDate={new Date(application.round.applicationsEndTime)}
55+
allocationStartDate={new Date(application.round.donationsStartTime)}
56+
allocationEndDate={new Date(application.round.donationsEndTime)}
5757
/>
5858
<div className="mx-auto flex max-w-[1440px] flex-col gap-4 px-20">
5959
<div>

src/features/checker/pages/ReviewApplicationsPage/ReviewApplicationsPage.tsx

+70-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useGetApplicationsReviewPage } from "~checker/hooks";
66
import {
77
goToApplicationEvaluationOverviewAction,
88
goToSubmitFinalEvaluationAction,
9+
goToSubmitApplicationEvaluationAction,
910
useCheckerContext,
1011
useCheckerDispatchContext,
1112
} from "~checker/store";
@@ -27,30 +28,38 @@ export const ReviewApplicationsPage = () => {
2728
dispatch(goToSubmitFinalEvaluationAction());
2829
};
2930

31+
const openRoundInManager = () => {
32+
window.open(`https://manager.gitcoin.co/#/chain/${chainId}/round/${poolId}`, "_blank");
33+
};
34+
35+
const openApplicationOnManager = (projectId: string) => {
36+
dispatch(goToSubmitApplicationEvaluationAction({ projectId }));
37+
};
3038
const ReadyApplicationsToSubmit = categorizedReviews?.READY_TO_REVIEW || [];
3139

3240
const PendingApplications = categorizedReviews?.INREVIEW || [];
3341

42+
const ApprovedApplications = categorizedReviews?.APPROVED || [];
43+
const RejectedApplications = categorizedReviews?.REJECTED || [];
44+
3445
return (
3546
<div className="flex flex-col gap-6 ">
3647
<PoolSummary
3748
chainId={chainId}
3849
poolId={poolId}
3950
strategyName={application?.round.strategyName ?? ""}
4051
name={application?.round.roundMetadata.name ?? ""}
41-
registerStartDate={new Date()}
42-
registerEndDate={new Date()}
43-
allocationStartDate={new Date()}
44-
allocationEndDate={new Date()}
52+
registerStartDate={new Date(application?.round.applicationsStartTime ?? new Date())}
53+
registerEndDate={new Date(application?.round.applicationsEndTime ?? new Date())}
54+
allocationStartDate={new Date(application?.round.donationsStartTime ?? new Date())}
55+
allocationEndDate={new Date(application?.round.donationsEndTime ?? new Date())}
4556
/>
4657
<div className="mx-auto flex max-w-[1440px] flex-col gap-6 px-20">
4758
<div className="flex justify-start">
4859
<Button
4960
variant="secondry"
5061
icon={<Icon type={IconType.CHEVRON_LEFT} />}
51-
onClick={() =>
52-
window.open(`https://manager.gitcoin.co/#/chain/${chainId}/round/${poolId}`)
53-
}
62+
onClick={openRoundInManager}
5463
value="back to round manager"
5564
/>
5665
</div>
@@ -87,7 +96,7 @@ export const ReviewApplicationsPage = () => {
8796
</div>
8897
) : (
8998
<ProjectReviewList
90-
reviewer={address || "0x"}
99+
reviewer={address}
91100
projects={ReadyApplicationsToSubmit}
92101
action={goToApplicationEvaluationOverview}
93102
/>
@@ -111,13 +120,65 @@ export const ReviewApplicationsPage = () => {
111120
</div>
112121
) : (
113122
<ProjectReviewList
114-
reviewer={address || "0x"}
123+
reviewer={address}
115124
projects={PendingApplications}
116125
action={goToApplicationEvaluationOverview}
117126
/>
118127
)}
119128
</div>
120129
</div>
130+
<div className="flex flex-col gap-2">
131+
<div className="pb-1">
132+
<div className="flex items-center justify-start pb-1">
133+
<div className="font-mono text-2xl font-medium leading-loose text-black">
134+
{`Approved applications (${ApprovedApplications.length})`}
135+
</div>
136+
</div>
137+
<div className="h-px bg-[#c8cccc]" />
138+
</div>
139+
140+
<div>
141+
{ApprovedApplications.length === 0 ? (
142+
<div className="font-mono text-base font-normal leading-7 text-grey-900">
143+
No approved applications.
144+
</div>
145+
) : (
146+
<ProjectReviewList
147+
reviewer={address}
148+
projects={ApprovedApplications}
149+
action={openApplicationOnManager}
150+
actionLabel="View project"
151+
keepAction
152+
/>
153+
)}
154+
</div>
155+
</div>
156+
<div className="flex flex-col gap-2">
157+
<div className="pb-1">
158+
<div className="flex items-center justify-start pb-1">
159+
<div className="font-mono text-2xl font-medium leading-loose text-black">
160+
{`Rejected applications (${RejectedApplications.length})`}
161+
</div>
162+
</div>
163+
<div className="h-px bg-[#c8cccc]" />
164+
</div>
165+
166+
<div>
167+
{RejectedApplications.length === 0 ? (
168+
<div className="font-mono text-base font-normal leading-7 text-grey-900">
169+
No rejected applications.
170+
</div>
171+
) : (
172+
<ProjectReviewList
173+
reviewer={address}
174+
projects={RejectedApplications}
175+
action={openApplicationOnManager}
176+
actionLabel="View project"
177+
keepAction
178+
/>
179+
)}
180+
</div>
181+
</div>
121182
</div>
122183
</div>
123184
</div>

src/features/checker/pages/SubmitApplicationEvaluationPage/SubmitApplicationEvaluationPage.tsx

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// src/components/SubmitApplicationEvaluation/SubmitApplicationEvaluationPage.tsx
22
import { useEffect, useState } from "react";
33

4+
import { useQueryClient } from "@tanstack/react-query";
45
import { Hex } from "viem";
56

67
import { ApplicationBadge, ApplicationBadgeStatus } from "@/components/Badges";
@@ -65,10 +66,10 @@ export const SubmitApplicationEvaluationPage = ({
6566
const { application, evaluationQuestions } =
6667
useApplicationOverviewEvaluations({ applicationId }) || {};
6768

68-
const [toastShowed, setToastShowed] = useState(false);
6969
const dispatch = useCheckerDispatchContext();
7070
const { data: pastApplications } = useGetPastApplications(chainId, poolId, applicationId);
7171
const { toast } = useToast();
72+
const queryClient = useQueryClient();
7273

7374
const showToast = () => {
7475
toast({
@@ -89,13 +90,15 @@ export const SubmitApplicationEvaluationPage = ({
8990
};
9091

9192
useEffect(() => {
92-
if ((isSuccess || isError) && !toastShowed) {
93-
setToastShowed(true);
93+
if ((isSuccess || isError) && isModalOpen) {
9494
setIsModalOpen(false);
9595
showToast();
9696
goToSubmitFinalEvaluation();
97+
if (isSuccess) {
98+
queryClient.invalidateQueries({ queryKey: ["poolData", chainId, poolId] }); // Invalidate the query
99+
}
97100
}
98-
}, [isSuccess, isError, toastShowed]);
101+
}, [isSuccess, isError]);
99102

100103
if (!application || !evaluationQuestions) return null;
101104

@@ -191,10 +194,10 @@ export const SubmitApplicationEvaluationPage = ({
191194
poolId={poolId}
192195
strategyName={application.round.strategyName}
193196
name={application.round.roundMetadata.name}
194-
registerStartDate={new Date()}
195-
registerEndDate={new Date()}
196-
allocationStartDate={new Date()}
197-
allocationEndDate={new Date()}
197+
registerStartDate={new Date(application.round.applicationsStartTime)}
198+
registerEndDate={new Date(application.round.applicationsEndTime)}
199+
allocationStartDate={new Date(application.round.donationsStartTime)}
200+
allocationEndDate={new Date(application.round.donationsEndTime)}
198201
/>
199202
<div className="mx-auto flex max-w-[1440px] flex-col gap-4 px-20">
200203
<SubmitApplicationEvaluationModal

src/features/checker/pages/SubmitFinalEvaluationPage/SubmitFinalEvaluationPage.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useState, useMemo, useEffect } from "react";
22

3+
import { useQueryClient } from "@tanstack/react-query";
34
import { match } from "ts-pattern";
45

56
import { Step } from "@/components/ProgressModal";
@@ -79,9 +80,12 @@ export const SubmitFinalEvaluationPage = ({
7980
return [success, error];
8081
}, [steps]);
8182

83+
const queryClient = useQueryClient();
84+
8285
useEffect(() => {
8386
if (success && isModalOpen) {
8487
setReviewBody(null);
88+
queryClient.invalidateQueries({ queryKey: ["poolData", chainId, poolId] }); // Invalidate the query
8589
setIsModalOpen(false);
8690
toast({ status: "success", description: "Your evaluations have been submitted" });
8791
dispatch(goToReviewApplicationsAction());
@@ -109,10 +113,10 @@ export const SubmitFinalEvaluationPage = ({
109113
poolId={poolId ?? "1"}
110114
strategyName={application?.round.strategyName ?? ""}
111115
name={application?.round.roundMetadata.name ?? ""}
112-
registerStartDate={new Date()}
113-
registerEndDate={new Date()}
114-
allocationStartDate={new Date()}
115-
allocationEndDate={new Date()}
116+
registerStartDate={new Date(application?.round.applicationsStartTime ?? new Date())}
117+
registerEndDate={new Date(application?.round.applicationsEndTime ?? new Date())}
118+
allocationStartDate={new Date(application?.round.donationsStartTime ?? new Date())}
119+
allocationEndDate={new Date(application?.round.donationsEndTime ?? new Date())}
116120
/>
117121
<div className="mx-auto flex max-w-[1440px] flex-col gap-6 px-20">
118122
<div className="flex justify-start">

0 commit comments

Comments
 (0)