|
| 1 | +import { Badge } from "@/components/ui/badge"; |
| 2 | +import { Button } from "@/components/ui/button"; |
| 3 | +import { Card } from "@/components/ui/card"; |
1 | 4 | import { AdminOnly } from "@3rdweb-sdk/react/components/roles/admin-only"; |
2 | | -import { Flex, SimpleGrid } from "@chakra-ui/react"; |
3 | 5 | import { ChevronDownIcon, ChevronUpIcon, XIcon } from "lucide-react"; |
4 | 6 | import type { ThirdwebContract } from "thirdweb"; |
5 | | -import { Badge, Button, Card, Heading, Text } from "tw-components"; |
6 | 7 | import { ClaimConditionTypeData, useClaimConditionsFormContext } from "."; |
7 | 8 | import { PricePreview } from "../price-preview"; |
8 | 9 | import { ClaimPriceInput } from "./Inputs/ClaimPriceInput"; |
@@ -41,117 +42,114 @@ export const ClaimConditionsPhase: React.FC<ClaimConditionsPhaseProps> = ({ |
41 | 42 | }; |
42 | 43 |
|
43 | 44 | return ( |
44 | | - <Card position="relative" p={8}> |
45 | | - <Flex direction="column" gap={8}> |
46 | | - <Flex |
47 | | - align="flex-start" |
48 | | - justify="space-between" |
49 | | - position="absolute" |
50 | | - top="10px" |
51 | | - right="10px" |
52 | | - gap={1} |
| 45 | + <Card className="relative flex flex-col gap-8 p-8"> |
| 46 | + <div className="absolute top-3 right-3 flex flex-row items-start justify-between gap-1"> |
| 47 | + <Button |
| 48 | + variant="ghost" |
| 49 | + onClick={toggleEditing} |
| 50 | + size="sm" |
| 51 | + className="gap-2" |
53 | 52 | > |
| 53 | + {field.isEditing ? "Collapse" : isAdmin ? "Edit" : "See Phase"} |
| 54 | + {field.isEditing ? ( |
| 55 | + <ChevronUpIcon className="size-4" /> |
| 56 | + ) : ( |
| 57 | + <ChevronDownIcon className="size-4" /> |
| 58 | + )} |
| 59 | + </Button> |
| 60 | + <AdminOnly contract={contract}> |
54 | 61 | <Button |
55 | 62 | variant="ghost" |
56 | | - onClick={toggleEditing} |
| 63 | + onClick={onRemove} |
| 64 | + disabled={isPending} |
57 | 65 | size="sm" |
58 | | - rightIcon={ |
59 | | - field.isEditing ? ( |
60 | | - <ChevronUpIcon className="size-4" /> |
61 | | - ) : ( |
62 | | - <ChevronDownIcon className="size-4" /> |
63 | | - ) |
64 | | - } |
| 66 | + className="gap-2 text-red-300" |
65 | 67 | > |
66 | | - {field.isEditing ? "Collapse" : isAdmin ? "Edit" : "See Phase"} |
| 68 | + Remove <XIcon className="size-4" /> |
67 | 69 | </Button> |
68 | | - <AdminOnly contract={contract}> |
69 | | - <Button |
70 | | - variant="ghost" |
71 | | - onClick={onRemove} |
72 | | - isDisabled={isPending} |
73 | | - colorScheme="red" |
74 | | - size="sm" |
75 | | - rightIcon={<XIcon className="size-4" />} |
76 | | - > |
77 | | - Remove |
78 | | - </Button> |
79 | | - </AdminOnly> |
80 | | - </Flex> |
| 70 | + </AdminOnly> |
| 71 | + </div> |
81 | 72 |
|
82 | | - <Flex flexDir="column" gap={2} mt={{ base: 4, md: 0 }}> |
83 | | - <Flex gap={3} alignItems="center"> |
84 | | - <Heading>{ClaimConditionTypeData[claimConditionType].name}</Heading> |
85 | | - {isActive && ( |
86 | | - <Badge colorScheme="green" borderRadius="lg" p={1.5}> |
87 | | - Currently active |
88 | | - </Badge> |
89 | | - )} |
90 | | - </Flex> |
| 73 | + <div className="mt-4 flex flex-col gap-2 md:mt-0"> |
| 74 | + <div className="flex flex-row items-center gap-3"> |
| 75 | + <p className="font-bold text-lg text-muted-foreground"> |
| 76 | + {ClaimConditionTypeData[claimConditionType].name} |
| 77 | + </p> |
| 78 | + {isActive && ( |
| 79 | + <Badge variant="success" className="rounded-lg p-1.5"> |
| 80 | + Currently active |
| 81 | + </Badge> |
| 82 | + )} |
| 83 | + </div> |
91 | 84 |
|
92 | | - <Text>{ClaimConditionTypeData[claimConditionType].description}</Text> |
93 | | - </Flex> |
| 85 | + <p className="text-muted-foreground"> |
| 86 | + {ClaimConditionTypeData[claimConditionType].description} |
| 87 | + </p> |
| 88 | + </div> |
94 | 89 |
|
95 | | - {!field.isEditing ? ( |
96 | | - <SimpleGrid columns={{ base: 2, md: 4 }} gap={2}> |
97 | | - <div className="flex flex-col"> |
98 | | - <Text fontWeight="bold">Phase start</Text> |
99 | | - <Text>{field.startTime?.toLocaleString()}</Text> |
100 | | - </div> |
101 | | - <div className="flex flex-col"> |
102 | | - <Text fontWeight="bold"> |
103 | | - {isErc20 ? "Tokens" : "NFTs"} to drop |
104 | | - </Text> |
105 | | - <Text textTransform="capitalize">{field.maxClaimableSupply}</Text> |
106 | | - </div> |
107 | | - <PricePreview |
108 | | - price={field.price} |
109 | | - currencyAddress={field.currencyAddress} |
110 | | - contractChainId={contract.chain.id} |
111 | | - /> |
112 | | - <div className="flex flex-col"> |
113 | | - <Text fontWeight="bold">Limit per wallet</Text> |
114 | | - {claimConditionType === "specific" ? ( |
115 | | - <Text>Set in the snapshot</Text> |
116 | | - ) : claimConditionType === "creator" ? ( |
117 | | - <Text>Unlimited</Text> |
118 | | - ) : ( |
119 | | - <Text textTransform="capitalize"> |
120 | | - {field.maxClaimablePerWallet} |
121 | | - </Text> |
122 | | - )} |
123 | | - </div> |
124 | | - </SimpleGrid> |
125 | | - ) : ( |
126 | | - <> |
127 | | - <CustomFormGroup> |
128 | | - {/* Phase Name Input / Form Title */} |
129 | | - {isMultiPhase ? <PhaseNameInput /> : null} |
130 | | - <PhaseStartTimeInput /> |
131 | | - </CustomFormGroup> |
| 90 | + {!field.isEditing ? ( |
| 91 | + <div className="grid grid-cols-2 gap-2 md:grid-cols-4"> |
| 92 | + <div className="flex flex-col"> |
| 93 | + <p className="font-bold text-muted-foreground">Phase start</p> |
| 94 | + <p className="text-muted-foreground"> |
| 95 | + {field.startTime?.toLocaleString()} |
| 96 | + </p> |
| 97 | + </div> |
| 98 | + <div className="flex flex-col"> |
| 99 | + <p className="font-bold text-muted-foreground"> |
| 100 | + {isErc20 ? "Tokens" : "NFTs"} to drop |
| 101 | + </p> |
| 102 | + <p className="text-muted-foreground capitalize"> |
| 103 | + {field.maxClaimableSupply} |
| 104 | + </p> |
| 105 | + </div> |
| 106 | + <PricePreview |
| 107 | + price={field.price} |
| 108 | + currencyAddress={field.currencyAddress} |
| 109 | + contractChainId={contract.chain.id} |
| 110 | + /> |
| 111 | + <div className="flex flex-col"> |
| 112 | + <p className="font-bold text-muted-foreground">Limit per wallet</p> |
| 113 | + {claimConditionType === "specific" ? ( |
| 114 | + <p>Set in the snapshot</p> |
| 115 | + ) : claimConditionType === "creator" ? ( |
| 116 | + <p>Unlimited</p> |
| 117 | + ) : ( |
| 118 | + <p className="text-muted-foreground capitalize"> |
| 119 | + {field.maxClaimablePerWallet} |
| 120 | + </p> |
| 121 | + )} |
| 122 | + </div> |
| 123 | + </div> |
| 124 | + ) : ( |
| 125 | + <> |
| 126 | + <CustomFormGroup> |
| 127 | + {/* Phase Name Input / Form Title */} |
| 128 | + {isMultiPhase ? <PhaseNameInput /> : null} |
| 129 | + <PhaseStartTimeInput /> |
| 130 | + </CustomFormGroup> |
132 | 131 |
|
133 | | - <CreatorInput |
134 | | - creatorAddress={ |
135 | | - (field.snapshot?.[0] as { address: string })?.address |
136 | | - } |
137 | | - /> |
| 132 | + <CreatorInput |
| 133 | + creatorAddress={ |
| 134 | + (field.snapshot?.[0] as { address: string })?.address |
| 135 | + } |
| 136 | + /> |
| 137 | + |
| 138 | + <CustomFormGroup> |
| 139 | + <MaxClaimableSupplyInput /> |
| 140 | + <ClaimPriceInput contractChainId={contract.chain.id} /> |
| 141 | + </CustomFormGroup> |
138 | 142 |
|
| 143 | + {claimConditionType === "specific" || |
| 144 | + claimConditionType === "creator" ? null : ( |
139 | 145 | <CustomFormGroup> |
140 | | - <MaxClaimableSupplyInput /> |
141 | | - <ClaimPriceInput contractChainId={contract.chain.id} /> |
| 146 | + <MaxClaimablePerWalletInput /> |
142 | 147 | </CustomFormGroup> |
| 148 | + )} |
143 | 149 |
|
144 | | - {claimConditionType === "specific" || |
145 | | - claimConditionType === "creator" ? null : ( |
146 | | - <CustomFormGroup> |
147 | | - <MaxClaimablePerWalletInput /> |
148 | | - </CustomFormGroup> |
149 | | - )} |
150 | | - |
151 | | - <ClaimerSelection /> |
152 | | - </> |
153 | | - )} |
154 | | - </Flex> |
| 150 | + <ClaimerSelection /> |
| 151 | + </> |
| 152 | + )} |
155 | 153 | </Card> |
156 | 154 | ); |
157 | 155 | }; |
0 commit comments