chore: heygermany customer project
This commit is contained in:
20
apps/website/hooks/company/useCompanyLogin.ts
Normal file
20
apps/website/hooks/company/useCompanyLogin.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { signInWithPassword } from "@/lib/auth"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import { useNavigate, useParams } from "@tanstack/react-router"
|
||||
|
||||
export const useCompanyLogin = () => {
|
||||
const navigate = useNavigate()
|
||||
const { lang } = useParams({ strict: false }) as { lang?: string }
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async ({ email, password }: { email: string; password: string }) => {
|
||||
return await signInWithPassword(email, password)
|
||||
},
|
||||
onSuccess: () => {
|
||||
navigate({ to: `/${lang || 'en'}/company/candidates`, replace: true })
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error('Company login failed:', error)
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user