Skip to content

Commit

Permalink
Fix & Refactor UI/UX Page [Settings] (ChatGPTNextWeb#162)
Browse files Browse the repository at this point in the history
- [+] fix(settings.tsx): fix conditional rendering of ListItem based on clientConfig.isApp
- [+] refactor(settings.tsx): improve readability of conditional rendering code
  • Loading branch information
H0llyW00dzZ authored Nov 27, 2023
1 parent a8491b9 commit 20fba13
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions app/components/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1276,21 +1276,26 @@ export function Settings() {

{!accessStore.hideUserApiKey && (
<>
<ListItem
title={Locale.Settings.Access.CustomEndpoint.Title}
subTitle={Locale.Settings.Access.CustomEndpoint.SubTitle}
>
<input
type="checkbox"
checked={accessStore.useCustomConfig}
onChange={(e) =>
accessStore.update(
(access) =>
(access.useCustomConfig = e.currentTarget.checked),
)
}
></input>
</ListItem>
{
// Conditionally render the following ListItem based on clientConfig.isApp
!clientConfig?.isApp && ( // only show if isApp is false
<ListItem
title={Locale.Settings.Access.CustomEndpoint.Title}
subTitle={Locale.Settings.Access.CustomEndpoint.SubTitle}
>
<input
type="checkbox"
checked={accessStore.useCustomConfig}
onChange={(e) =>
accessStore.update(
(access) =>
(access.useCustomConfig = e.currentTarget.checked),
)
}
></input>
</ListItem>
)
}
{accessStore.useCustomConfig && (
<>
<ListItem
Expand Down

0 comments on commit 20fba13

Please sign in to comment.