@spaceinvoices/react-ui 0.4.2 → 0.4.3

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.
Files changed (116) hide show
  1. package/cli/dist/index.js +1 -1
  2. package/package.json +1 -1
  3. package/src/components/advance-invoices/list/list-table.tsx +60 -0
  4. package/src/components/advance-invoices/list/locales/de.ts +1 -0
  5. package/src/components/advance-invoices/list/locales/en.ts +1 -0
  6. package/src/components/advance-invoices/list/locales/es.ts +1 -0
  7. package/src/components/advance-invoices/list/locales/fr.ts +1 -0
  8. package/src/components/advance-invoices/list/locales/hr.ts +1 -0
  9. package/src/components/advance-invoices/list/locales/it.ts +1 -0
  10. package/src/components/advance-invoices/list/locales/nl.ts +1 -0
  11. package/src/components/advance-invoices/list/locales/pl.ts +1 -0
  12. package/src/components/advance-invoices/list/locales/pt.ts +1 -0
  13. package/src/components/advance-invoices/list/locales/sl.ts +1 -0
  14. package/src/components/credit-notes/list/list-table.tsx +34 -6
  15. package/src/components/credit-notes/list/locales/de.ts +1 -1
  16. package/src/components/credit-notes/list/locales/en.ts +2 -0
  17. package/src/components/credit-notes/list/locales/es.ts +1 -1
  18. package/src/components/credit-notes/list/locales/fr.ts +1 -1
  19. package/src/components/credit-notes/list/locales/hr.ts +1 -1
  20. package/src/components/credit-notes/list/locales/it.ts +1 -1
  21. package/src/components/credit-notes/list/locales/nl.ts +1 -1
  22. package/src/components/credit-notes/list/locales/pl.ts +1 -1
  23. package/src/components/credit-notes/list/locales/pt.ts +1 -1
  24. package/src/components/credit-notes/list/locales/sl.ts +1 -1
  25. package/src/components/dashboard/collection-rate-card/use-collection-rate.ts +2 -2
  26. package/src/components/dashboard/invoice-status-chart/use-invoice-status.ts +3 -3
  27. package/src/components/dashboard/payment-methods-chart/use-payment-methods.ts +1 -1
  28. package/src/components/dashboard/payment-trend-chart/use-payment-trend.ts +1 -1
  29. package/src/components/dashboard/revenue-trend-chart/use-revenue-trend.ts +1 -1
  30. package/src/components/dashboard/shared/use-revenue-data.ts +4 -4
  31. package/src/components/dashboard/shared/use-stats-counts.ts +4 -4
  32. package/src/components/dashboard/shared/use-stats-query.ts +1 -1
  33. package/src/components/dashboard/tax-collected-card/use-tax-collected.ts +2 -2
  34. package/src/components/dashboard/top-customers-chart/use-top-customers.ts +1 -1
  35. package/src/components/delivery-notes/create/create-delivery-note-form.tsx +332 -0
  36. package/src/components/delivery-notes/create/locales/de.ts +50 -0
  37. package/src/components/delivery-notes/create/locales/es.ts +49 -0
  38. package/src/components/delivery-notes/create/locales/fr.ts +50 -0
  39. package/src/components/delivery-notes/create/locales/hr.ts +49 -0
  40. package/src/components/delivery-notes/create/locales/it.ts +49 -0
  41. package/src/components/delivery-notes/create/locales/nl.ts +50 -0
  42. package/src/components/delivery-notes/create/locales/pl.ts +49 -0
  43. package/src/components/delivery-notes/create/locales/pt.ts +50 -0
  44. package/src/components/delivery-notes/create/locales/sl.ts +49 -0
  45. package/src/components/delivery-notes/create/prepare-delivery-note-submission.ts +38 -0
  46. package/src/components/delivery-notes/create/use-delivery-note-customer-form.ts +1 -0
  47. package/src/components/delivery-notes/delivery-notes.hooks.ts +15 -0
  48. package/src/components/delivery-notes/list/index.ts +3 -0
  49. package/src/components/delivery-notes/list/list-row-actions.tsx +103 -0
  50. package/src/components/delivery-notes/list/list-table.tsx +214 -0
  51. package/src/components/delivery-notes/list/locales/de.ts +9 -0
  52. package/src/components/delivery-notes/list/locales/en.ts +11 -0
  53. package/src/components/delivery-notes/list/locales/es.ts +9 -0
  54. package/src/components/delivery-notes/list/locales/fr.ts +9 -0
  55. package/src/components/delivery-notes/list/locales/hr.ts +9 -0
  56. package/src/components/delivery-notes/list/locales/it.ts +9 -0
  57. package/src/components/delivery-notes/list/locales/nl.ts +9 -0
  58. package/src/components/delivery-notes/list/locales/pl.ts +9 -0
  59. package/src/components/delivery-notes/list/locales/pt.ts +9 -0
  60. package/src/components/delivery-notes/list/locales/sl.ts +9 -0
  61. package/src/components/delivery-notes/list/use-delivery-note-download.ts +63 -0
  62. package/src/components/documents/create/document-details-section.tsx +36 -32
  63. package/src/components/documents/create/live-preview.tsx +37 -10
  64. package/src/components/documents/create/prepare-document-submission.ts +1 -1
  65. package/src/components/documents/documents.hooks.ts +2 -1
  66. package/src/components/documents/shared/document-preview-display.tsx +12 -5
  67. package/src/components/documents/types.ts +10 -1
  68. package/src/components/documents/view/document-details-card.tsx +3 -3
  69. package/src/components/documents/view/document-payments-list.tsx +3 -3
  70. package/src/components/documents/view/document-relations-list.tsx +105 -0
  71. package/src/components/documents/view/locales/de.ts +21 -0
  72. package/src/components/documents/view/locales/es.ts +21 -0
  73. package/src/components/documents/view/locales/fr.ts +21 -0
  74. package/src/components/documents/view/locales/hr.ts +21 -0
  75. package/src/components/documents/view/locales/it.ts +21 -0
  76. package/src/components/documents/view/locales/nl.ts +21 -0
  77. package/src/components/documents/view/locales/pl.ts +21 -0
  78. package/src/components/documents/view/locales/pt.ts +21 -0
  79. package/src/components/documents/view/locales/sl.ts +21 -0
  80. package/src/components/documents/view/use-document-download.ts +5 -3
  81. package/src/components/entities/fina-settings-form/fina-settings-form.tsx +77 -65
  82. package/src/components/entities/fina-settings-form/fina-settings.hooks.ts +7 -2
  83. package/src/components/entities/furs-settings-form/furs-settings-form.tsx +10 -1
  84. package/src/components/entities/furs-settings-form/furs-settings.hooks.ts +7 -2
  85. package/src/components/entities/furs-settings-form/sections/general-settings-section.tsx +12 -4
  86. package/src/components/invoices/invoices-furs.hooks.ts +24 -9
  87. package/src/components/invoices/list/list-row-actions.tsx +3 -3
  88. package/src/components/invoices/list/list-table.tsx +68 -3
  89. package/src/components/invoices/list/locales/de.ts +1 -0
  90. package/src/components/invoices/list/locales/en.ts +1 -0
  91. package/src/components/invoices/list/locales/es.ts +1 -0
  92. package/src/components/invoices/list/locales/fr.ts +1 -0
  93. package/src/components/invoices/list/locales/hr.ts +1 -0
  94. package/src/components/invoices/list/locales/it.ts +1 -0
  95. package/src/components/invoices/list/locales/nl.ts +1 -0
  96. package/src/components/invoices/list/locales/pl.ts +1 -0
  97. package/src/components/invoices/list/locales/pt.ts +1 -0
  98. package/src/components/invoices/list/locales/sl.ts +1 -0
  99. package/src/components/items/item-list-table/item-list-row-actions.tsx +3 -2
  100. package/src/components/items/item-list-table/item-list-row.tsx +3 -2
  101. package/src/generated/schemas/deliverynote.ts +134 -0
  102. package/src/generated/schemas/entity.ts +4 -0
  103. package/src/generated/schemas/index.ts +3 -0
  104. package/src/generated/schemas/order.ts +5 -3
  105. package/src/generated/schemas/payment.ts +22 -2
  106. package/src/generated/schemas/renderadvanceinvoicepreview_body.ts +1 -0
  107. package/src/generated/schemas/rendercreditnotepreview_body.ts +1 -0
  108. package/src/generated/schemas/renderdeliverynotepreview_body.ts +185 -0
  109. package/src/generated/schemas/renderestimatepreview_body.ts +1 -0
  110. package/src/generated/schemas/renderinvoicepreview_body.ts +1 -0
  111. package/src/generated/schemas/startpdfexport_body.ts +18 -2
  112. package/src/generated/schemas/userfinasettings.ts +19 -0
  113. package/src/generated/schemas/webhook.ts +12 -0
  114. package/src/hooks/use-duplicate-document.ts +11 -3
  115. package/src/hooks/use-next-document-number.ts +2 -2
  116. package/src/providers/sdk-provider.tsx +5 -7
package/cli/dist/index.js CHANGED
@@ -870,7 +870,7 @@ async function list(options = {}) {
870
870
 
871
871
  // cli/src/index.ts
872
872
  var program = new Command();
873
- program.name("spaceinvoices-ui").description("CLI for adding Space Invoices React UI components to your project").version("0.4.2");
873
+ program.name("spaceinvoices-ui").description("CLI for adding Space Invoices React UI components to your project").version("0.4.3");
874
874
  program.option("--local <path>", "Use local registry from specified path (for development)");
875
875
  program.command("init").description("Initialize Space Invoices UI in your project").option("-y, --yes", "Skip prompts and use defaults").option("-f, --force", "Overwrite existing configuration").option("--cwd <path>", "Working directory (defaults to current directory)").action(async (options) => {
876
876
  const globalOpts = program.opts();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spaceinvoices/react-ui",
3
3
  "type": "module",
4
- "version": "0.4.2",
4
+ "version": "0.4.3",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "description": "Space Invoices UI components - copy-paste distribution with CLI support",
@@ -184,6 +184,11 @@ export default function AdvanceInvoiceListTable({
184
184
  align: "right",
185
185
  cell: (advanceInvoice) => advanceInvoice.total_with_tax,
186
186
  },
187
+ {
188
+ id: "status",
189
+ header: t("Status"),
190
+ cell: (advanceInvoice) => <AdvanceInvoiceStatusBadge advanceInvoice={advanceInvoice} t={t} />,
191
+ },
187
192
  {
188
193
  id: "actions",
189
194
  header: "",
@@ -236,3 +241,58 @@ export default function AdvanceInvoiceListTable({
236
241
  />
237
242
  );
238
243
  }
244
+
245
+ /** Status badge for advance invoices */
246
+ function AdvanceInvoiceStatusBadge({
247
+ advanceInvoice,
248
+ t,
249
+ }: {
250
+ advanceInvoice: AdvanceInvoice;
251
+ t: (key: string) => string;
252
+ }) {
253
+ if ((advanceInvoice as any).voided_at) {
254
+ return (
255
+ <Badge variant="outline" className="border-red-500 bg-red-50 text-red-700 dark:bg-red-950 dark:text-red-400">
256
+ {t("Voided")}
257
+ </Badge>
258
+ );
259
+ }
260
+ if ((advanceInvoice as any).is_draft) {
261
+ return null;
262
+ }
263
+ if (advanceInvoice.paid_in_full) {
264
+ return (
265
+ <Badge
266
+ variant="outline"
267
+ className="border-green-500 bg-green-50 text-green-700 dark:bg-green-950 dark:text-green-400"
268
+ >
269
+ {t("Paid")}
270
+ </Badge>
271
+ );
272
+ }
273
+ if (advanceInvoice.date_due && new Date(advanceInvoice.date_due) < new Date()) {
274
+ return (
275
+ <Badge
276
+ variant="outline"
277
+ className="border-orange-500 bg-orange-50 text-orange-700 dark:bg-orange-950 dark:text-orange-400"
278
+ >
279
+ {t("Overdue")}
280
+ </Badge>
281
+ );
282
+ }
283
+ if (advanceInvoice.total_paid > 0) {
284
+ return (
285
+ <Badge
286
+ variant="outline"
287
+ className="border-yellow-500 bg-yellow-50 text-yellow-700 dark:bg-yellow-950 dark:text-yellow-400"
288
+ >
289
+ {t("Partially Paid")}
290
+ </Badge>
291
+ );
292
+ }
293
+ return (
294
+ <Badge variant="outline" className="border-gray-500 bg-gray-50 text-gray-700 dark:bg-gray-800 dark:text-gray-400">
295
+ {t("Unpaid")}
296
+ </Badge>
297
+ );
298
+ }
@@ -41,4 +41,5 @@ export default {
41
41
  selected: "ausgewählt",
42
42
  "Export PDFs": "PDFs exportieren",
43
43
  "Deselect all": "Auswahl aufheben",
44
+ "Partially Paid": "Teilweise bezahlt",
44
45
  } as const;
@@ -8,4 +8,5 @@ export default {
8
8
  selected: "selected",
9
9
  "Export PDFs": "Export PDFs",
10
10
  "Deselect all": "Deselect all",
11
+ "Partially Paid": "Partially Paid",
11
12
  } as const;
@@ -41,4 +41,5 @@ export default {
41
41
  selected: "seleccionados",
42
42
  "Export PDFs": "Exportar PDFs",
43
43
  "Deselect all": "Deseleccionar todo",
44
+ "Partially Paid": "Parcialmente pagado",
44
45
  } as const;
@@ -41,4 +41,5 @@ export default {
41
41
  selected: "sélectionnés",
42
42
  "Export PDFs": "Exporter les PDF",
43
43
  "Deselect all": "Tout désélectionner",
44
+ "Partially Paid": "Partiellement payé",
44
45
  } as const;
@@ -41,4 +41,5 @@ export default {
41
41
  selected: "odabranih",
42
42
  "Export PDFs": "Izvezi PDF-ove",
43
43
  "Deselect all": "Poništi odabir",
44
+ "Partially Paid": "Djelomično plaćeno",
44
45
  } as const;
@@ -41,4 +41,5 @@ export default {
41
41
  selected: "selezionati",
42
42
  "Export PDFs": "Esporta PDF",
43
43
  "Deselect all": "Deseleziona tutto",
44
+ "Partially Paid": "Parzialmente pagato",
44
45
  } as const;
@@ -41,4 +41,5 @@ export default {
41
41
  selected: "geselecteerd",
42
42
  "Export PDFs": "PDFs exporteren",
43
43
  "Deselect all": "Alles deselecteren",
44
+ "Partially Paid": "Gedeeltelijk betaald",
44
45
  } as const;
@@ -41,4 +41,5 @@ export default {
41
41
  selected: "wybranych",
42
42
  "Export PDFs": "Eksportuj PDF-y",
43
43
  "Deselect all": "Odznacz wszystko",
44
+ "Partially Paid": "Częściowo opłacona",
44
45
  } as const;
@@ -41,4 +41,5 @@ export default {
41
41
  selected: "selecionados",
42
42
  "Export PDFs": "Exportar PDFs",
43
43
  "Deselect all": "Desselecionar tudo",
44
+ "Partially Paid": "Parcialmente pago",
44
45
  } as const;
@@ -41,4 +41,5 @@ export default {
41
41
  selected: "izbranih",
42
42
  "Export PDFs": "Izvozi PDF-je",
43
43
  "Deselect all": "Počisti izbiro",
44
+ "Partially Paid": "Delno plačano",
44
45
  } as const;
@@ -176,7 +176,7 @@ export default function CreditNoteListTable({
176
176
  {
177
177
  id: "status",
178
178
  header: t("Status"),
179
- cell: (creditNote) => <PaymentStatusBadge creditNote={creditNote} t={t} />,
179
+ cell: (creditNote) => <CreditNoteStatusBadge creditNote={creditNote} t={t} />,
180
180
  },
181
181
  {
182
182
  id: "actions",
@@ -231,13 +231,41 @@ export default function CreditNoteListTable({
231
231
  );
232
232
  }
233
233
 
234
- /** Payment status badge for credit notes */
235
- function PaymentStatusBadge({ creditNote, t }: { creditNote: CreditNote; t: (key: string) => string }) {
234
+ /** Status badge for credit notes */
235
+ function CreditNoteStatusBadge({ creditNote, t }: { creditNote: CreditNote; t: (key: string) => string }) {
236
+ if ((creditNote as any).voided_at) {
237
+ return (
238
+ <Badge variant="outline" className="border-red-500 bg-red-50 text-red-700 dark:bg-red-950 dark:text-red-400">
239
+ {t("Voided")}
240
+ </Badge>
241
+ );
242
+ }
243
+ if ((creditNote as any).is_draft) {
244
+ return null;
245
+ }
236
246
  if (creditNote.paid_in_full) {
237
- return <span className="rounded-full bg-green-100 px-2 py-1 text-green-800 text-xs">{t("Paid")}</span>;
247
+ return (
248
+ <Badge
249
+ variant="outline"
250
+ className="border-green-500 bg-green-50 text-green-700 dark:bg-green-950 dark:text-green-400"
251
+ >
252
+ {t("Paid")}
253
+ </Badge>
254
+ );
238
255
  }
239
256
  if (creditNote.total_paid > 0) {
240
- return <span className="rounded-full bg-yellow-100 px-2 py-1 text-xs text-yellow-800">{t("Partial")}</span>;
257
+ return (
258
+ <Badge
259
+ variant="outline"
260
+ className="border-yellow-500 bg-yellow-50 text-yellow-700 dark:bg-yellow-950 dark:text-yellow-400"
261
+ >
262
+ {t("Partially Paid")}
263
+ </Badge>
264
+ );
241
265
  }
242
- return <span className="rounded-full bg-gray-100 px-2 py-1 text-gray-800 text-xs">{t("Unpaid")}</span>;
266
+ return (
267
+ <Badge variant="outline" className="border-gray-500 bg-gray-50 text-gray-700 dark:bg-gray-800 dark:text-gray-400">
268
+ {t("Unpaid")}
269
+ </Badge>
270
+ );
243
271
  }
@@ -28,7 +28,7 @@ export default {
28
28
  Overdue: "Überfällig",
29
29
  Voided: "Storniert",
30
30
  "Created At": "Erstellt am",
31
- Partial: "Teilweise bezahlt",
31
+ "Partially Paid": "Teilweise bezahlt",
32
32
  Unshare: "Freigabe aufheben",
33
33
  // Empty state translations
34
34
  "Your list is empty": "Ihre Gutschriftenliste ist leer",
@@ -8,4 +8,6 @@ export default {
8
8
  selected: "selected",
9
9
  "Export PDFs": "Export PDFs",
10
10
  "Deselect all": "Deselect all",
11
+ "Partially Paid": "Partially Paid",
12
+ Voided: "Voided",
11
13
  } as const;
@@ -28,7 +28,7 @@ export default {
28
28
  Overdue: "Vencido",
29
29
  Voided: "Anulado",
30
30
  "Created At": "Creado el",
31
- Partial: "Parcialmente pagado",
31
+ "Partially Paid": "Parcialmente pagado",
32
32
  Unshare: "Dejar de compartir",
33
33
  // Empty state translations
34
34
  "Your list is empty": "Su lista de notas de credito esta vacia",
@@ -28,7 +28,7 @@ export default {
28
28
  Overdue: "En retard",
29
29
  Voided: "Annule",
30
30
  "Created At": "Cree le",
31
- Partial: "Partiellement paye",
31
+ "Partially Paid": "Partiellement payé",
32
32
  Unshare: "Supprimer le partage",
33
33
  // Empty state translations
34
34
  "Your list is empty": "Votre liste d'avoirs est vide",
@@ -28,7 +28,7 @@ export default {
28
28
  Overdue: "Dospjelo",
29
29
  Voided: "Stornirano",
30
30
  "Created At": "Kreirano",
31
- Partial: "Djelomicno placeno",
31
+ "Partially Paid": "Djelomično plaćeno",
32
32
  Unshare: "Ukloni dijeljenje",
33
33
  // Empty state translations
34
34
  "Your list is empty": "Vasa lista odobrenja je prazna",
@@ -28,7 +28,7 @@ export default {
28
28
  Overdue: "Scaduto",
29
29
  Voided: "Annullato",
30
30
  "Created At": "Creato il",
31
- Partial: "Parzialmente pagato",
31
+ "Partially Paid": "Parzialmente pagato",
32
32
  Unshare: "Rimuovi condivisione",
33
33
  // Empty state translations
34
34
  "Your list is empty": "La lista delle note di credito e vuota",
@@ -28,7 +28,7 @@ export default {
28
28
  Overdue: "Achterstallig",
29
29
  Voided: "Nietig verklaard",
30
30
  "Created At": "Aangemaakt op",
31
- Partial: "Gedeeltelijk betaald",
31
+ "Partially Paid": "Gedeeltelijk betaald",
32
32
  Unshare: "Delen opheffen",
33
33
  // Empty state translations
34
34
  "Your list is empty": "Uw lijst met creditnota's is leeg",
@@ -28,7 +28,7 @@ export default {
28
28
  Overdue: "Zaległe",
29
29
  Voided: "Anulowane",
30
30
  "Created At": "Utworzono",
31
- Partial: "Czesciowo oplacone",
31
+ "Partially Paid": "Częściowo opłacona",
32
32
  Unshare: "Cofnij udostepnienie",
33
33
  // Empty state translations
34
34
  "Your list is empty": "Twoja lista not kredytowych jest pusta",
@@ -28,7 +28,7 @@ export default {
28
28
  Overdue: "Vencido",
29
29
  Voided: "Anulado",
30
30
  "Created At": "Criado em",
31
- Partial: "Parcialmente pago",
31
+ "Partially Paid": "Parcialmente pago",
32
32
  Unshare: "Remover partilha",
33
33
  // Empty state translations
34
34
  "Your list is empty": "A sua lista de notas de credito esta vazia",
@@ -28,7 +28,7 @@ export default {
28
28
  Overdue: "Zapadlo",
29
29
  Voided: "Stornirano",
30
30
  "Created At": "Ustvarjeno",
31
- Partial: "Delno plačano",
31
+ "Partially Paid": "Delno plačano",
32
32
  Unshare: "Odstrani deljenje",
33
33
  // Empty state translations
34
34
  "Your list is empty": "Vaš seznam dobropisov je prazen",
@@ -35,7 +35,7 @@ export function useCollectionRateData(entityId: string | undefined) {
35
35
  );
36
36
  },
37
37
  enabled: !!entityId && !!sdk,
38
- staleTime: 30_000,
38
+ staleTime: 120_000,
39
39
  },
40
40
  // Total collected (payments)
41
41
  {
@@ -51,7 +51,7 @@ export function useCollectionRateData(entityId: string | undefined) {
51
51
  );
52
52
  },
53
53
  enabled: !!entityId && !!sdk,
54
- staleTime: 30_000,
54
+ staleTime: 120_000,
55
55
  },
56
56
  ],
57
57
  });
@@ -36,7 +36,7 @@ export function useInvoiceStatusData(entityId: string | undefined) {
36
36
  );
37
37
  },
38
38
  enabled: !!entityId && !!sdk,
39
- staleTime: 30_000,
39
+ staleTime: 120_000,
40
40
  },
41
41
  // Unpaid invoices grouped by overdue bucket (current = pending, others = overdue)
42
42
  {
@@ -54,7 +54,7 @@ export function useInvoiceStatusData(entityId: string | undefined) {
54
54
  );
55
55
  },
56
56
  enabled: !!entityId && !!sdk,
57
- staleTime: 30_000,
57
+ staleTime: 120_000,
58
58
  },
59
59
  // Total count to derive voided
60
60
  {
@@ -71,7 +71,7 @@ export function useInvoiceStatusData(entityId: string | undefined) {
71
71
  );
72
72
  },
73
73
  enabled: !!entityId && !!sdk,
74
- staleTime: 30_000,
74
+ staleTime: 120_000,
75
75
  },
76
76
  ],
77
77
  });
@@ -32,7 +32,7 @@ export function usePaymentMethodsData(entityId: string | undefined) {
32
32
  );
33
33
  },
34
34
  enabled: !!entityId && !!sdk,
35
- staleTime: 30_000,
35
+ staleTime: 120_000,
36
36
  select: (response) => {
37
37
  const data = response.data || [];
38
38
  return (data as StatsQueryDataItem[]).map((row) => ({
@@ -54,7 +54,7 @@ export function usePaymentTrendData(entityId: string | undefined) {
54
54
  );
55
55
  },
56
56
  enabled: !!entityId && !!sdk,
57
- staleTime: 30_000,
57
+ staleTime: 120_000,
58
58
  select: (response) => {
59
59
  // Build a map of all months with 0 amount
60
60
  const monthMap: Record<string, number> = {};
@@ -55,7 +55,7 @@ export function useRevenueTrendData(entityId: string | undefined) {
55
55
  );
56
56
  },
57
57
  enabled: !!entityId && !!sdk,
58
- staleTime: 30_000,
58
+ staleTime: 120_000,
59
59
  select: (response) => {
60
60
  // Build a map of all months with 0 revenue
61
61
  const monthMap: Record<string, number> = {};
@@ -61,7 +61,7 @@ export function useRevenueData(entityId: string | undefined) {
61
61
  );
62
62
  },
63
63
  enabled: !!entityId && !!sdk,
64
- staleTime: 30_000,
64
+ staleTime: 120_000,
65
65
  },
66
66
  // This year revenue (using converted amounts for multi-currency support)
67
67
  {
@@ -80,7 +80,7 @@ export function useRevenueData(entityId: string | undefined) {
80
80
  );
81
81
  },
82
82
  enabled: !!entityId && !!sdk,
83
- staleTime: 30_000,
83
+ staleTime: 120_000,
84
84
  },
85
85
  // Outstanding (unpaid, not voided)
86
86
  {
@@ -97,7 +97,7 @@ export function useRevenueData(entityId: string | undefined) {
97
97
  );
98
98
  },
99
99
  enabled: !!entityId && !!sdk,
100
- staleTime: 30_000,
100
+ staleTime: 120_000,
101
101
  },
102
102
  // Overdue (past due date, unpaid)
103
103
  {
@@ -118,7 +118,7 @@ export function useRevenueData(entityId: string | undefined) {
118
118
  );
119
119
  },
120
120
  enabled: !!entityId && !!sdk,
121
- staleTime: 30_000,
121
+ staleTime: 120_000,
122
122
  },
123
123
  ],
124
124
  });
@@ -31,7 +31,7 @@ export function useStatsCountsData(entityId: string | undefined) {
31
31
  );
32
32
  },
33
33
  enabled: !!entityId && !!sdk,
34
- staleTime: 30_000,
34
+ staleTime: 120_000,
35
35
  },
36
36
  // Estimates count
37
37
  {
@@ -44,7 +44,7 @@ export function useStatsCountsData(entityId: string | undefined) {
44
44
  );
45
45
  },
46
46
  enabled: !!entityId && !!sdk,
47
- staleTime: 30_000,
47
+ staleTime: 120_000,
48
48
  },
49
49
  // Customers count
50
50
  {
@@ -57,7 +57,7 @@ export function useStatsCountsData(entityId: string | undefined) {
57
57
  );
58
58
  },
59
59
  enabled: !!entityId && !!sdk,
60
- staleTime: 30_000,
60
+ staleTime: 120_000,
61
61
  },
62
62
  // Items count
63
63
  {
@@ -70,7 +70,7 @@ export function useStatsCountsData(entityId: string | undefined) {
70
70
  );
71
71
  },
72
72
  enabled: !!entityId && !!sdk,
73
- staleTime: 30_000,
73
+ staleTime: 120_000,
74
74
  },
75
75
  ],
76
76
  });
@@ -32,7 +32,7 @@ export function useStatsQuery<TData = StatsQueryResponse>(
32
32
  return await sdk.entityStats.queryEntityStats(query, { entity_id: entityId });
33
33
  },
34
34
  enabled: !!entityId && !!sdk,
35
- staleTime: 30_000, // 30 seconds
35
+ staleTime: 120_000, // 2 minutes
36
36
  ...options,
37
37
  });
38
38
  }
@@ -88,7 +88,7 @@ export function useTaxCollectedData(entityId: string | undefined) {
88
88
  );
89
89
  },
90
90
  enabled: !!entityId && !!sdk,
91
- staleTime: 60_000, // 1 minute
91
+ staleTime: 120_000, // 1 minute
92
92
  },
93
93
  // Current year taxes - aggregated by rate using stats API
94
94
  {
@@ -108,7 +108,7 @@ export function useTaxCollectedData(entityId: string | undefined) {
108
108
  );
109
109
  },
110
110
  enabled: !!entityId && !!sdk,
111
- staleTime: 60_000,
111
+ staleTime: 120_000,
112
112
  },
113
113
  ],
114
114
  });
@@ -34,7 +34,7 @@ export function useTopCustomersData(entityId: string | undefined, limit = 5) {
34
34
  );
35
35
  },
36
36
  enabled: !!entityId && !!sdk,
37
- staleTime: 30_000,
37
+ staleTime: 120_000,
38
38
  select: (response) => {
39
39
  const data = response.data || [];
40
40