21 lines
676 B
TypeScript
21 lines
676 B
TypeScript
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)
|
|
}
|
|
})
|
|
}
|