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)
|
||||
}
|
||||
})
|
||||
}
|
||||
10
apps/website/hooks/company/useGetCompanyCandidate.ts
Normal file
10
apps/website/hooks/company/useGetCompanyCandidate.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { pikku } from "@/pikku/http"
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
|
||||
export const useGetCompanyCandidate = (candidateId: string) => {
|
||||
return useQuery({
|
||||
queryKey: ['company', 'candidate', candidateId],
|
||||
queryFn: async () => await pikku().get('/company/candidate/:candidateId', { candidateId }),
|
||||
enabled: !!candidateId
|
||||
})
|
||||
}
|
||||
9
apps/website/hooks/company/useGetCompanyCandidates.ts
Normal file
9
apps/website/hooks/company/useGetCompanyCandidates.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { pikku } from "@/pikku/http"
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
|
||||
export const useGetCompanyCandidates = () => {
|
||||
return useQuery({
|
||||
queryKey: ['company', 'candidates'],
|
||||
queryFn: async () => await pikku().get('/company/candidate', {})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user