Skip to content

Commit 5e73039

Browse files
committed
feat: improve allowlist creation dialog
change intended to allow user to edit allowlist on dialog if user uploaded via url. if user updated allowlist, then delete original url to avoid confliction in a minting process
1 parent e928240 commit 5e73039

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

components/allowlist/create-allowlist-dialog.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@ const defaultValues = [
3535

3636
export default function Component({
3737
setAllowlistEntries,
38+
setAllowlistURL,
39+
allowlistURL,
3840
setOpen,
3941
open,
4042
initialValues,
4143
}: {
4244
setAllowlistEntries: (allowlistEntries: AllowlistEntry[]) => void;
45+
setAllowlistURL: (allowlistURL: string) => void;
46+
allowlistURL: string | undefined;
4347
setOpen: (open: boolean) => void;
4448
initialValues?: AllowListItem[];
4549
open: boolean;
@@ -55,6 +59,16 @@ export default function Component({
5559
initialValues?.length ? initialValues : defaultValues,
5660
);
5761

62+
useEffect(() => {
63+
if (open && !allowList[0].address && !allowList[0].percentage) {
64+
if (initialValues && initialValues.length > 0) {
65+
setAllowList(initialValues);
66+
} else {
67+
setAllowList(defaultValues);
68+
}
69+
}
70+
}, [open]);
71+
5872
useEffect(() => {
5973
if (validateAllowlistResponse?.success) {
6074
(async () => {
@@ -141,6 +155,7 @@ export default function Component({
141155
throw new Error("Allow list is empty");
142156
}
143157
validateAllowlist({ allowList: parsedAllowList, totalUnits });
158+
setAllowlistURL("");
144159
} catch (e) {
145160
if (errorHasMessage(e)) {
146161
toast({
@@ -264,6 +279,12 @@ export default function Component({
264279
</Button>
265280
</div>
266281
</div>
282+
{allowlistURL && (
283+
<p className="text-sm text-red-600">
284+
If you edit an original allowlist imported via URL, the original
285+
allowlist will be deleted.
286+
</p>
287+
)}
267288
<CreateAllowListErrorMessage />
268289
<div className="flex gap-2 justify-evenly w-full">
269290
<Button

0 commit comments

Comments
 (0)