Skip to content

Commit 6730b60

Browse files
committed
refactor: ⚡ tab selection and token fetching to be linter compliant
1 parent 71c4689 commit 6730b60

2 files changed

Lines changed: 18 additions & 14 deletions

File tree

Containers/UserSettings/Integrations/Integrations.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,15 @@ export default function Integrations() {
8383

8484
////LifeCycle
8585
useEffect(() => {
86-
fetchTokenList();
86+
start();
87+
fetch('/api/v1/integration/token-manager', {
88+
method: 'GET',
89+
headers: { 'Content-type': 'application/json' },
90+
})
91+
.then((res) => res.json() as Promise<Array<IntegrationTokenType>>)
92+
.then((data) => setTokenList(data))
93+
.catch(() => handleError('Fetching token list failed.'))
94+
.finally(() => stop());
8795
// eslint-disable-next-line react-hooks/exhaustive-deps
8896
}, []);
8997

Containers/UserSettings/UserSettings.tsx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,9 @@ export default function UserSettings({ data }: UserSettingsProps) {
3636
fetchWizardEnv();
3737
}, []);
3838

39-
// If Integrations tab is selected but disabled, fallback to General
40-
useEffect(() => {
41-
if (tab === 'Integrations' && wizardEnv?.DISABLE_INTEGRATIONS === 'true') {
42-
setTab('General');
43-
}
44-
// eslint-disable-next-line react-hooks/exhaustive-deps
45-
}, [wizardEnv?.DISABLE_INTEGRATIONS]);
39+
// Derive active tab: fallback to General if Integrations is disabled
40+
const activeTab =
41+
tab === 'Integrations' && wizardEnv?.DISABLE_INTEGRATIONS === 'true' ? 'General' : tab;
4642

4743
return (
4844
<div className={classes.containerSettings}>
@@ -52,14 +48,14 @@ export default function UserSettings({ data }: UserSettingsProps) {
5248
<>
5349
<div className={classes.tabList}>
5450
<button
55-
className={tab === 'General' ? classes.tabListButtonActive : classes.tabListButton}
51+
className={activeTab === 'General' ? classes.tabListButtonActive : classes.tabListButton}
5652
onClick={() => setTab('General')}
5753
>
5854
General
5955
</button>
6056
<button
6157
className={
62-
tab === 'Notifications' ? classes.tabListButtonActive : classes.tabListButton
58+
activeTab === 'Notifications' ? classes.tabListButtonActive : classes.tabListButton
6359
}
6460
onClick={() => setTab('Notifications')}
6561
>
@@ -68,7 +64,7 @@ export default function UserSettings({ data }: UserSettingsProps) {
6864
{wizardEnv.DISABLE_INTEGRATIONS !== 'true' && (
6965
<button
7066
className={
71-
tab === 'Integrations' ? classes.tabListButtonActive : classes.tabListButton
67+
activeTab === 'Integrations' ? classes.tabListButtonActive : classes.tabListButton
7268
}
7369
onClick={() => setTab('Integrations')}
7470
>
@@ -77,22 +73,22 @@ export default function UserSettings({ data }: UserSettingsProps) {
7773
)}
7874
</div>
7975

80-
{tab === 'General' && (
76+
{activeTab === 'General' && (
8177
<>
8278
<PasswordSettings />
8379
<EmailSettings email={data.user?.email ?? undefined} />
8480
<UsernameSettings username={data.user?.name ?? undefined} />
8581
</>
8682
)}
8783

88-
{tab === 'Notifications' && (
84+
{activeTab === 'Notifications' && (
8985
<>
9086
<EmailAlertSettings />
9187
<AppriseAlertSettings />
9288
</>
9389
)}
9490

95-
{tab === 'Integrations' && wizardEnv.DISABLE_INTEGRATIONS !== 'true' && <Integrations />}
91+
{activeTab === 'Integrations' && wizardEnv.DISABLE_INTEGRATIONS !== 'true' && <Integrations />}
9692
</>
9793
)}
9894
</div>

0 commit comments

Comments
 (0)