-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add endpoints and queries for company doc signing
- Loading branch information
1 parent
78799c9
commit ac24f9a
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useMutation, useSuspenseQuery } from '@tanstack/react-query' | ||
import { queryClient, useGustoApi } from '@/api/context' | ||
|
||
export function useGetAllCompanyForms(company_id: string) { | ||
const { GustoClient: client } = useGustoApi() | ||
return useSuspenseQuery({ | ||
queryKey: ['companies', company_id, 'forms'], | ||
queryFn: () => client.getAllCompanyForms(company_id), | ||
}) | ||
} | ||
|
||
export function useGetCompanyFormPdf(form_id: string) { | ||
const { GustoClient: client } = useGustoApi() | ||
return useSuspenseQuery({ | ||
queryKey: ['companies', 'forms', form_id, 'pdf'], | ||
queryFn: () => client.getCompanyFormPdf(form_id), | ||
}) | ||
} | ||
|
||
export function useSignCompanyForm( | ||
company_id: string, | ||
opts?: Omit<Parameters<typeof useMutation>[0], 'mutationFn'>, | ||
) { | ||
const { GustoClient: client } = useGustoApi() | ||
const onSettled = async (data: unknown, error: unknown, variables: unknown, context: unknown) => { | ||
if (opts?.onSettled) opts.onSettled(data, error, variables, context) | ||
await queryClient.invalidateQueries({ | ||
queryKey: ['companies', company_id, 'forms'], | ||
}) | ||
} | ||
|
||
return useMutation({ | ||
mutationFn: ({ | ||
form_id, | ||
body, | ||
}: { | ||
form_id: string | ||
body: Parameters<typeof client.signCompanyForm>[1] | ||
}) => client.signCompanyForm(form_id, body), | ||
...opts, | ||
onSettled, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './company' | ||
export * from './employee' | ||
export * from './payroll' | ||
export * from './companyForms' |