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

Commit

Permalink
add custom fields based on pool type
Browse files Browse the repository at this point in the history
  • Loading branch information
thelostone-mc committed Jan 28, 2025
1 parent 97b556e commit 8712dc3
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/components/IconLabel/IconLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const IconLabel: React.FC<
))
.with(
{ type: "roundPeriod" },
({ startDate, endDate = undefined, className, isLoading, label }) => (
({ startDate, endDate = undefined, className, isLoading, label = "Review Period" }) => (
<IconLabelContainer
type="period"
className={className}
Expand Down
2 changes: 1 addition & 1 deletion src/components/IconLabel/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ interface PeriodProps {

interface RoundPeriodProps {
type: "roundPeriod";
label: string;
startDate: Date;
endDate?: Date;
label?: string;
className?: string;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Button } from "@/primitives/Button";
import { Icon, IconType } from "@/primitives/Icon";
import { StatCardProps } from "@/primitives/StatCard";
import { StatCardGroup } from "@/primitives/StatCardGroup";
import { PoolType } from "@/types";

import { ApplicationsSection } from "~checker/components";
import { useGetApplicationsReviewPage } from "~checker/hooks";
Expand All @@ -15,7 +16,7 @@ import {
useCheckerContext,
useCheckerDispatchContext,
} from "~checker/store";
import { getManagerUrl } from "~checker/utils";
import { getManagerUrl, getRoundLinkOnManager } from "~checker/utils";
import { PoolSummary } from "~pool";

export const ReviewApplicationsPage = ({ isStandalone }: { isStandalone: boolean }) => {
Expand Down Expand Up @@ -51,7 +52,10 @@ export const ReviewApplicationsPage = ({ isStandalone }: { isStandalone: boolean
};

const openRoundInManager = () => {
window.open(`${getManagerUrl(chainId)}/#/chain/${chainId}/round/${poolId}`, "_blank");
window.open(
getRoundLinkOnManager(chainId, poolId, poolData?.strategyName as PoolType),
"_blank",
);
};

const openCheckerApplicationEvaluations = (projectId: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useToast } from "@/hooks/useToast";
import { Button } from "@/primitives/Button";
import { Icon, IconType } from "@/primitives/Icon";
import { StatCardGroup } from "@/primitives/StatCardGroup";
import { Step } from "@/types";
import { PoolType, Step } from "@/types";

import { ProjectEvaluationList } from "~checker/components";
import { useGetApplicationsFinalEvaluationPage } from "~checker/hooks";
Expand All @@ -19,7 +19,7 @@ import {
useCheckerContext,
} from "~checker/store";
import { EvaluationAction, ReviewBody } from "~checker/types";
import { getManagerUrl } from "~checker/utils";
import { getManagerUrl, getRoundLinkOnManager } from "~checker/utils";
import { PoolSummary } from "~pool";

import { SubmitFinalEvaluationModal } from "./SubmitFinalEvaluationModal";
Expand Down Expand Up @@ -136,7 +136,13 @@ export const SubmitFinalEvaluationPage = ({
variant="secondry"
icon={<Icon type={IconType.CHEVRON_LEFT} />}
onClick={() =>
window.open(`${getManagerUrl(chainId as number)}/#/chain/${chainId}/round/${poolId}`)
window.open(
getRoundLinkOnManager(
chainId as number,
poolId as string,
poolData?.strategyName as PoolType,
),
)
}
value="back to round manager"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Icon, IconType } from "@/primitives/Icon";
import { ApplicationSummary, SummaryAccordians } from "~application";
import { ReviewDropdownList } from "~checker/components";
import { useApplicationEvaluations, useGetPastApplications } from "~checker/hooks";
import { getExplorerUrl } from "~checker/utils";
import { getApplicationLinkOnExplorer, getExplorerUrl } from "~checker/utils";
import { ProjectBanner } from "~project";
import { ProjectSummary } from "~project";

Expand Down Expand Up @@ -80,10 +80,7 @@ export const ViewApplicationEvaluationsPage: React.FC<ViewApplicationEvaluations
variant="none"
className="h-[38px] w-40 bg-white"
onClick={() => {
window.open(
`${getExplorerUrl(chainId)}/#/round/${chainId}/${poolId}/${applicationId}`,
"_blank",
);
window.open(getApplicationLinkOnExplorer(chainId, poolId, applicationId), "_blank");
}}
/>
</div>
Expand Down
115 changes: 101 additions & 14 deletions src/features/checker/utils/getGitcoinLinks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { getChains, TChain } from "@gitcoin/gitcoin-chain-data";

import { PoolType } from "@/types";

type ChainIdToType = Record<number, string>;

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

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

export const getBuilderUrl = (chainId: number): string => {
const chainType = chainIdToType[chainId];
return chainType === "mainnet"
? "https://builder.gitcoin.co"
: "https://grants-stack-builder-staging.vercel.app";
// --- Manager ---

export const getManagerUrl = (chainId: number, strategyName?: PoolType): string => {
switch (strategyName) {
case PoolType.Retrofunding:
return "https://retrofunding-amber.vercel.app";
default:
return getUrlByChainType(
chainId,
"https://manager.gitcoin.co",
"https://grants-stack-manager-staging.vercel.app",
);
}
};

export const getExplorerUrl = (chainId: number): string => {
const chainType = chainIdToType[chainId];
return chainType === "mainnet"
? "https://explorer.gitcoin.co"
: "https://grants-stack-explorer-staging.vercel.app";
export const getProgramLinkOnManager = (
chainId: number,
programId: string,
strategyName?: PoolType,
) => {
switch (strategyName) {
default:
return `${getManagerUrl(chainId, strategyName)}/#/chain/${chainId}/program/${programId}`;
}
};

export const getRoundLinkOnManager = (chainId: number, poolId: string, strategyName?: PoolType) => {
switch (strategyName) {
default:
return `${getManagerUrl(chainId, strategyName)}/#/chain/${chainId}/round/${poolId}`;
}
};

// Builder

export const getBuilderUrl = (chainId: number, strategyName?: PoolType): string => {
switch (strategyName) {
case PoolType.Retrofunding:
default:
return getUrlByChainType(
chainId,
"https://builder.gitcoin.co",
"https://grants-stack-builder-staging.vercel.app",
);
}
};

export const getApplyLink = (chainId: number, poolId: string, strategyName?: PoolType) => {
switch (strategyName) {
default:
return `${getBuilderUrl(chainId, strategyName)}/#/chains/${chainId}/rounds/${poolId}/apply`;
}
};

// --- Explorer ---
export const getExplorerUrl = (chainId: number, strategyName?: PoolType): string => {
switch (strategyName) {
case PoolType.Retrofunding:
return "https://retrofunding-vote.vercel.app";
default:
return getUrlByChainType(
chainId,
"https://explorer.gitcoin.co",
"https://grants-stack-explorer-staging.vercel.app",
);
}
};

export const getPoolLinkOnExplorer = (chainId: number, poolId: string, strategyName?: PoolType) => {
switch (strategyName) {
default:
return `${getExplorerUrl(chainId, strategyName)}/#/round/${chainId}/${poolId}`;
}
};

export const getApplicationLinkOnExplorer = (
chainId: number,
poolId: string,
applicationId: string,
strategyName?: PoolType,
) => {
switch (strategyName) {
default:
return `${getExplorerUrl(
chainId,
strategyName,
)}/#/round/${chainId}/${poolId}/${applicationId}`;
}
};

export const getVotingInterfaceLinkOnExplorer = (
chainId: number,
poolId: string,
strategyName?: PoolType,
) => {
switch (strategyName) {
default:
return `${getExplorerUrl(chainId, strategyName)}/#/round/${chainId}/${poolId}/voting`;
}
};
31 changes: 21 additions & 10 deletions src/features/pool/components/PoolSummary/PoolSummary.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
import type { Meta, StoryObj } from "@storybook/react";

import { PoolType } from "@/types";

import { PoolSummary, PoolSummaryProps } from "./PoolSummary";

const defaultProps = {
chainId: 1,
name: "Beta Round",
poolId: "1",
strategyName: PoolType.QuadraticFunding,
applicationsStartTime: "2024-12-09T19:22:56.413Z",
applicationsEndTime: "2024-12-10T19:23:30.678Z",
donationsStartTime: "2024-12-09T19:22:56.413Z",
donationsEndTime: "2024-12-09T19:22:56.413Z",
};

const meta: Meta<PoolSummaryProps> = {
title: "Features/Pool/PoolSummary",
component: PoolSummary,
args: {
chainId: 1,
name: "Beta Round",
poolId: "1",
strategyName: "allov2.DonationVotingMerkleDistributionDirectTransferStrategy",
applicationsStartTime: "2024-12-09T19:22:56.413Z",
applicationsEndTime: "2024-12-10T19:23:30.678Z",
donationsStartTime: "2024-12-09T19:22:56.413Z",
donationsEndTime: "2024-12-09T19:22:56.413Z",
},
args: defaultProps,
} satisfies Meta;

export default meta;

type Story = StoryObj<typeof PoolSummary>;

export const Default: Story = {};

export const Retrofunding: Story = {
args: {
...defaultProps,
strategyName: PoolType.Retrofunding,
},
};
Loading

0 comments on commit 8712dc3

Please sign in to comment.