Skip to content

Commit

Permalink
fix: update user profile
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Dec 13, 2024
1 parent fb08ee9 commit aeaf795
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions apps/renderer/src/modules/profile/profile-setting-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
FormMessage,
} from "@follow/components/ui/form/index.jsx"
import { Input } from "@follow/components/ui/input/index.js"
import { updateUser } from "@follow/shared/auth"
import { cn } from "@follow/utils/utils"
import { zodResolver } from "@hookform/resolvers/zod"
import { useMutation } from "@tanstack/react-query"
Expand All @@ -19,7 +20,6 @@ import { toast } from "sonner"
import { z } from "zod"

import { setWhoami, useWhoami } from "~/atoms/user"
import { apiClient } from "~/lib/api-fetch"
import { toastFetchError } from "~/lib/error-parser"

const formSchema = z.object({
Expand Down Expand Up @@ -48,9 +48,12 @@ export const ProfileSettingForm = ({
})

const updateMutation = useMutation({
mutationFn: async (values: z.infer<typeof formSchema>) =>
apiClient["auth-app"]["update-account"].$patch({
json: values,
mutationFn: (values: z.infer<typeof formSchema>) =>
updateUser({
// @ts-expect-error
handle: values.handle,
image: values.image,
name: values.name,
}),
onError: (error) => {
toastFetchError(error)
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const authClient = createAuthClient({
plugins: serverPlugins,
})

export const { signIn, signOut, getSession, getProviders, createSession } = authClient
export const { signIn, signOut, getSession, getProviders, createSession, updateUser } = authClient

export const LOGIN_CALLBACK_URL = `${WEB_URL}/login`
export type LoginRuntime = "browser" | "app"
Expand Down

0 comments on commit aeaf795

Please sign in to comment.