Skip to content

Commit e17ae27

Browse files
author
Pablo Mendez
committed
fix swr render when data is false
1 parent 445b858 commit e17ae27

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/admin-ui/src/components/SwrRender.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export function renderResponse<T>(
88
loadingMessages: string[],
99
onData: (data: T) => React.ReactElement
1010
): React.ReactElement | null {
11-
if (res.data) return onData(res.data);
11+
// res.data might be false, so we check if it exists or is not undefined
12+
if (res.data || res.data !== undefined) return onData(res.data);
1213
if (res.error) return <ErrorView error={res.error} />;
1314
if (res.isValidating) return <Loading steps={loadingMessages} />;
1415
return null;

packages/admin-ui/src/pages/notifications/NotificationsRoot.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ import { NotificationsSettings } from "./tabs/Settings/Settings";
1212
import { LegacyNotifications } from "./tabs/Legacy";
1313

1414
export const NotificationsRoot: React.FC = () => {
15-
const dnpsRequest = useApi.packagesGet();
16-
return renderResponse(dnpsRequest, ["Loading notifications"], () => {
17-
const isNotificationsPkgInstalled = useApi.notificationsIsInstalled();
15+
const isNotificationsPkgInstalledRequest = useApi.notificationsIsInstalled();
1816

17+
return renderResponse(isNotificationsPkgInstalledRequest, ["Loading notifications"], (isInstalled) => {
1918
const availableRoutes: {
2019
name: string;
2120
subPath: string;
@@ -24,12 +23,12 @@ export const NotificationsRoot: React.FC = () => {
2423
{
2524
name: "Inbox",
2625
subPath: subPaths.inbox,
27-
component: isNotificationsPkgInstalled.data ? Inbox : () => <InstallNotificationsPkg />
26+
component: isInstalled ? Inbox : () => <InstallNotificationsPkg />
2827
},
2928
{
3029
name: "Settings",
3130
subPath: subPaths.settings,
32-
component: isNotificationsPkgInstalled.data ? NotificationsSettings : () => <InstallNotificationsPkg />
31+
component: isInstalled ? NotificationsSettings : () => <InstallNotificationsPkg />
3332
},
3433
{
3534
name: "Legacy",

0 commit comments

Comments
 (0)