chore: heygermany customer project
This commit is contained in:
19
apps/website/hooks/backoffice/useBackOfficeLogin.ts
Normal file
19
apps/website/hooks/backoffice/useBackOfficeLogin.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { signInWithPassword } from "@/lib/auth"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import { useParams, useRouter } from "@/framework/navigation"
|
||||
|
||||
export const useBackOfficeLogin = () => {
|
||||
const router = useRouter()
|
||||
const { lang } = useParams<{ lang?: string }>()
|
||||
return useMutation({
|
||||
mutationFn: async ({ email, password }: { email: string; password: string }) => {
|
||||
return await signInWithPassword(email, password)
|
||||
},
|
||||
onSuccess: () => {
|
||||
router.replace(`/${lang || 'en'}/backoffice/candidates`)
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error('BackOffice login failed:', error)
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user