Skip to content

Commit

Permalink
add check for list item options
Browse files Browse the repository at this point in the history
  • Loading branch information
AlyssaWang committed Jan 10, 2025
1 parent 53f16b2 commit 2dcd70d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions client/src/components/InputsModal/InputAccess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ const InputAccess: FC<InputAccessProps> = ({ input, index, inputsMap, setInputsM
const [accessValuesPopulated, setAccessValuesPopulated] = React.useState<boolean>(false);

// Default auth type settings
const authComponent = input.options?.components?.find(
const authComponentDefault = input.options?.components?.find(
(component) => component.name === 'auth_type',
);
)?.default;

const firstListOption =
input.options?.list_options && input.options?.list_options?.length > 0
? input.options?.list_options[0]
: undefined;

const [authType, setAuthType] = React.useState<string>(
authComponent?.default ? (authComponent.default as string) : 'public',
(authComponentDefault || firstListOption || 'public') as string,
);

const [accessFields, setAccessFields] = React.useState<TestInput[]>(
Expand Down
12 changes: 9 additions & 3 deletions client/src/components/InputsModal/InputAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@ const InputAuth: FC<InputAuthProps> = ({ input, index, inputsMap, setInputsMap }
const [authValuesPopulated, setAuthValuesPopulated] = React.useState<boolean>(false);

// Default auth type settings
const authComponent = input.options?.components?.find(
const authComponentDefault = input.options?.components?.find(
(component) => component.name === 'auth_type',
);
)?.default;

const firstListOption =
input.options?.list_options && input.options?.list_options?.length > 0
? input.options?.list_options[0]
: undefined;

const [authType, setAuthType] = React.useState<string>(
authComponent?.default ? (authComponent.default as string) : 'public',
(authComponentDefault || firstListOption || 'public') as string,
);

const [authFields, setAuthFields] = React.useState<TestInput[]>(
Expand Down

0 comments on commit 2dcd70d

Please sign in to comment.