Skip to content

Commit 46590d7

Browse files
committed
chore: refactor ViewCartPage splitting components and fixing hook dependencies
1 parent 965e946 commit 46590d7

File tree

11 files changed

+606
-570
lines changed

11 files changed

+606
-570
lines changed

packages/grant-explorer/src/features/round/DonateToGitcoin.tsx

Lines changed: 0 additions & 311 deletions
This file was deleted.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { useMemo, useCallback } from "react";
2+
import { Checkbox } from "@chakra-ui/react";
3+
import { useDonateToGitcoin } from "../DonateToGitcoinContext";
4+
import React from "react";
5+
import { DonateToGitcoinContent } from "./components/DonateToGitcoinContent";
6+
7+
type TokenFilter = {
8+
chainId: number;
9+
addresses: string[];
10+
};
11+
12+
export type DonationDetails = {
13+
chainId: number;
14+
tokenAddress: string;
15+
amount: string;
16+
};
17+
18+
type DonateToGitcoinProps = {
19+
divider?: "none" | "top" | "bottom";
20+
tokenFilters?: TokenFilter[];
21+
};
22+
23+
export const DonateToGitcoin = React.memo(
24+
({ divider = "none" }: DonateToGitcoinProps) => {
25+
const { isEnabled, setIsEnabled } = useDonateToGitcoin();
26+
27+
const handleCheckboxChange = useCallback(
28+
(value: React.ChangeEvent<HTMLInputElement>) => {
29+
setIsEnabled(value.target.checked);
30+
},
31+
[setIsEnabled]
32+
);
33+
34+
const borderClass = useMemo(() => {
35+
switch (divider) {
36+
case "top":
37+
return "border-t";
38+
case "bottom":
39+
return "border-b";
40+
default:
41+
return "";
42+
}
43+
}, [divider]);
44+
45+
return (
46+
<div className={`flex flex-col justify-center mt-2 py-4 ${borderClass}`}>
47+
<div className={`${!isEnabled ? "opacity-50" : ""}`}>
48+
<p className="font-sans font-medium flex items-center">
49+
<Checkbox
50+
className="mr-2"
51+
border={"1px"}
52+
borderRadius={"4px"}
53+
colorScheme="whiteAlpha"
54+
iconColor="black"
55+
size="lg"
56+
isChecked={isEnabled}
57+
onChange={handleCheckboxChange}
58+
/>
59+
<img
60+
className="inline mr-2 w-5 h-5"
61+
alt="Gitcoin"
62+
src="/logos/gitcoin-gist-logo.svg"
63+
/>
64+
<span className="font-sans font-medium">Donate to Gitcoin</span>
65+
</p>
66+
</div>
67+
68+
<DonateToGitcoinContent />
69+
</div>
70+
);
71+
},
72+
(prevProps, nextProps) => prevProps.divider === nextProps.divider
73+
);

0 commit comments

Comments
 (0)