-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathuser-entrypoints.tsx
More file actions
107 lines (89 loc) · 3.08 KB
/
user-entrypoints.tsx
File metadata and controls
107 lines (89 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { ByPotId, indexer } from "@/common/api/indexer";
import { NOOP_STRING, PUBLIC_GOODS_REGISTRY_LIST_ID } from "@/common/constants";
import { type ByAccountId, ByCampaignId, ByListId } from "@/common/types";
import { Button, type ButtonProps, Skeleton } from "@/common/ui/layout/components";
import { cn } from "@/common/ui/layout/utils";
import { type DonationUserFlowProps, useDonationUserFlow } from "../hooks/user-flow";
export const DonateRandomly = () => {
const {
isLoading: isRandomPGRegistryEntryLoading,
data: randomPGRegistryEntry,
mutate: refetchRandomPGRegistryEntry,
} = indexer.useRandomListRegistration({
listId: PUBLIC_GOODS_REGISTRY_LIST_ID,
status: "Approved",
});
const randomProjectAccountId = randomPGRegistryEntry?.registrant.id;
const { openDonationModal: openRandomDonationModal } = useDonationUserFlow({
accountId: randomProjectAccountId ?? NOOP_STRING,
});
const onDonateRandomlyClick = (event: React.MouseEvent) => {
openRandomDonationModal(event);
refetchRandomPGRegistryEntry();
};
return isRandomPGRegistryEntryLoading ? (
<Skeleton className="h-10 w-full bg-[rgba(246,118,122,0.3)] md:w-[180px]" />
) : (
randomProjectAccountId && (
<Button className="w-full md:w-[180px]" onClick={onDonateRandomlyClick}>
{"Donate Randomly"}
</Button>
)
);
};
export type DonateToAccountButtonProps = ByAccountId &
Pick<ButtonProps, "className" | "variant"> & {};
export const DonateToAccountButton: React.FC<DonateToAccountButtonProps> = ({
accountId,
variant: variantProp,
className,
}) => {
const { openDonationModal } = useDonationUserFlow({ accountId });
return (
<Button
variant={variantProp ?? "standard-outline"}
onClick={openDonationModal}
className={cn("w-full", className)}
>
{"Donate"}
</Button>
);
};
export type DonateToPotProjectsProps = ByPotId & {};
export const DonateToPotProjects: React.FC<DonateToPotProjectsProps> = ({ potId }) => {
const { openDonationModal } = useDonationUserFlow({ potId });
return <Button onClick={openDonationModal}>{"Donate to Projects"}</Button>;
};
export type DonateToListProjectsProps = ByListId & {};
export const DonateToListProjects: React.FC<DonateToListProjectsProps> = ({ listId }) => {
const { openDonationModal } = useDonationUserFlow({ listId });
return <Button onClick={openDonationModal}>{"Donate to Projects"}</Button>;
};
export type DonationToCampaignProps = ByCampaignId &
Pick<DonationUserFlowProps, "cachedTokenId"> & {
className?: string;
disabled: boolean;
variant?: "standard-outline";
};
export const DonateToCampaign: React.FC<DonationToCampaignProps> = ({
cachedTokenId,
campaignId,
className,
disabled,
variant,
}) => {
const { openDonationModal } = useDonationUserFlow({ campaignId, cachedTokenId });
return (
<Button
variant={variant ?? "brand-filled"}
disabled={disabled}
className={cn("w-full", className)}
onClick={(e) => {
e.stopPropagation();
openDonationModal(e);
}}
>
{"Donate"}
</Button>
);
};