Skip to content

Commit c4430e7

Browse files
committed
feat(allowlist): support pre-populating allowlist entries
Add support for initializing the create allowlist dialog with existing entries, enabling editing of allowlists in blueprints
1 parent b9584f1 commit c4430e7

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

components/allowlist/create-allowlist-dialog.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,22 @@ type AllowListItem = {
2626
percentage?: string;
2727
};
2828

29+
const defaultValues = [
30+
{
31+
address: "",
32+
percentage: "",
33+
},
34+
];
35+
2936
export default function Component({
3037
setAllowlistEntries,
3138
setOpen,
3239
open,
40+
initialValues,
3341
}: {
3442
setAllowlistEntries: (allowlistEntries: AllowlistEntry[]) => void;
3543
setOpen: (open: boolean) => void;
44+
initialValues?: AllowListItem[];
3645
open: boolean;
3746
}) {
3847
const {
@@ -42,12 +51,9 @@ export default function Component({
4251
error: createAllowListError,
4352
reset,
4453
} = useValidateAllowlist();
45-
const [allowList, setAllowList] = useState<AllowListItem[]>([
46-
{
47-
address: "",
48-
percentage: "",
49-
},
50-
]);
54+
const [allowList, setAllowList] = useState<AllowListItem[]>(
55+
initialValues?.length ? initialValues : defaultValues,
56+
);
5157

5258
useEffect(() => {
5359
if (validateAllowlistResponse?.success) {

components/hypercert/hypercert-minting-form/form-steps.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,12 @@ const AdvancedAndSubmit = ({ form, isBlueprint }: FormStepsProps) => {
509509
setAllowlistEntries={setAllowlistEntries}
510510
open={createDialogOpen}
511511
setOpen={setCreateDialogOpen}
512+
initialValues={allowlistEntries?.map((entry) => ({
513+
address: entry.address,
514+
percentage: calculatePercentageBigInt(
515+
entry.units,
516+
).toString(),
517+
}))}
512518
/>
513519
</div>
514520
{!!allowlistEntries?.length && (

0 commit comments

Comments
 (0)