@kanda-libs/ks-component-ts 0.3.51 → 0.3.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ import { useToast } from "@kanda-libs/ks-design-library";
2
2
  import { services, useSubmit } from "@kanda-libs/ks-frontend-services";
3
3
  import { useCallback } from "react";
4
4
  import { downloadBase64 } from "../../helpers";
5
+ import { GetDocumentRequestFunction } from "~/generated/operations/getDocument";
5
6
 
6
7
  export interface DownloadDocumentHook {
7
8
  downloadDocument: (id: string) => void;
@@ -9,9 +10,15 @@ export interface DownloadDocumentHook {
9
10
  }
10
11
 
11
12
  export default function useDownloadDocument(): DownloadDocumentHook {
12
- const { submit: getDocument, isSubmitting = false } = useSubmit(
13
- services.document.getDocument
14
- );
13
+ const service = {
14
+ key: services.document.getDocument.key,
15
+ method: (
16
+ services.document.getDocument
17
+ .method as unknown as () => GetDocumentRequestFunction
18
+ )(),
19
+ };
20
+
21
+ const { submit: getDocument, isSubmitting = false } = useSubmit(service);
15
22
 
16
23
  const { showError } = useToast();
17
24
 
@@ -8,6 +8,9 @@ import {
8
8
  import { useCallback, useState } from "react";
9
9
  import { isJobCustom } from "./helpers";
10
10
  import { downloadBase64 } from "../../helpers";
11
+ import { GetJobRequestFunction } from "~/generated/operations/getJob";
12
+ import { GetDocumentRequestFunction } from "~/generated/operations/getDocument";
13
+ import { JobCompanyInfoRequestFunction } from "~/generated/operations/jobCompanyInfo";
11
14
 
12
15
  export interface DownloadPdfHook {
13
16
  downloadPdf: (id: string) => void;
@@ -15,9 +18,26 @@ export interface DownloadPdfHook {
15
18
  }
16
19
 
17
20
  export default function useDownloadPdf(): DownloadPdfHook {
18
- const { submit: getJob } = useSubmit(services.job.getJob);
19
- const { submit: getDocument } = useSubmit(services.document.getDocument);
20
- const { submit: jobCompanyInfo } = useSubmit(services.job.jobCompanyInfo);
21
+ const { submit: getJob } = useSubmit({
22
+ key: services.job.getJob.key,
23
+ method: (
24
+ services.job.getJob.method as unknown as () => GetJobRequestFunction
25
+ )(),
26
+ });
27
+ const { submit: getDocument } = useSubmit({
28
+ key: services.document.getDocument.key,
29
+ method: (
30
+ services.document.getDocument
31
+ .method as unknown as () => GetDocumentRequestFunction
32
+ )(),
33
+ });
34
+ const { submit: jobCompanyInfo } = useSubmit({
35
+ key: services.job.jobCompanyInfo.key,
36
+ method: (
37
+ services.job.jobCompanyInfo
38
+ .method as unknown as () => JobCompanyInfoRequestFunction
39
+ )(),
40
+ });
21
41
 
22
42
  const { showError } = useToast();
23
43
  const { createPdf } = useQuoteDownload();
@@ -25,7 +45,7 @@ export default function useDownloadPdf(): DownloadPdfHook {
25
45
  const [isSubmitting, setIsSubmitting] = useState(false);
26
46
 
27
47
  const customDownload = useCallback(
28
- (job: Job) => {
48
+ (job) => {
29
49
  const id = job?.job_items[0]?.quote_document?.id;
30
50
  if (!id) {
31
51
  setIsSubmitting(false);