From c1dbc78c3f26c94421b09b371439cafc591c7f89 Mon Sep 17 00:00:00 2001 From: Xevion Date: Thu, 9 May 2024 21:45:46 -0500 Subject: [PATCH] reformatting, improve name/docs --- src/components/form/LookupInput.tsx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/components/form/LookupInput.tsx b/src/components/form/LookupInput.tsx index 521bfa8..a2096ee 100644 --- a/src/components/form/LookupInput.tsx +++ b/src/components/form/LookupInput.tsx @@ -36,7 +36,10 @@ type LookupInputProps = { * @param target - The target object containing the search target and target type. * @returns Nothing. */ - onChange?: (target: { target: string; targetType: ObjectType | null }) => void; + onChange?: (target: { + target: string; + targetType: ObjectType | null; + }) => void; detectedType: Maybe; }; @@ -54,7 +57,10 @@ const LookupInput: FunctionComponent = ({ }, }); - const options: Record = { + /** + * Mapping of object types to their corresponding display names. + */ + const objectNames: Record = { auto: "Autodetect", domain: "Domain", ip: "IP/CIDR", @@ -66,7 +72,6 @@ const LookupInput: FunctionComponent = ({ json: "JSON", }; - /** * Represents the selected value in the LookupInput component. */ @@ -82,7 +87,7 @@ const LookupInput: FunctionComponent = ({ if (value == null) value = selected; // 'auto' means 'do whatever' so we return null. - if (value == "auto" ) return null; + if (value == "auto") return null; return value as ObjectType; } @@ -154,7 +159,9 @@ const LookupInput: FunctionComponent = ({ > {/* Fetch special text for 'auto' mode, otherwise just use the options. */} - {selected == "auto" ? detectedType.unwrapOr("???") : options[selected]} + {selected == "auto" + ? detectedType.unwrapOr("???") + : objectNames[selected]} = ({ "text-zinc-200 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm" )} > - {Object.entries(options).map(([key, value]) => ( + {Object.entries(objectNames).map(([key, value]) => (