From 85d1b4629555ab97015a3723b7b7b9b0e0c4427f Mon Sep 17 00:00:00 2001 From: Curetix Date: Sun, 19 Nov 2023 11:37:46 +0100 Subject: [PATCH] Add button to save alias settings Allows to persist the settings without having to create an alias --- src/components/AliasCreateModal.tsx | 40 +++++++++++++++++++---------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/src/components/AliasCreateModal.tsx b/src/components/AliasCreateModal.tsx index e5ec9c0..dca3f34 100644 --- a/src/components/AliasCreateModal.tsx +++ b/src/components/AliasCreateModal.tsx @@ -109,6 +109,23 @@ export default function AliasCreateModal({ opened, onClose }: Props) { resetForm(); }, [aliasSettings, selectedZoneId, hostname]); + function saveAliasSettings() { + const { values } = aliasCreateForm; + return setAliasSettings({ + format: values.format as "characters" | "words" | "custom", + characterCount: values.characterCount, + wordCount: values.wordCount, + separator: values.separator, + prefixFormat: values.prefixFormat as + | "none" + | "custom" + | "domainWithoutExtension" + | "domainWithExtension" + | "fullDomain", + destination: values.destination, + }); + } + async function createAlias(variables: typeof aliasCreateForm.values) { const zone = zones.data?.find((z) => z.id === variables.zoneId); @@ -194,19 +211,7 @@ export default function AliasCreateModal({ opened, onClose }: Props) { onSuccess: (data) => { resetForm(); setSelectedZoneId(variables.zoneId); - setAliasSettings({ - format: variables.format as "characters" | "words" | "custom", - characterCount: variables.characterCount, - wordCount: variables.wordCount, - separator: variables.separator, - prefixFormat: variables.prefixFormat as - | "none" - | "custom" - | "domainWithoutExtension" - | "domainWithExtension" - | "fullDomain", - destination: variables.destination, - }); + saveAliasSettings(); if (copyAlias) { clipboard.copy(data.matchers[0].value); } @@ -388,9 +393,16 @@ export default function AliasCreateModal({ opened, onClose }: Props) { + +