warqadui 0.0.301 → 0.0.302
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.
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +14 -11
- package/dist/index.mjs +14 -11
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -911,6 +911,7 @@ interface FetchProps {
|
|
|
911
911
|
}) => void;
|
|
912
912
|
};
|
|
913
913
|
multipart?: boolean;
|
|
914
|
+
headers?: Record<string, any>;
|
|
914
915
|
}
|
|
915
916
|
type FetchFunction = (props: Omit<FetchProps, "body">) => Promise<any>;
|
|
916
917
|
type PostFunction = (props: FetchProps) => Promise<any>;
|
|
@@ -925,7 +926,7 @@ declare const useApi: () => {
|
|
|
925
926
|
post: PostFunction;
|
|
926
927
|
put: PutFunction;
|
|
927
928
|
remove: DeleteFunction;
|
|
928
|
-
fetchPdf: ({ url, v, method, body, }: FetchProps & {
|
|
929
|
+
fetchPdf: ({ url, v, method, body, headers, }: FetchProps & {
|
|
929
930
|
method: "GET" | "POST";
|
|
930
931
|
}) => Promise<{
|
|
931
932
|
ok: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -911,6 +911,7 @@ interface FetchProps {
|
|
|
911
911
|
}) => void;
|
|
912
912
|
};
|
|
913
913
|
multipart?: boolean;
|
|
914
|
+
headers?: Record<string, any>;
|
|
914
915
|
}
|
|
915
916
|
type FetchFunction = (props: Omit<FetchProps, "body">) => Promise<any>;
|
|
916
917
|
type PostFunction = (props: FetchProps) => Promise<any>;
|
|
@@ -925,7 +926,7 @@ declare const useApi: () => {
|
|
|
925
926
|
post: PostFunction;
|
|
926
927
|
put: PutFunction;
|
|
927
928
|
remove: DeleteFunction;
|
|
928
|
-
fetchPdf: ({ url, v, method, body, }: FetchProps & {
|
|
929
|
+
fetchPdf: ({ url, v, method, body, headers, }: FetchProps & {
|
|
929
930
|
method: "GET" | "POST";
|
|
930
931
|
}) => Promise<{
|
|
931
932
|
ok: boolean;
|
package/dist/index.js
CHANGED
|
@@ -745,14 +745,14 @@ var useApi = () => {
|
|
|
745
745
|
const [isLoading, setIsLoading] = (0, import_react5.useState)(false);
|
|
746
746
|
const [pdfLoading, setPdfLoading] = (0, import_react5.useState)(false);
|
|
747
747
|
const [error, setError] = (0, import_react5.useState)(null);
|
|
748
|
-
const get = async ({ url, v = 1, params, delay }) => {
|
|
748
|
+
const get = async ({ url, v = 1, params, delay, headers }) => {
|
|
749
749
|
setIsLoading(true);
|
|
750
750
|
try {
|
|
751
751
|
if (delay) await new Promise((r) => setTimeout(r, delay));
|
|
752
752
|
const prefix = v === 0 ? "" : `/v${v}`;
|
|
753
753
|
const response = await api.get(`${prefix}${url}`, {
|
|
754
754
|
params,
|
|
755
|
-
headers: { Authorization: `Bearer ${getToken()}
|
|
755
|
+
headers: { Authorization: `Bearer ${getToken()}`, ...headers }
|
|
756
756
|
});
|
|
757
757
|
setData(response.data);
|
|
758
758
|
setError(null);
|
|
@@ -771,7 +771,8 @@ var useApi = () => {
|
|
|
771
771
|
v = 1,
|
|
772
772
|
body,
|
|
773
773
|
form,
|
|
774
|
-
multipart = false
|
|
774
|
+
multipart = false,
|
|
775
|
+
headers
|
|
775
776
|
}) => {
|
|
776
777
|
setIsLoading(true);
|
|
777
778
|
try {
|
|
@@ -799,13 +800,14 @@ var useApi = () => {
|
|
|
799
800
|
response = await api.post(`${prefix}${url}`, formData, {
|
|
800
801
|
headers: {
|
|
801
802
|
"Content-Type": "multipart/form-data",
|
|
802
|
-
Authorization: `Bearer ${getToken()}
|
|
803
|
+
Authorization: `Bearer ${getToken()}`,
|
|
804
|
+
...headers
|
|
803
805
|
}
|
|
804
806
|
});
|
|
805
807
|
} else {
|
|
806
808
|
const prefix = v === 0 ? "" : `/v${v}`;
|
|
807
809
|
response = await api.post(`${prefix}${url}`, body, {
|
|
808
|
-
headers: { Authorization: `Bearer ${getToken()}
|
|
810
|
+
headers: { Authorization: `Bearer ${getToken()}`, ...headers }
|
|
809
811
|
});
|
|
810
812
|
}
|
|
811
813
|
setData(response.data);
|
|
@@ -828,12 +830,12 @@ var useApi = () => {
|
|
|
828
830
|
setIsLoading(false);
|
|
829
831
|
}
|
|
830
832
|
};
|
|
831
|
-
const put = async ({ url, v = 1, body }) => {
|
|
833
|
+
const put = async ({ url, v = 1, body, headers }) => {
|
|
832
834
|
setIsLoading(true);
|
|
833
835
|
try {
|
|
834
836
|
const prefix = v === 0 ? "" : `/v${v}`;
|
|
835
837
|
const response = await api.put(`${prefix}${url}`, body, {
|
|
836
|
-
headers: { Authorization: `Bearer ${getToken()}
|
|
838
|
+
headers: { Authorization: `Bearer ${getToken()}`, ...headers }
|
|
837
839
|
});
|
|
838
840
|
setData(response.data);
|
|
839
841
|
return response.data;
|
|
@@ -845,13 +847,13 @@ var useApi = () => {
|
|
|
845
847
|
setIsLoading(false);
|
|
846
848
|
}
|
|
847
849
|
};
|
|
848
|
-
const remove = async ({ url, v = 1, params }) => {
|
|
850
|
+
const remove = async ({ url, v = 1, params, headers }) => {
|
|
849
851
|
setIsLoading(true);
|
|
850
852
|
try {
|
|
851
853
|
const prefix = v === 0 ? "" : `/v${v}`;
|
|
852
854
|
const response = await api.delete(`${prefix}${url}`, {
|
|
853
855
|
params,
|
|
854
|
-
headers: { Authorization: `Bearer ${getToken()}
|
|
856
|
+
headers: { Authorization: `Bearer ${getToken()}`, ...headers }
|
|
855
857
|
});
|
|
856
858
|
setData(response.data);
|
|
857
859
|
setError(null);
|
|
@@ -869,7 +871,8 @@ var useApi = () => {
|
|
|
869
871
|
url,
|
|
870
872
|
v = 1,
|
|
871
873
|
method,
|
|
872
|
-
body
|
|
874
|
+
body,
|
|
875
|
+
headers
|
|
873
876
|
}) => {
|
|
874
877
|
setPdfLoading(true);
|
|
875
878
|
try {
|
|
@@ -878,7 +881,7 @@ var useApi = () => {
|
|
|
878
881
|
method,
|
|
879
882
|
data: body,
|
|
880
883
|
responseType: "blob",
|
|
881
|
-
headers: { Authorization: `Bearer ${getToken()}
|
|
884
|
+
headers: { Authorization: `Bearer ${getToken()}`, ...headers }
|
|
882
885
|
});
|
|
883
886
|
if (!response.data || response.data.size === 0) {
|
|
884
887
|
return { ok: false, message: "Received empty PDF file", errors: [] };
|
package/dist/index.mjs
CHANGED
|
@@ -526,14 +526,14 @@ var useApi = () => {
|
|
|
526
526
|
const [isLoading, setIsLoading] = useState3(false);
|
|
527
527
|
const [pdfLoading, setPdfLoading] = useState3(false);
|
|
528
528
|
const [error, setError] = useState3(null);
|
|
529
|
-
const get = async ({ url, v = 1, params, delay }) => {
|
|
529
|
+
const get = async ({ url, v = 1, params, delay, headers }) => {
|
|
530
530
|
setIsLoading(true);
|
|
531
531
|
try {
|
|
532
532
|
if (delay) await new Promise((r) => setTimeout(r, delay));
|
|
533
533
|
const prefix = v === 0 ? "" : `/v${v}`;
|
|
534
534
|
const response = await api.get(`${prefix}${url}`, {
|
|
535
535
|
params,
|
|
536
|
-
headers: { Authorization: `Bearer ${getToken()}
|
|
536
|
+
headers: { Authorization: `Bearer ${getToken()}`, ...headers }
|
|
537
537
|
});
|
|
538
538
|
setData(response.data);
|
|
539
539
|
setError(null);
|
|
@@ -552,7 +552,8 @@ var useApi = () => {
|
|
|
552
552
|
v = 1,
|
|
553
553
|
body,
|
|
554
554
|
form,
|
|
555
|
-
multipart = false
|
|
555
|
+
multipart = false,
|
|
556
|
+
headers
|
|
556
557
|
}) => {
|
|
557
558
|
setIsLoading(true);
|
|
558
559
|
try {
|
|
@@ -580,13 +581,14 @@ var useApi = () => {
|
|
|
580
581
|
response = await api.post(`${prefix}${url}`, formData, {
|
|
581
582
|
headers: {
|
|
582
583
|
"Content-Type": "multipart/form-data",
|
|
583
|
-
Authorization: `Bearer ${getToken()}
|
|
584
|
+
Authorization: `Bearer ${getToken()}`,
|
|
585
|
+
...headers
|
|
584
586
|
}
|
|
585
587
|
});
|
|
586
588
|
} else {
|
|
587
589
|
const prefix = v === 0 ? "" : `/v${v}`;
|
|
588
590
|
response = await api.post(`${prefix}${url}`, body, {
|
|
589
|
-
headers: { Authorization: `Bearer ${getToken()}
|
|
591
|
+
headers: { Authorization: `Bearer ${getToken()}`, ...headers }
|
|
590
592
|
});
|
|
591
593
|
}
|
|
592
594
|
setData(response.data);
|
|
@@ -609,12 +611,12 @@ var useApi = () => {
|
|
|
609
611
|
setIsLoading(false);
|
|
610
612
|
}
|
|
611
613
|
};
|
|
612
|
-
const put = async ({ url, v = 1, body }) => {
|
|
614
|
+
const put = async ({ url, v = 1, body, headers }) => {
|
|
613
615
|
setIsLoading(true);
|
|
614
616
|
try {
|
|
615
617
|
const prefix = v === 0 ? "" : `/v${v}`;
|
|
616
618
|
const response = await api.put(`${prefix}${url}`, body, {
|
|
617
|
-
headers: { Authorization: `Bearer ${getToken()}
|
|
619
|
+
headers: { Authorization: `Bearer ${getToken()}`, ...headers }
|
|
618
620
|
});
|
|
619
621
|
setData(response.data);
|
|
620
622
|
return response.data;
|
|
@@ -626,13 +628,13 @@ var useApi = () => {
|
|
|
626
628
|
setIsLoading(false);
|
|
627
629
|
}
|
|
628
630
|
};
|
|
629
|
-
const remove = async ({ url, v = 1, params }) => {
|
|
631
|
+
const remove = async ({ url, v = 1, params, headers }) => {
|
|
630
632
|
setIsLoading(true);
|
|
631
633
|
try {
|
|
632
634
|
const prefix = v === 0 ? "" : `/v${v}`;
|
|
633
635
|
const response = await api.delete(`${prefix}${url}`, {
|
|
634
636
|
params,
|
|
635
|
-
headers: { Authorization: `Bearer ${getToken()}
|
|
637
|
+
headers: { Authorization: `Bearer ${getToken()}`, ...headers }
|
|
636
638
|
});
|
|
637
639
|
setData(response.data);
|
|
638
640
|
setError(null);
|
|
@@ -650,7 +652,8 @@ var useApi = () => {
|
|
|
650
652
|
url,
|
|
651
653
|
v = 1,
|
|
652
654
|
method,
|
|
653
|
-
body
|
|
655
|
+
body,
|
|
656
|
+
headers
|
|
654
657
|
}) => {
|
|
655
658
|
setPdfLoading(true);
|
|
656
659
|
try {
|
|
@@ -659,7 +662,7 @@ var useApi = () => {
|
|
|
659
662
|
method,
|
|
660
663
|
data: body,
|
|
661
664
|
responseType: "blob",
|
|
662
|
-
headers: { Authorization: `Bearer ${getToken()}
|
|
665
|
+
headers: { Authorization: `Bearer ${getToken()}`, ...headers }
|
|
663
666
|
});
|
|
664
667
|
if (!response.data || response.data.size === 0) {
|
|
665
668
|
return { ok: false, message: "Received empty PDF file", errors: [] };
|