Skip to content

Commit

Permalink
feat: handle no notification settings found / fix ybx updates checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
chambaz committed Mar 7, 2024
1 parent 5ba77eb commit 276b605
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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 (
<Accordion type="single" collapsible className="w-full space-y-4 mb-6">
Expand Down
4 changes: 4 additions & 0 deletions apps/marginfi-v2-ui/src/pages/api/user/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 276b605

Please sign in to comment.