fix: update user profile

This commit is contained in:
Stephen Zhou 2024-12-13 09:32:01 +08:00
parent fb08ee964d
commit aeaf79522b
No known key found for this signature in database
2 changed files with 8 additions and 5 deletions

View File

@ -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"
@ -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({
@ -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)

View File

@ -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"