Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8712dc3

Browse files
committedJan 28, 2025·
add custom fields based on pool type
1 parent 97b556e commit 8712dc3

File tree

8 files changed

+199
-52
lines changed

8 files changed

+199
-52
lines changed
 

‎src/components/IconLabel/IconLabel.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const IconLabel: React.FC<
7474
))
7575
.with(
7676
{ type: "roundPeriod" },
77-
({ startDate, endDate = undefined, className, isLoading, label }) => (
77+
({ startDate, endDate = undefined, className, isLoading, label = "Review Period" }) => (
7878
<IconLabelContainer
7979
type="period"
8080
className={className}

‎src/components/IconLabel/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ interface PeriodProps {
2121

2222
interface RoundPeriodProps {
2323
type: "roundPeriod";
24-
label: string;
2524
startDate: Date;
2625
endDate?: Date;
26+
label?: string;
2727
className?: string;
2828
}
2929

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Button } from "@/primitives/Button";
66
import { Icon, IconType } from "@/primitives/Icon";
77
import { StatCardProps } from "@/primitives/StatCard";
88
import { StatCardGroup } from "@/primitives/StatCardGroup";
9+
import { PoolType } from "@/types";
910

1011
import { ApplicationsSection } from "~checker/components";
1112
import { useGetApplicationsReviewPage } from "~checker/hooks";
@@ -15,7 +16,7 @@ import {
1516
useCheckerContext,
1617
useCheckerDispatchContext,
1718
} from "~checker/store";
18-
import { getManagerUrl } from "~checker/utils";
19+
import { getManagerUrl, getRoundLinkOnManager } from "~checker/utils";
1920
import { PoolSummary } from "~pool";
2021

2122
export const ReviewApplicationsPage = ({ isStandalone }: { isStandalone: boolean }) => {
@@ -51,7 +52,10 @@ export const ReviewApplicationsPage = ({ isStandalone }: { isStandalone: boolean
5152
};
5253

5354
const openRoundInManager = () => {
54-
window.open(`${getManagerUrl(chainId)}/#/chain/${chainId}/round/${poolId}`, "_blank");
55+
window.open(
56+
getRoundLinkOnManager(chainId, poolId, poolData?.strategyName as PoolType),
57+
"_blank",
58+
);
5559
};
5660

5761
const openCheckerApplicationEvaluations = (projectId: string) => {

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useToast } from "@/hooks/useToast";
99
import { Button } from "@/primitives/Button";
1010
import { Icon, IconType } from "@/primitives/Icon";
1111
import { StatCardGroup } from "@/primitives/StatCardGroup";
12-
import { Step } from "@/types";
12+
import { PoolType, Step } from "@/types";
1313

1414
import { ProjectEvaluationList } from "~checker/components";
1515
import { useGetApplicationsFinalEvaluationPage } from "~checker/hooks";
@@ -19,7 +19,7 @@ import {
1919
useCheckerContext,
2020
} from "~checker/store";
2121
import { EvaluationAction, ReviewBody } from "~checker/types";
22-
import { getManagerUrl } from "~checker/utils";
22+
import { getManagerUrl, getRoundLinkOnManager } from "~checker/utils";
2323
import { PoolSummary } from "~pool";
2424

2525
import { SubmitFinalEvaluationModal } from "./SubmitFinalEvaluationModal";
@@ -136,7 +136,13 @@ export const SubmitFinalEvaluationPage = ({
136136
variant="secondry"
137137
icon={<Icon type={IconType.CHEVRON_LEFT} />}
138138
onClick={() =>
139-
window.open(`${getManagerUrl(chainId as number)}/#/chain/${chainId}/round/${poolId}`)
139+
window.open(
140+
getRoundLinkOnManager(
141+
chainId as number,
142+
poolId as string,
143+
poolData?.strategyName as PoolType,
144+
),
145+
)
140146
}
141147
value="back to round manager"
142148
/>

‎src/features/checker/pages/ViewApplicationEvaluationsPage/ViewApplicationEvaluationsPage.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Icon, IconType } from "@/primitives/Icon";
1111
import { ApplicationSummary, SummaryAccordians } from "~application";
1212
import { ReviewDropdownList } from "~checker/components";
1313
import { useApplicationEvaluations, useGetPastApplications } from "~checker/hooks";
14-
import { getExplorerUrl } from "~checker/utils";
14+
import { getApplicationLinkOnExplorer, getExplorerUrl } from "~checker/utils";
1515
import { ProjectBanner } from "~project";
1616
import { ProjectSummary } from "~project";
1717

@@ -80,10 +80,7 @@ export const ViewApplicationEvaluationsPage: React.FC<ViewApplicationEvaluations
8080
variant="none"
8181
className="h-[38px] w-40 bg-white"
8282
onClick={() => {
83-
window.open(
84-
`${getExplorerUrl(chainId)}/#/round/${chainId}/${poolId}/${applicationId}`,
85-
"_blank",
86-
);
83+
window.open(getApplicationLinkOnExplorer(chainId, poolId, applicationId), "_blank");
8784
}}
8885
/>
8986
</div>
+101-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { getChains, TChain } from "@gitcoin/gitcoin-chain-data";
22

3+
import { PoolType } from "@/types";
4+
35
type ChainIdToType = Record<number, string>;
46

57
const chainData = getChains();
@@ -9,23 +11,108 @@ const chainIdToType: ChainIdToType = chainData.reduce((acc, chain: TChain) => {
911
return acc;
1012
}, {} as ChainIdToType);
1113

12-
export const getManagerUrl = (chainId: number): string => {
14+
const getUrlByChainType = (chainId: number, mainnetUrl: string, stagingUrl: string): string => {
1315
const chainType = chainIdToType[chainId];
14-
return chainType === "mainnet"
15-
? "https://manager.gitcoin.co"
16-
: "https://grants-stack-manager-staging.vercel.app";
16+
return chainType === "mainnet" ? mainnetUrl : stagingUrl;
1717
};
1818

19-
export const getBuilderUrl = (chainId: number): string => {
20-
const chainType = chainIdToType[chainId];
21-
return chainType === "mainnet"
22-
? "https://builder.gitcoin.co"
23-
: "https://grants-stack-builder-staging.vercel.app";
19+
// --- Manager ---
20+
21+
export const getManagerUrl = (chainId: number, strategyName?: PoolType): string => {
22+
switch (strategyName) {
23+
case PoolType.Retrofunding:
24+
return "https://retrofunding-amber.vercel.app";
25+
default:
26+
return getUrlByChainType(
27+
chainId,
28+
"https://manager.gitcoin.co",
29+
"https://grants-stack-manager-staging.vercel.app",
30+
);
31+
}
2432
};
2533

26-
export const getExplorerUrl = (chainId: number): string => {
27-
const chainType = chainIdToType[chainId];
28-
return chainType === "mainnet"
29-
? "https://explorer.gitcoin.co"
30-
: "https://grants-stack-explorer-staging.vercel.app";
34+
export const getProgramLinkOnManager = (
35+
chainId: number,
36+
programId: string,
37+
strategyName?: PoolType,
38+
) => {
39+
switch (strategyName) {
40+
default:
41+
return `${getManagerUrl(chainId, strategyName)}/#/chain/${chainId}/program/${programId}`;
42+
}
43+
};
44+
45+
export const getRoundLinkOnManager = (chainId: number, poolId: string, strategyName?: PoolType) => {
46+
switch (strategyName) {
47+
default:
48+
return `${getManagerUrl(chainId, strategyName)}/#/chain/${chainId}/round/${poolId}`;
49+
}
50+
};
51+
52+
// Builder
53+
54+
export const getBuilderUrl = (chainId: number, strategyName?: PoolType): string => {
55+
switch (strategyName) {
56+
case PoolType.Retrofunding:
57+
default:
58+
return getUrlByChainType(
59+
chainId,
60+
"https://builder.gitcoin.co",
61+
"https://grants-stack-builder-staging.vercel.app",
62+
);
63+
}
64+
};
65+
66+
export const getApplyLink = (chainId: number, poolId: string, strategyName?: PoolType) => {
67+
switch (strategyName) {
68+
default:
69+
return `${getBuilderUrl(chainId, strategyName)}/#/chains/${chainId}/rounds/${poolId}/apply`;
70+
}
71+
};
72+
73+
// --- Explorer ---
74+
export const getExplorerUrl = (chainId: number, strategyName?: PoolType): string => {
75+
switch (strategyName) {
76+
case PoolType.Retrofunding:
77+
return "https://retrofunding-vote.vercel.app";
78+
default:
79+
return getUrlByChainType(
80+
chainId,
81+
"https://explorer.gitcoin.co",
82+
"https://grants-stack-explorer-staging.vercel.app",
83+
);
84+
}
85+
};
86+
87+
export const getPoolLinkOnExplorer = (chainId: number, poolId: string, strategyName?: PoolType) => {
88+
switch (strategyName) {
89+
default:
90+
return `${getExplorerUrl(chainId, strategyName)}/#/round/${chainId}/${poolId}`;
91+
}
92+
};
93+
94+
export const getApplicationLinkOnExplorer = (
95+
chainId: number,
96+
poolId: string,
97+
applicationId: string,
98+
strategyName?: PoolType,
99+
) => {
100+
switch (strategyName) {
101+
default:
102+
return `${getExplorerUrl(
103+
chainId,
104+
strategyName,
105+
)}/#/round/${chainId}/${poolId}/${applicationId}`;
106+
}
107+
};
108+
109+
export const getVotingInterfaceLinkOnExplorer = (
110+
chainId: number,
111+
poolId: string,
112+
strategyName?: PoolType,
113+
) => {
114+
switch (strategyName) {
115+
default:
116+
return `${getExplorerUrl(chainId, strategyName)}/#/round/${chainId}/${poolId}/voting`;
117+
}
31118
};
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,35 @@
11
import type { Meta, StoryObj } from "@storybook/react";
22

3+
import { PoolType } from "@/types";
4+
35
import { PoolSummary, PoolSummaryProps } from "./PoolSummary";
46

7+
const defaultProps = {
8+
chainId: 1,
9+
name: "Beta Round",
10+
poolId: "1",
11+
strategyName: PoolType.QuadraticFunding,
12+
applicationsStartTime: "2024-12-09T19:22:56.413Z",
13+
applicationsEndTime: "2024-12-10T19:23:30.678Z",
14+
donationsStartTime: "2024-12-09T19:22:56.413Z",
15+
donationsEndTime: "2024-12-09T19:22:56.413Z",
16+
};
17+
518
const meta: Meta<PoolSummaryProps> = {
619
title: "Features/Pool/PoolSummary",
720
component: PoolSummary,
8-
args: {
9-
chainId: 1,
10-
name: "Beta Round",
11-
poolId: "1",
12-
strategyName: "allov2.DonationVotingMerkleDistributionDirectTransferStrategy",
13-
applicationsStartTime: "2024-12-09T19:22:56.413Z",
14-
applicationsEndTime: "2024-12-10T19:23:30.678Z",
15-
donationsStartTime: "2024-12-09T19:22:56.413Z",
16-
donationsEndTime: "2024-12-09T19:22:56.413Z",
17-
},
21+
args: defaultProps,
1822
} satisfies Meta;
1923

2024
export default meta;
2125

2226
type Story = StoryObj<typeof PoolSummary>;
2327

2428
export const Default: Story = {};
29+
30+
export const Retrofunding: Story = {
31+
args: {
32+
...defaultProps,
33+
strategyName: PoolType.Retrofunding,
34+
},
35+
};

‎src/features/pool/components/PoolSummary/PoolSummary.tsx

+58-16
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ import { Button } from "@/primitives/Button";
1111
import { Icon, IconType } from "@/primitives/Icon";
1212
import { PoolStatus, PoolType } from "@/types";
1313

14-
import { getManagerUrl, getBuilderUrl, getExplorerUrl } from "~checker/utils";
14+
import {
15+
getApplyLink,
16+
getPoolLinkOnExplorer,
17+
getProgramLinkOnManager,
18+
getManagerUrl,
19+
getVotingInterfaceLinkOnExplorer,
20+
} from "~checker/utils";
1521

1622
import { PoolBadge } from "../PoolBadge";
1723

@@ -38,13 +44,11 @@ export const PoolSummary = (pool: PoolSummaryProps) => {
3844
const { toast } = useToast();
3945
const chainInfo = getChainInfo(pool.chainId);
4046

41-
const managerUrl = getManagerUrl(pool.chainId);
42-
const builderUrl = getBuilderUrl(pool.chainId);
43-
const explorerUrl = getExplorerUrl(pool.chainId);
44-
4547
let poolStatus: PoolStatus;
4648
const poolType = pool.strategyName as PoolType;
4749

50+
const managerUrl = getManagerUrl(pool.chainId, poolType);
51+
4852
const now = new Date();
4953

5054
const registerStartDate = pool.applicationsStartTime
@@ -67,9 +71,9 @@ export const PoolSummary = (pool: PoolSummaryProps) => {
6771
} else {
6872
poolStatus = PoolStatus.PreRound;
6973
}
70-
const applyLink = `${builderUrl}/#/chains/${pool.chainId}/rounds/${pool.poolId}/apply`;
71-
const explorerLink = `${explorerUrl}/#/round/${pool.chainId}/${pool.poolId}`;
72-
const managerProgramLink = `${managerUrl}/#/chain/${pool.chainId}/program/${pool.programId}`;
74+
const applyLink = getApplyLink(pool.chainId, pool.poolId, poolType);
75+
const explorerLink = getPoolLinkOnExplorer(pool.chainId, pool.poolId, poolType);
76+
const managerProgramLink = getProgramLinkOnManager(pool.chainId, pool.programId, poolType);
7377
const breadcrumbItems = [
7478
{ label: "My Programs", href: managerUrl },
7579
{
@@ -81,6 +85,13 @@ export const PoolSummary = (pool: PoolSummaryProps) => {
8185
href: explorerLink,
8286
},
8387
];
88+
89+
const { registerDateLabel, allocationDateLabel, viewButton } = getInfoBasedOnPoolType(
90+
poolType,
91+
pool,
92+
explorerLink,
93+
);
94+
8495
return (
8596
<div className={cn(variants.variants.default, "grid grid-cols-2 py-6")}>
8697
<div className="flex flex-col items-start justify-start gap-4">
@@ -105,14 +116,14 @@ export const PoolSummary = (pool: PoolSummaryProps) => {
105116
startDate={registerStartDate}
106117
endDate={registerEndDate}
107118
isLoading={pool.isLoading}
108-
label="Review"
119+
label={registerDateLabel}
109120
/>
110121
<IconLabel
111122
type="roundPeriod"
112123
startDate={allocationStartDate}
113124
endDate={allocationEndDate}
114125
isLoading={pool.isLoading}
115-
label="Voting"
126+
label={allocationDateLabel}
116127
/>
117128
</div>
118129
</div>
@@ -140,14 +151,45 @@ export const PoolSummary = (pool: PoolSummaryProps) => {
140151
);
141152
}}
142153
/>
143-
<Button
144-
icon={<Icon type={IconType.EXPLORER} />}
145-
className="border-grey-100 bg-white text-black shadow-sm"
146-
value="View round"
147-
onClick={() => window.open(explorerLink, "_blank")}
148-
/>
154+
{viewButton}
149155
</div>
150156
</div>
151157
</div>
152158
);
153159
};
160+
161+
function getInfoBasedOnPoolType(poolType: PoolType, pool: PoolSummaryProps, explorerLink: string) {
162+
let allocationDateLabel;
163+
let registerDateLabel;
164+
let viewButton;
165+
166+
if (poolType === PoolType.Retrofunding) {
167+
registerDateLabel = "Applications";
168+
allocationDateLabel = "Voting";
169+
viewButton = (
170+
<Button
171+
icon={<Icon type={IconType.LINK} />}
172+
className="border-grey-100 bg-white text-black shadow-sm"
173+
value="Voting Interface"
174+
onClick={() =>
175+
window.open(
176+
getVotingInterfaceLinkOnExplorer(pool.chainId, pool.poolId, poolType),
177+
"_blank",
178+
)
179+
}
180+
/>
181+
);
182+
} else {
183+
registerDateLabel = "Review";
184+
allocationDateLabel = "Allocation";
185+
viewButton = (
186+
<Button
187+
icon={<Icon type={IconType.EXPLORER} />}
188+
className="border-grey-100 bg-white text-black shadow-sm"
189+
value="View round"
190+
onClick={() => window.open(explorerLink, "_blank")}
191+
/>
192+
);
193+
}
194+
return { registerDateLabel, allocationDateLabel, viewButton };
195+
}

0 commit comments

Comments
 (0)
This repository has been archived.