From 276b60530086cdf53578d6b550ac76ca0a5e3b75 Mon Sep 17 00:00:00 2001 From: chambaz Date: Wed, 6 Mar 2024 21:08:53 -0500 Subject: [PATCH] feat: handle no notification settings found / fix ybx updates checkbox --- .../src/components/common/Wallet/WalletSettings.tsx | 6 +++--- apps/marginfi-v2-ui/src/pages/api/user/notifications.ts | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/marginfi-v2-ui/src/components/common/Wallet/WalletSettings.tsx b/apps/marginfi-v2-ui/src/components/common/Wallet/WalletSettings.tsx index c8ab5ef165..77eaa6b400 100644 --- a/apps/marginfi-v2-ui/src/components/common/Wallet/WalletSettings.tsx +++ b/apps/marginfi-v2-ui/src/components/common/Wallet/WalletSettings.tsx @@ -107,7 +107,7 @@ export const WalletSettings = ({ walletAddress, tokens }: WalletSettingsProps) = if (!res.ok) { // document not found which means notifications have not been set - const { success } = await res.json(); + const { success, message } = await res.json(); if (success) { return; } @@ -121,13 +121,13 @@ export const WalletSettings = ({ walletAddress, tokens }: WalletSettingsProps) = setEmail(data.email); setNotificationSettings({ health: data.account_health, - ybx: data.product_updates, + ybx: data.ybx_updates, }); }, [walletAddress]); React.useEffect(() => { fetchUsersNotificationSettings(); - }, []); + }, [fetchUsersNotificationSettings]); return ( diff --git a/apps/marginfi-v2-ui/src/pages/api/user/notifications.ts b/apps/marginfi-v2-ui/src/pages/api/user/notifications.ts index 106f1d9e28..a841a813f1 100644 --- a/apps/marginfi-v2-ui/src/pages/api/user/notifications.ts +++ b/apps/marginfi-v2-ui/src/pages/api/user/notifications.ts @@ -61,6 +61,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) const data = await response.json(); return res.status(200).json({ success: true, data }); } else { + if (response.status === 404) { + return res.status(200).json({ success: true, data: {} }); + } + const errorData = await response.json(); console.error("Error fetching notifications settings via API:", errorData); return res