Skip to content

Commit ad475c4

Browse files
committed
chore(dashboard): fix conditional hooks
1 parent e9a7252 commit ad475c4

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

packages/apps/app-dashboard/src/components/user-dashboard/dashboard/RepermitConnectPageWrapper.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ export function RepermitConnectPageWrapper() {
3030
error: appError,
3131
} = vincentApiClient.useGetAppQuery({ appId: Number(appId) }, { skip: !appId });
3232

33-
// Early return if required params are missing
34-
if (!appId) {
35-
return <GeneralErrorScreen errorDetails="App ID was not provided" />;
36-
}
37-
3833
const isUserAuthed = authInfo?.userPKP && sessionSigs;
3934

4035
// Check if we have finished loading but got no data (invalid appId)
@@ -49,12 +44,17 @@ export function RepermitConnectPageWrapper() {
4944

5045
// Redirect if app is already permitted
5146
useEffect(() => {
52-
if (isAllDataLoaded && permittedVersion !== null) {
47+
if (isAllDataLoaded && permittedVersion !== null && appId) {
5348
// App is already permitted, redirect to normal manage page
5449
navigate(`/user/appId/${appId}`, { replace: true });
5550
}
5651
}, [isAllDataLoaded, permittedVersion, appId, navigate]);
5752

53+
// Early return if required params are missing
54+
if (!appId) {
55+
return <GeneralErrorScreen errorDetails="App ID was not provided" />;
56+
}
57+
5858
// Authentication check - must be done before other business logic
5959
if (!isProcessing && !isUserAuthed) {
6060
return (

packages/apps/app-dashboard/src/components/user-dashboard/dashboard/UpdateVersionPageWrapper.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ export function UpdateVersionPageWrapper() {
4444
authorizedRedirectUris: data?.app?.redirectUris,
4545
});
4646

47-
// Early return if required params are missing
48-
if (!appId) {
49-
return <GeneralErrorScreen errorDetails="App ID was not provided" />;
50-
}
51-
5247
// Wait for ALL critical data to load before making routing decisions
5348
const isUserAuthed = authInfo?.userPKP && sessionSigs;
5449

@@ -68,7 +63,8 @@ export function UpdateVersionPageWrapper() {
6863
isAllDataLoaded &&
6964
data?.app &&
7065
permittedVersion !== null &&
71-
permittedVersion !== undefined
66+
permittedVersion !== undefined &&
67+
appId
7268
) {
7369
const activeVersion = data.app.activeVersion?.toString();
7470
const permitted = permittedVersion.toString();
@@ -80,6 +76,11 @@ export function UpdateVersionPageWrapper() {
8076
}
8177
}, [isAllDataLoaded, data, permittedVersion, appId, navigate]);
8278

79+
// Early return if required params are missing
80+
if (!appId) {
81+
return <GeneralErrorScreen errorDetails="App ID was not provided" />;
82+
}
83+
8384
// Authentication check - must be done before other business logic
8485
if (!isProcessing && !isUserAuthed) {
8586
return (

0 commit comments

Comments
 (0)