Skip to content

Commit

Permalink
update default setting to values
Browse files Browse the repository at this point in the history
  • Loading branch information
AlyssaWang committed Jan 10, 2025
1 parent 2dcd70d commit 96349b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions client/src/components/InputsModal/InputAccess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ const InputAccess: FC<InputAccessProps> = ({ input, index, inputsMap, setInputsM
const [accessValuesPopulated, setAccessValuesPopulated] = React.useState<boolean>(false);

// Default auth type settings
const authComponentDefault = input.options?.components?.find(
const authComponent = 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]
authComponent?.options?.list_options && authComponent?.options?.list_options?.length > 0
? authComponent?.options?.list_options[0].value
: undefined;

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

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

// Default auth type settings
const authComponentDefault = input.options?.components?.find(
const authComponent = 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]
authComponent?.options?.list_options && authComponent?.options?.list_options?.length > 0
? authComponent?.options?.list_options[0].value
: undefined;

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

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

0 comments on commit 96349b7

Please sign in to comment.