fix: refactor drizzle integration to use optional chaining for DATABASE_URL fix: update Supabase integration to use getCookies instead of parseCookies feat: implement user profile creation with validation schema refactor: remove unused user-related functions and adjust signup logic fix: update user validation schema to include first and last name chore: enhance route tree with SSR support for router refactor: rename createRouter to getRouter for clarity fix: update RootDocument styles for background gradient refactor: clean up _authed routes by removing unused queries fix: adjust register form layout for better readability chore: simplify Vite configuration by removing unnecessary options
39 lines
905 B
TypeScript
39 lines
905 B
TypeScript
import { useMutation } from "@tanstack/react-query"
|
|
import { toast } from "sonner"
|
|
import type z from "zod"
|
|
import { profileFormSchema } from "@/lib/validation/user"
|
|
import { useValidation } from "../useValidation"
|
|
|
|
type TProfileForm = z.infer<typeof profileFormSchema>
|
|
|
|
export const useProfile = () => {
|
|
const { validate, errors } = useValidation({
|
|
defaultSchema: profileFormSchema
|
|
})
|
|
const signup = useMutation({
|
|
mutationKey: ["create-profile"],
|
|
mutationFn: async (data: TProfileForm) => {},
|
|
onSuccess: () => {
|
|
toast.success("Your profile is created..", {
|
|
id: "create-profile"
|
|
})
|
|
}
|
|
})
|
|
|
|
const validateSignup = (formData: TProfileForm) => {
|
|
const isValid = validate({ formData })
|
|
if (!isValid) {
|
|
toast.error("Don't create", {
|
|
id: "create-profile"
|
|
})
|
|
}
|
|
signup.mutate(formData)
|
|
}
|
|
|
|
return {
|
|
profile: validateSignup,
|
|
errors,
|
|
isPending: signup.isPending
|
|
}
|
|
}
|