Skip to content

Commit

Permalink
hotfix handle null value
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin-Umali committed Jul 14, 2024
1 parent b2a82e5 commit e181f80
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
6 changes: 1 addition & 5 deletions client/api/queries.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useMutation, useQuery } from "@tanstack/react-query";

import { getAccountSettings, saveAccountSettings } from "./account";
import { loginUser, logoutUser, refreshToken, registerUser } from "./auth";
Expand Down Expand Up @@ -137,11 +137,7 @@ export const useAccountSettings = (accessToken: string) => {
};

export const useSaveAccountSettings = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: saveAccountSettings,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ["account"] });
},
});
};
11 changes: 5 additions & 6 deletions client/app/(account)/(routes)/settings/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ const Settings = () => {
useEffect(() => {
if (accountSettings) {
methods.reset({
username: accountSettings?.data.username,
email: accountSettings?.data.profile.email,
fullName: accountSettings?.data.profile.fullName,
newsletter: accountSettings?.data.notifications.isNewsletterEnabled,
updates: accountSettings?.data.notifications.isUpdatesEnabled,
username: accountSettings?.data?.username ?? "",
email: accountSettings?.data?.profile?.email ?? "",
fullName: accountSettings?.data?.profile?.fullName ?? "",
newsletter: accountSettings?.data?.notifications?.isNewsletterEnabled ?? false,
updates: accountSettings?.data?.notifications?.isUpdatesEnabled ?? false,
});
setInitialUsername(accountSettings?.data.username);
}
Expand All @@ -82,7 +82,6 @@ const Settings = () => {
},
{
onSuccess: () => {
console.log(data.username, initialUsername);
if (data.username !== initialUsername) {
toast.info("Settings saved successfully! Logging out in 3 seconds...");
setTimeout(() => {
Expand Down

1 comment on commit e181f80

@vercel
Copy link

@vercel vercel bot commented on e181f80 Jul 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.