reformatting, improve name/docs

This commit is contained in:
2024-05-09 21:45:46 -05:00
parent cb798c4ec1
commit c1dbc78c3f

View File

@@ -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<ObjectType>;
};
@@ -54,7 +57,10 @@ const LookupInput: FunctionComponent<LookupInputProps> = ({
},
});
const options: Record<ObjectType | "auto", string> = {
/**
* Mapping of object types to their corresponding display names.
*/
const objectNames: Record<ObjectType | "auto", string> = {
auto: "Autodetect",
domain: "Domain",
ip: "IP/CIDR",
@@ -66,7 +72,6 @@ const LookupInput: FunctionComponent<LookupInputProps> = ({
json: "JSON",
};
/**
* Represents the selected value in the LookupInput component.
*/
@@ -154,7 +159,9 @@ const LookupInput: FunctionComponent<LookupInputProps> = ({
>
{/* Fetch special text for 'auto' mode, otherwise just use the options. */}
<span className="block">
{selected == "auto" ? detectedType.unwrapOr("???") : options[selected]}
{selected == "auto"
? detectedType.unwrapOr("???")
: objectNames[selected]}
</span>
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
<ChevronUpDownIcon
@@ -175,7 +182,7 @@ const LookupInput: FunctionComponent<LookupInputProps> = ({
"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]) => (
<Listbox.Option
key={key}
className={({ active }) =>