warqadui 0.0.302 → 0.0.303

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 CHANGED
@@ -447,6 +447,7 @@ type EnumsConfig = {
447
447
  };
448
448
  interface WarqadConfig {
449
449
  api?: string;
450
+ apiHeaders?: Record<string, any>;
450
451
  socketUrl?: string;
451
452
  apiConfig?: apiConfig;
452
453
  theme?: ThemeConfig;
@@ -481,6 +482,7 @@ interface WarqadConfig {
481
482
  interface WarqadConfigContextType {
482
483
  config: WarqadConfig & {
483
484
  api: string;
485
+ apiHeaders?: Record<string, any>;
484
486
  apiConfig: Required<apiConfig>;
485
487
  theme: Required<ThemeConfig>;
486
488
  store: Required<StoreConfig>;
@@ -496,6 +498,7 @@ interface WarqadConfigContextType {
496
498
  */
497
499
  declare const useWarqadConfig: () => WarqadConfig & {
498
500
  api: string;
501
+ apiHeaders?: Record<string, any>;
499
502
  apiConfig: Required<apiConfig>;
500
503
  theme: Required<ThemeConfig>;
501
504
  store: Required<StoreConfig>;
package/dist/index.d.ts CHANGED
@@ -447,6 +447,7 @@ type EnumsConfig = {
447
447
  };
448
448
  interface WarqadConfig {
449
449
  api?: string;
450
+ apiHeaders?: Record<string, any>;
450
451
  socketUrl?: string;
451
452
  apiConfig?: apiConfig;
452
453
  theme?: ThemeConfig;
@@ -481,6 +482,7 @@ interface WarqadConfig {
481
482
  interface WarqadConfigContextType {
482
483
  config: WarqadConfig & {
483
484
  api: string;
485
+ apiHeaders?: Record<string, any>;
484
486
  apiConfig: Required<apiConfig>;
485
487
  theme: Required<ThemeConfig>;
486
488
  store: Required<StoreConfig>;
@@ -496,6 +498,7 @@ interface WarqadConfigContextType {
496
498
  */
497
499
  declare const useWarqadConfig: () => WarqadConfig & {
498
500
  api: string;
501
+ apiHeaders?: Record<string, any>;
499
502
  apiConfig: Required<apiConfig>;
500
503
  theme: Required<ThemeConfig>;
501
504
  store: Required<StoreConfig>;
package/dist/index.js CHANGED
@@ -415,6 +415,7 @@ var WarqadProvider = ({ children, config }) => {
415
415
  const mergedConfig = (0, import_react2.useMemo)(
416
416
  () => ({
417
417
  api: config?.api || DEFAULT_API,
418
+ apiHeaders: config?.apiHeaders,
418
419
  socketUrl: config?.socketUrl,
419
420
  apiConfig: {
420
421
  ...DEFAULT_API_CONFIG,
@@ -733,7 +734,7 @@ var getToken = () => {
733
734
  return localStorage.getItem("token");
734
735
  };
735
736
  var useApi = () => {
736
- const { api: configApi } = useWarqadConfig();
737
+ const { api: configApi, apiHeaders } = useWarqadConfig();
737
738
  const api = (0, import_react5.useMemo)(() => {
738
739
  const baseURL = configApi || "/api";
739
740
  return import_axios.default.create({
@@ -752,7 +753,11 @@ var useApi = () => {
752
753
  const prefix = v === 0 ? "" : `/v${v}`;
753
754
  const response = await api.get(`${prefix}${url}`, {
754
755
  params,
755
- headers: { Authorization: `Bearer ${getToken()}`, ...headers }
756
+ headers: {
757
+ Authorization: `Bearer ${getToken()}`,
758
+ ...apiHeaders,
759
+ ...headers
760
+ }
756
761
  });
757
762
  setData(response.data);
758
763
  setError(null);
@@ -801,13 +806,18 @@ var useApi = () => {
801
806
  headers: {
802
807
  "Content-Type": "multipart/form-data",
803
808
  Authorization: `Bearer ${getToken()}`,
809
+ ...apiHeaders,
804
810
  ...headers
805
811
  }
806
812
  });
807
813
  } else {
808
814
  const prefix = v === 0 ? "" : `/v${v}`;
809
815
  response = await api.post(`${prefix}${url}`, body, {
810
- headers: { Authorization: `Bearer ${getToken()}`, ...headers }
816
+ headers: {
817
+ Authorization: `Bearer ${getToken()}`,
818
+ ...apiHeaders,
819
+ ...headers
820
+ }
811
821
  });
812
822
  }
813
823
  setData(response.data);
@@ -835,7 +845,11 @@ var useApi = () => {
835
845
  try {
836
846
  const prefix = v === 0 ? "" : `/v${v}`;
837
847
  const response = await api.put(`${prefix}${url}`, body, {
838
- headers: { Authorization: `Bearer ${getToken()}`, ...headers }
848
+ headers: {
849
+ Authorization: `Bearer ${getToken()}`,
850
+ ...apiHeaders,
851
+ ...headers
852
+ }
839
853
  });
840
854
  setData(response.data);
841
855
  return response.data;
@@ -853,7 +867,11 @@ var useApi = () => {
853
867
  const prefix = v === 0 ? "" : `/v${v}`;
854
868
  const response = await api.delete(`${prefix}${url}`, {
855
869
  params,
856
- headers: { Authorization: `Bearer ${getToken()}`, ...headers }
870
+ headers: {
871
+ Authorization: `Bearer ${getToken()}`,
872
+ ...apiHeaders,
873
+ ...headers
874
+ }
857
875
  });
858
876
  setData(response.data);
859
877
  setError(null);
@@ -881,7 +899,11 @@ var useApi = () => {
881
899
  method,
882
900
  data: body,
883
901
  responseType: "blob",
884
- headers: { Authorization: `Bearer ${getToken()}`, ...headers }
902
+ headers: {
903
+ Authorization: `Bearer ${getToken()}`,
904
+ ...apiHeaders,
905
+ ...headers
906
+ }
885
907
  });
886
908
  if (!response.data || response.data.size === 0) {
887
909
  return { ok: false, message: "Received empty PDF file", errors: [] };
package/dist/index.mjs CHANGED
@@ -196,6 +196,7 @@ var WarqadProvider = ({ children, config }) => {
196
196
  const mergedConfig = useMemo(
197
197
  () => ({
198
198
  api: config?.api || DEFAULT_API,
199
+ apiHeaders: config?.apiHeaders,
199
200
  socketUrl: config?.socketUrl,
200
201
  apiConfig: {
201
202
  ...DEFAULT_API_CONFIG,
@@ -514,7 +515,7 @@ var getToken = () => {
514
515
  return localStorage.getItem("token");
515
516
  };
516
517
  var useApi = () => {
517
- const { api: configApi } = useWarqadConfig();
518
+ const { api: configApi, apiHeaders } = useWarqadConfig();
518
519
  const api = useMemo2(() => {
519
520
  const baseURL = configApi || "/api";
520
521
  return axios.create({
@@ -533,7 +534,11 @@ var useApi = () => {
533
534
  const prefix = v === 0 ? "" : `/v${v}`;
534
535
  const response = await api.get(`${prefix}${url}`, {
535
536
  params,
536
- headers: { Authorization: `Bearer ${getToken()}`, ...headers }
537
+ headers: {
538
+ Authorization: `Bearer ${getToken()}`,
539
+ ...apiHeaders,
540
+ ...headers
541
+ }
537
542
  });
538
543
  setData(response.data);
539
544
  setError(null);
@@ -582,13 +587,18 @@ var useApi = () => {
582
587
  headers: {
583
588
  "Content-Type": "multipart/form-data",
584
589
  Authorization: `Bearer ${getToken()}`,
590
+ ...apiHeaders,
585
591
  ...headers
586
592
  }
587
593
  });
588
594
  } else {
589
595
  const prefix = v === 0 ? "" : `/v${v}`;
590
596
  response = await api.post(`${prefix}${url}`, body, {
591
- headers: { Authorization: `Bearer ${getToken()}`, ...headers }
597
+ headers: {
598
+ Authorization: `Bearer ${getToken()}`,
599
+ ...apiHeaders,
600
+ ...headers
601
+ }
592
602
  });
593
603
  }
594
604
  setData(response.data);
@@ -616,7 +626,11 @@ var useApi = () => {
616
626
  try {
617
627
  const prefix = v === 0 ? "" : `/v${v}`;
618
628
  const response = await api.put(`${prefix}${url}`, body, {
619
- headers: { Authorization: `Bearer ${getToken()}`, ...headers }
629
+ headers: {
630
+ Authorization: `Bearer ${getToken()}`,
631
+ ...apiHeaders,
632
+ ...headers
633
+ }
620
634
  });
621
635
  setData(response.data);
622
636
  return response.data;
@@ -634,7 +648,11 @@ var useApi = () => {
634
648
  const prefix = v === 0 ? "" : `/v${v}`;
635
649
  const response = await api.delete(`${prefix}${url}`, {
636
650
  params,
637
- headers: { Authorization: `Bearer ${getToken()}`, ...headers }
651
+ headers: {
652
+ Authorization: `Bearer ${getToken()}`,
653
+ ...apiHeaders,
654
+ ...headers
655
+ }
638
656
  });
639
657
  setData(response.data);
640
658
  setError(null);
@@ -662,7 +680,11 @@ var useApi = () => {
662
680
  method,
663
681
  data: body,
664
682
  responseType: "blob",
665
- headers: { Authorization: `Bearer ${getToken()}`, ...headers }
683
+ headers: {
684
+ Authorization: `Bearer ${getToken()}`,
685
+ ...apiHeaders,
686
+ ...headers
687
+ }
666
688
  });
667
689
  if (!response.data || response.data.size === 0) {
668
690
  return { ok: false, message: "Received empty PDF file", errors: [] };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "warqadui",
3
- "version": "0.0.302",
3
+ "version": "0.0.303",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",