@spaceinvoices/react-ui 0.1.1

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 (352) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +340 -0
  3. package/cli/dist/index.js +922 -0
  4. package/package.json +87 -0
  5. package/registry.json +600 -0
  6. package/spaceinvoices.schema.json +47 -0
  7. package/src/app.tsx +25 -0
  8. package/src/common/autocomplete.tsx +135 -0
  9. package/src/components/activities/activity-timeline.tsx +160 -0
  10. package/src/components/activities/index.ts +1 -0
  11. package/src/components/activities/locales/de.ts +30 -0
  12. package/src/components/activities/locales/sl.ts +30 -0
  13. package/src/components/advance-invoices/advance-invoices.hooks.ts +75 -0
  14. package/src/components/advance-invoices/create/create-advance-invoice-form.tsx +702 -0
  15. package/src/components/advance-invoices/create/locales/de.ts +29 -0
  16. package/src/components/advance-invoices/create/locales/sl.ts +25 -0
  17. package/src/components/advance-invoices/create/prepare-advance-invoice-submission.ts +74 -0
  18. package/src/components/advance-invoices/index.ts +5 -0
  19. package/src/components/advance-invoices/list/index.ts +3 -0
  20. package/src/components/advance-invoices/list/list-row-actions.tsx +119 -0
  21. package/src/components/advance-invoices/list/list-table.tsx +178 -0
  22. package/src/components/advance-invoices/list/locales/de.ts +32 -0
  23. package/src/components/advance-invoices/list/locales/sl.ts +32 -0
  24. package/src/components/advance-invoices/list/use-advance-invoice-download.ts +63 -0
  25. package/src/components/button-loader.tsx +11 -0
  26. package/src/components/combobox.tsx +96 -0
  27. package/src/components/company-registry/company-registry-autocomplete.tsx +151 -0
  28. package/src/components/company-registry/company-registry.hooks.ts +67 -0
  29. package/src/components/company-registry/index.ts +7 -0
  30. package/src/components/credit-notes/create/create-credit-note-form.tsx +332 -0
  31. package/src/components/credit-notes/create/index.ts +1 -0
  32. package/src/components/credit-notes/create/locales/de.ts +69 -0
  33. package/src/components/credit-notes/create/locales/sl.ts +67 -0
  34. package/src/components/credit-notes/credit-notes.hooks.ts +22 -0
  35. package/src/components/credit-notes/index.ts +10 -0
  36. package/src/components/credit-notes/list/index.ts +3 -0
  37. package/src/components/credit-notes/list/list-row-actions.tsx +116 -0
  38. package/src/components/credit-notes/list/list-table.tsx +183 -0
  39. package/src/components/credit-notes/list/locales/de.ts +33 -0
  40. package/src/components/credit-notes/list/locales/sl.ts +33 -0
  41. package/src/components/credit-notes/list/use-credit-note-download.ts +65 -0
  42. package/src/components/customers/create-customer-form/create-customer-form.tsx +134 -0
  43. package/src/components/customers/create-customer-form/locales/de.ts +20 -0
  44. package/src/components/customers/create-customer-form/locales/sl.ts +20 -0
  45. package/src/components/customers/customer-autocomplete.tsx +173 -0
  46. package/src/components/customers/customer-combobox.tsx +130 -0
  47. package/src/components/customers/customer-list-table/customer-list-row-actions.tsx +48 -0
  48. package/src/components/customers/customer-list-table/customer-list-table.tsx +124 -0
  49. package/src/components/customers/customer-list-table/index.ts +2 -0
  50. package/src/components/customers/customer-list-table/locales/de.ts +16 -0
  51. package/src/components/customers/customer-list-table/locales/sl.ts +16 -0
  52. package/src/components/customers/customers.hooks.test.ts +348 -0
  53. package/src/components/customers/customers.hooks.ts +57 -0
  54. package/src/components/customers/index.ts +5 -0
  55. package/src/components/dashboard/chart-empty-state.tsx +29 -0
  56. package/src/components/dashboard/collection-rate-card/collection-rate-card.tsx +80 -0
  57. package/src/components/dashboard/collection-rate-card/index.ts +4 -0
  58. package/src/components/dashboard/collection-rate-card/locales/sl.ts +3 -0
  59. package/src/components/dashboard/collection-rate-card/use-collection-rate.ts +74 -0
  60. package/src/components/dashboard/index.ts +54 -0
  61. package/src/components/dashboard/invoice-status-chart/index.ts +4 -0
  62. package/src/components/dashboard/invoice-status-chart/invoice-status-chart.tsx +130 -0
  63. package/src/components/dashboard/invoice-status-chart/locales/sl.ts +9 -0
  64. package/src/components/dashboard/invoice-status-chart/use-invoice-status.ts +105 -0
  65. package/src/components/dashboard/loading-card.tsx +19 -0
  66. package/src/components/dashboard/payment-methods-chart/index.ts +4 -0
  67. package/src/components/dashboard/payment-methods-chart/locales/sl.ts +12 -0
  68. package/src/components/dashboard/payment-methods-chart/payment-methods-chart.tsx +152 -0
  69. package/src/components/dashboard/payment-methods-chart/use-payment-methods.ts +50 -0
  70. package/src/components/dashboard/payment-trend-chart/index.ts +4 -0
  71. package/src/components/dashboard/payment-trend-chart/locales/sl.ts +5 -0
  72. package/src/components/dashboard/payment-trend-chart/payment-trend-chart.tsx +137 -0
  73. package/src/components/dashboard/payment-trend-chart/use-payment-trend.ts +92 -0
  74. package/src/components/dashboard/revenue-card.tsx +49 -0
  75. package/src/components/dashboard/revenue-trend-chart/index.ts +4 -0
  76. package/src/components/dashboard/revenue-trend-chart/locales/sl.ts +5 -0
  77. package/src/components/dashboard/revenue-trend-chart/revenue-trend-chart.tsx +137 -0
  78. package/src/components/dashboard/revenue-trend-chart/use-revenue-trend.ts +93 -0
  79. package/src/components/dashboard/shared/index.ts +5 -0
  80. package/src/components/dashboard/shared/use-revenue-data.ts +160 -0
  81. package/src/components/dashboard/shared/use-stats-counts.ts +89 -0
  82. package/src/components/dashboard/shared/use-stats-query.ts +38 -0
  83. package/src/components/dashboard/stat-card.tsx +41 -0
  84. package/src/components/dashboard/tax-collected-card/index.ts +2 -0
  85. package/src/components/dashboard/tax-collected-card/tax-collected-card.tsx +77 -0
  86. package/src/components/dashboard/tax-collected-card/use-tax-collected.ts +145 -0
  87. package/src/components/dashboard/top-customers-chart/index.ts +4 -0
  88. package/src/components/dashboard/top-customers-chart/locales/sl.ts +5 -0
  89. package/src/components/dashboard/top-customers-chart/top-customers-chart.tsx +130 -0
  90. package/src/components/dashboard/top-customers-chart/use-top-customers.ts +72 -0
  91. package/src/components/documents/create/document-add-item-form.tsx +379 -0
  92. package/src/components/documents/create/document-add-item-tax-rate-field.tsx +120 -0
  93. package/src/components/documents/create/document-details-section.tsx +597 -0
  94. package/src/components/documents/create/document-items-section.tsx +133 -0
  95. package/src/components/documents/create/document-recipient-section.tsx +101 -0
  96. package/src/components/documents/create/form-types.ts +36 -0
  97. package/src/components/documents/create/index.ts +9 -0
  98. package/src/components/documents/create/live-preview.tsx +235 -0
  99. package/src/components/documents/create/mark-as-paid-section.tsx +82 -0
  100. package/src/components/documents/create/prepare-document-submission.test.ts +132 -0
  101. package/src/components/documents/create/prepare-document-submission.ts +187 -0
  102. package/src/components/documents/create/prepare-preview-data.test.ts +155 -0
  103. package/src/components/documents/create/prepare-preview-data.ts +16 -0
  104. package/src/components/documents/create/smart-code-insert-button.tsx +139 -0
  105. package/src/components/documents/create/use-document-customer-form.ts +161 -0
  106. package/src/components/documents/document-preview.tsx +13 -0
  107. package/src/components/documents/documents.hooks.ts +146 -0
  108. package/src/components/documents/index.ts +23 -0
  109. package/src/components/documents/shared/document-preview-display.tsx +172 -0
  110. package/src/components/documents/shared/index.ts +3 -0
  111. package/src/components/documents/shared/scaled-document-preview.tsx +70 -0
  112. package/src/components/documents/shared/use-a4-scaling.ts +62 -0
  113. package/src/components/documents/types.ts +61 -0
  114. package/src/components/documents/view/document-actions-bar.tsx +328 -0
  115. package/src/components/documents/view/document-details-card.tsx +179 -0
  116. package/src/components/documents/view/document-payments-list.tsx +256 -0
  117. package/src/components/documents/view/index.ts +4 -0
  118. package/src/components/documents/view/locales/de.ts +85 -0
  119. package/src/components/documents/view/locales/sl.ts +84 -0
  120. package/src/components/documents/view/use-document-download.ts +125 -0
  121. package/src/components/entities/create-entity-form.tsx +105 -0
  122. package/src/components/entities/entities.hooks.ts +50 -0
  123. package/src/components/entities/entity-settings-form/email-template-variables-info.tsx +103 -0
  124. package/src/components/entities/entity-settings-form/entity-settings-form.tsx +1326 -0
  125. package/src/components/entities/entity-settings-form/image-upload-with-crop.tsx +222 -0
  126. package/src/components/entities/entity-settings-form/index.ts +2 -0
  127. package/src/components/entities/entity-settings-form/input-with-preview.tsx +190 -0
  128. package/src/components/entities/entity-settings-form/locales/de.ts +192 -0
  129. package/src/components/entities/entity-settings-form/locales/sl.ts +188 -0
  130. package/src/components/entities/furs-settings-form/furs-settings-form.tsx +410 -0
  131. package/src/components/entities/furs-settings-form/furs-settings.hooks.ts +320 -0
  132. package/src/components/entities/furs-settings-form/index.ts +3 -0
  133. package/src/components/entities/furs-settings-form/locales/de.ts +233 -0
  134. package/src/components/entities/furs-settings-form/locales/en.ts +194 -0
  135. package/src/components/entities/furs-settings-form/locales/sl.ts +196 -0
  136. package/src/components/entities/furs-settings-form/sections/certificate-settings-section.tsx +242 -0
  137. package/src/components/entities/furs-settings-form/sections/enable-fiscalization-section.tsx +139 -0
  138. package/src/components/entities/furs-settings-form/sections/general-settings-section.tsx +252 -0
  139. package/src/components/entities/furs-settings-form/sections/premises-management-section.tsx +370 -0
  140. package/src/components/entities/furs-settings-form/sections/register-premise-dialog.tsx +420 -0
  141. package/src/components/entities/keys.ts +2 -0
  142. package/src/components/entities/settings/branding-settings-form.tsx +274 -0
  143. package/src/components/entities/settings/company-settings-form.tsx +256 -0
  144. package/src/components/entities/settings/defaults-settings-form.tsx +501 -0
  145. package/src/components/entities/settings/email-settings-form.tsx +288 -0
  146. package/src/components/entities/settings/eslog-settings-form.tsx +113 -0
  147. package/src/components/entities/settings/index.ts +8 -0
  148. package/src/components/entities/settings/number-format-settings-form.tsx +244 -0
  149. package/src/components/entities/settings/pdf-template-selector/demo-invoice-data.ts +164 -0
  150. package/src/components/entities/settings/pdf-template-selector/index.ts +2 -0
  151. package/src/components/entities/settings/pdf-template-selector/locales/de.ts +18 -0
  152. package/src/components/entities/settings/pdf-template-selector/locales/sl.ts +18 -0
  153. package/src/components/entities/settings/pdf-template-selector/pdf-template-cards.tsx +49 -0
  154. package/src/components/entities/settings/settings-footer.tsx +16 -0
  155. package/src/components/entities/settings/tax-rules-settings-form.tsx +346 -0
  156. package/src/components/estimates/create/create-estimate-form.tsx +384 -0
  157. package/src/components/estimates/create/locales/de.ts +64 -0
  158. package/src/components/estimates/create/locales/sl.ts +63 -0
  159. package/src/components/estimates/create/prepare-estimate-submission.ts +39 -0
  160. package/src/components/estimates/create/use-estimate-customer-form.ts +5 -0
  161. package/src/components/estimates/estimates.hooks.ts +15 -0
  162. package/src/components/estimates/index.ts +6 -0
  163. package/src/components/estimates/list/index.ts +3 -0
  164. package/src/components/estimates/list/list-row-actions.tsx +103 -0
  165. package/src/components/estimates/list/list-table.tsx +171 -0
  166. package/src/components/estimates/list/locales/de.ts +26 -0
  167. package/src/components/estimates/list/locales/sl.ts +26 -0
  168. package/src/components/estimates/list/use-estimate-download.ts +63 -0
  169. package/src/components/export/document-export-form.tsx +288 -0
  170. package/src/components/export/index.ts +2 -0
  171. package/src/components/form/form-input.tsx +89 -0
  172. package/src/components/form/index.ts +1 -0
  173. package/src/components/invoices/create/create-invoice-form.tsx +852 -0
  174. package/src/components/invoices/create/eslog-validation.test.ts +242 -0
  175. package/src/components/invoices/create/eslog-validation.ts +208 -0
  176. package/src/components/invoices/create/locales/de.ts +118 -0
  177. package/src/components/invoices/create/locales/sl.ts +114 -0
  178. package/src/components/invoices/create/prepare-invoice-submission.test.ts +777 -0
  179. package/src/components/invoices/create/prepare-invoice-submission.ts +79 -0
  180. package/src/components/invoices/create/use-invoice-customer-form.ts +5 -0
  181. package/src/components/invoices/index.ts +9 -0
  182. package/src/components/invoices/invoices-furs.hooks.ts +28 -0
  183. package/src/components/invoices/invoices.hooks.ts +110 -0
  184. package/src/components/invoices/list/index.ts +3 -0
  185. package/src/components/invoices/list/list-row-actions.tsx +132 -0
  186. package/src/components/invoices/list/list-table.tsx +165 -0
  187. package/src/components/invoices/list/locales/de.ts +33 -0
  188. package/src/components/invoices/list/locales/sl.ts +33 -0
  189. package/src/components/invoices/list/use-invoice-download.ts +62 -0
  190. package/src/components/invoices/send-email-dialog/index.ts +1 -0
  191. package/src/components/invoices/send-email-dialog/locales/de.ts +18 -0
  192. package/src/components/invoices/send-email-dialog/locales/sl.ts +17 -0
  193. package/src/components/invoices/send-email-dialog/send-email-dialog.tsx +289 -0
  194. package/src/components/invoices/send-email-dialog.tsx +2 -0
  195. package/src/components/invoices/shared/index.ts +2 -0
  196. package/src/components/invoices/shared/scaled-document-preview.tsx +32 -0
  197. package/src/components/invoices/shared/use-a4-scaling.tsx +39 -0
  198. package/src/components/invoices/view/eslog-info-display.tsx +160 -0
  199. package/src/components/invoices/view/furs-info-display.tsx +213 -0
  200. package/src/components/items/create-item-form/create-item-form.tsx +155 -0
  201. package/src/components/items/create-item-form/locales/de.ts +14 -0
  202. package/src/components/items/create-item-form/locales/en.ts +9 -0
  203. package/src/components/items/create-item-form/locales/sl.ts +14 -0
  204. package/src/components/items/item-combobox.tsx +147 -0
  205. package/src/components/items/item-list-table/item-list-header.tsx +33 -0
  206. package/src/components/items/item-list-table/item-list-row-actions.tsx +48 -0
  207. package/src/components/items/item-list-table/item-list-row.tsx +32 -0
  208. package/src/components/items/item-list-table/item-list-table.tsx +76 -0
  209. package/src/components/items/item-list-table/locales/de.ts +10 -0
  210. package/src/components/items/item-list-table/locales/en.ts +10 -0
  211. package/src/components/items/item-list-table/locales/sl.ts +10 -0
  212. package/src/components/items/items.hooks.ts +63 -0
  213. package/src/components/loading-spinner.tsx +24 -0
  214. package/src/components/payments/create-payment-form/create-payment-form.tsx +222 -0
  215. package/src/components/payments/create-payment-form/locales/de.ts +20 -0
  216. package/src/components/payments/create-payment-form/locales/sl.ts +20 -0
  217. package/src/components/payments/edit-payment-form/edit-payment-form.tsx +230 -0
  218. package/src/components/payments/edit-payment-form/index.ts +1 -0
  219. package/src/components/payments/edit-payment-form/locales/de.ts +20 -0
  220. package/src/components/payments/edit-payment-form/locales/sl.ts +20 -0
  221. package/src/components/payments/index.ts +4 -0
  222. package/src/components/payments/list/index.ts +2 -0
  223. package/src/components/payments/list/list-row-actions.tsx +98 -0
  224. package/src/components/payments/list/list-table.tsx +186 -0
  225. package/src/components/payments/list/locales/de.ts +19 -0
  226. package/src/components/payments/list/locales/sl.ts +19 -0
  227. package/src/components/payments/payments.hooks.ts +15 -0
  228. package/src/components/request-logs/index.ts +3 -0
  229. package/src/components/request-logs/request-log-detail.tsx +242 -0
  230. package/src/components/request-logs/request-log-list-table.tsx +266 -0
  231. package/src/components/request-logs/request-logs-page.tsx +10 -0
  232. package/src/components/table/README.md +410 -0
  233. package/src/components/table/data-table.tsx +251 -0
  234. package/src/components/table/date-cell.tsx +35 -0
  235. package/src/components/table/filter-bar.tsx +114 -0
  236. package/src/components/table/filter-panel.tsx +407 -0
  237. package/src/components/table/hooks/use-table-fetch.ts +17 -0
  238. package/src/components/table/hooks/use-table-query.ts +36 -0
  239. package/src/components/table/hooks/use-table-state.ts +293 -0
  240. package/src/components/table/index.ts +35 -0
  241. package/src/components/table/search-input.tsx +85 -0
  242. package/src/components/table/sortable-header.tsx +56 -0
  243. package/src/components/table/table-empty-state.tsx +40 -0
  244. package/src/components/table/table-no-results.tsx +41 -0
  245. package/src/components/table/table-pagination.tsx +42 -0
  246. package/src/components/table/table-skeleton.tsx +54 -0
  247. package/src/components/table/types.ts +136 -0
  248. package/src/components/tax-reports/index.ts +1 -0
  249. package/src/components/tax-reports/kir-export-form.tsx +172 -0
  250. package/src/components/taxes/create-tax-form/create-tax-form.tsx +112 -0
  251. package/src/components/taxes/create-tax-form/locales/de.ts +8 -0
  252. package/src/components/taxes/create-tax-form/locales/en.ts +7 -0
  253. package/src/components/taxes/create-tax-form/locales/sl.ts +8 -0
  254. package/src/components/taxes/tax-list-table/locales/de.ts +11 -0
  255. package/src/components/taxes/tax-list-table/locales/en.ts +10 -0
  256. package/src/components/taxes/tax-list-table/locales/sl.ts +11 -0
  257. package/src/components/taxes/tax-list-table/tax-list-header.tsx +29 -0
  258. package/src/components/taxes/tax-list-table/tax-list-row-actions.tsx +43 -0
  259. package/src/components/taxes/tax-list-table/tax-list-row.tsx +46 -0
  260. package/src/components/taxes/tax-list-table/tax-list-table.tsx +59 -0
  261. package/src/components/taxes/taxes.hooks.ts +35 -0
  262. package/src/components/ui/alert-dialog.tsx +61 -0
  263. package/src/components/ui/alert.tsx +72 -0
  264. package/src/components/ui/badge.tsx +48 -0
  265. package/src/components/ui/breadcrumb.tsx +132 -0
  266. package/src/components/ui/button.tsx +61 -0
  267. package/src/components/ui/calendar.tsx +213 -0
  268. package/src/components/ui/card.tsx +94 -0
  269. package/src/components/ui/chart.tsx +380 -0
  270. package/src/components/ui/checkbox.tsx +27 -0
  271. package/src/components/ui/collapsible.tsx +56 -0
  272. package/src/components/ui/command.tsx +187 -0
  273. package/src/components/ui/dialog.tsx +187 -0
  274. package/src/components/ui/drawer.tsx +123 -0
  275. package/src/components/ui/dropdown-menu.tsx +291 -0
  276. package/src/components/ui/form.tsx +166 -0
  277. package/src/components/ui/input-group.tsx +149 -0
  278. package/src/components/ui/input.tsx +20 -0
  279. package/src/components/ui/label.tsx +18 -0
  280. package/src/components/ui/loading-spinner.tsx +16 -0
  281. package/src/components/ui/popover.tsx +108 -0
  282. package/src/components/ui/radio-group.tsx +37 -0
  283. package/src/components/ui/select.tsx +200 -0
  284. package/src/components/ui/separator.tsx +23 -0
  285. package/src/components/ui/sheet.tsx +145 -0
  286. package/src/components/ui/sidebar.tsx +771 -0
  287. package/src/components/ui/skeleton.tsx +13 -0
  288. package/src/components/ui/sonner.tsx +60 -0
  289. package/src/components/ui/spinner.tsx +10 -0
  290. package/src/components/ui/sticky-form-footer.tsx +55 -0
  291. package/src/components/ui/switch.tsx +30 -0
  292. package/src/components/ui/table.tsx +101 -0
  293. package/src/components/ui/tabs.tsx +80 -0
  294. package/src/components/ui/textarea.tsx +18 -0
  295. package/src/components/ui/tooltip.tsx +89 -0
  296. package/src/components/wl-subscription/index.ts +2 -0
  297. package/src/components/wl-subscription/locked-feature.tsx +173 -0
  298. package/src/components/wl-subscription/upgrade-modal.tsx +209 -0
  299. package/src/frontend.tsx +28 -0
  300. package/src/generate-schemas.ts +265 -0
  301. package/src/generated/schemas/advanceinvoice.ts +177 -0
  302. package/src/generated/schemas/creditnote.ts +187 -0
  303. package/src/generated/schemas/customer.ts +29 -0
  304. package/src/generated/schemas/entity.ts +252 -0
  305. package/src/generated/schemas/estimate.ts +159 -0
  306. package/src/generated/schemas/furssettings.ts +25 -0
  307. package/src/generated/schemas/index.ts +24 -0
  308. package/src/generated/schemas/invoice.ts +167 -0
  309. package/src/generated/schemas/item.ts +38 -0
  310. package/src/generated/schemas/payment.ts +44 -0
  311. package/src/generated/schemas/previewadvanceinvoice_body.ts +354 -0
  312. package/src/generated/schemas/previewestimate_body.ts +309 -0
  313. package/src/generated/schemas/registerfursmovablepremise_body.ts +22 -0
  314. package/src/generated/schemas/registerfursrealestatepremise_body.ts +32 -0
  315. package/src/generated/schemas/renderdocument_body.ts +594 -0
  316. package/src/generated/schemas/sendemail_body.ts +26 -0
  317. package/src/generated/schemas/startpdfexport_body.ts +20 -0
  318. package/src/generated/schemas/tax.ts +48 -0
  319. package/src/generated/schemas/uploadfile_body.ts +23 -0
  320. package/src/generated/schemas/uploadfurscertificate_body.ts +20 -0
  321. package/src/generated/schemas/userfurssettings.ts +19 -0
  322. package/src/hooks/create-resource-hooks.test.ts +483 -0
  323. package/src/hooks/create-resource-hooks.ts +300 -0
  324. package/src/hooks/use-debounce.ts +12 -0
  325. package/src/hooks/use-duplicate-document.ts +185 -0
  326. package/src/hooks/use-media-query.tsx +19 -0
  327. package/src/hooks/use-mobile.ts +39 -0
  328. package/src/hooks/use-next-document-number.ts +57 -0
  329. package/src/hooks/use-resource-mutation.ts +118 -0
  330. package/src/hooks/use-vies-check.ts +130 -0
  331. package/src/index.css +11 -0
  332. package/src/index.html +13 -0
  333. package/src/index.tsx +12 -0
  334. package/src/lib/auth.ts +4 -0
  335. package/src/lib/browser-cookies.ts +70 -0
  336. package/src/lib/constants.ts +287 -0
  337. package/src/lib/cookies.ts +36 -0
  338. package/src/lib/schemas/advance-invoice.ts +43 -0
  339. package/src/lib/schemas/credit-note.ts +32 -0
  340. package/src/lib/schemas/estimate.ts +31 -0
  341. package/src/lib/schemas/index.ts +18 -0
  342. package/src/lib/schemas/invoice.ts +43 -0
  343. package/src/lib/schemas/shared.ts +79 -0
  344. package/src/lib/translation.ts +38 -0
  345. package/src/lib/utils.ts +6 -0
  346. package/src/providers/entities-context.tsx +41 -0
  347. package/src/providers/entities-provider.tsx +201 -0
  348. package/src/providers/form-footer-context.tsx +72 -0
  349. package/src/providers/sdk-provider.tsx +164 -0
  350. package/src/providers/white-label-provider.tsx +91 -0
  351. package/src/providers/wl-subscription-provider.tsx +277 -0
  352. package/src/utils/string-helpers.ts +111 -0
@@ -0,0 +1,130 @@
1
+ "use client";
2
+
3
+ import { Cell, Pie, PieChart } from "recharts";
4
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/ui/components/ui/card";
5
+ import {
6
+ type ChartConfig,
7
+ ChartContainer,
8
+ ChartLegend,
9
+ ChartLegendContent,
10
+ ChartTooltip,
11
+ ChartTooltipContent,
12
+ } from "@/ui/components/ui/chart";
13
+ import { createTranslation } from "@/ui/lib/translation";
14
+ import { ChartEmptyState } from "../chart-empty-state";
15
+ import { LoadingCard } from "../loading-card";
16
+ import sl from "./locales/sl";
17
+ import { useInvoiceStatusData } from "./use-invoice-status";
18
+
19
+ const translations = { sl } as const;
20
+
21
+ export type InvoiceStatusChartData = {
22
+ paid: number;
23
+ pending: number;
24
+ overdue: number;
25
+ voided: number;
26
+ };
27
+
28
+ type BaseProps = {
29
+ locale?: string;
30
+ t?: (key: string) => string;
31
+ namespace?: string;
32
+ };
33
+
34
+ type DataProps = BaseProps & {
35
+ data: InvoiceStatusChartData;
36
+ entityId?: never;
37
+ };
38
+
39
+ type TurnkeyProps = BaseProps & {
40
+ entityId: string;
41
+ data?: never;
42
+ };
43
+
44
+ export type InvoiceStatusChartProps = DataProps | TurnkeyProps;
45
+
46
+ const COLORS = {
47
+ paid: "var(--chart-2)", // green
48
+ pending: "var(--chart-3)", // yellow
49
+ overdue: "var(--chart-1)", // red
50
+ voided: "var(--chart-4)", // gray
51
+ };
52
+
53
+ export function InvoiceStatusChart(props: InvoiceStatusChartProps) {
54
+ const { locale, t: externalT, namespace } = props;
55
+ const t = createTranslation({ t: externalT, namespace, locale, translations });
56
+
57
+ // Turnkey mode - fetch own data
58
+ const hookResult = useInvoiceStatusData("entityId" in props ? props.entityId : undefined);
59
+
60
+ // Determine data source
61
+ const data = "entityId" in props ? hookResult.data : props.data;
62
+ const isLoading = "entityId" in props ? hookResult.isLoading : false;
63
+
64
+ if (isLoading) {
65
+ return <LoadingCard className="h-[280px]" />;
66
+ }
67
+
68
+ const chartConfig = {
69
+ paid: { label: t("Paid"), color: COLORS.paid },
70
+ pending: { label: t("Pending"), color: COLORS.pending },
71
+ overdue: { label: t("Overdue"), color: COLORS.overdue },
72
+ voided: { label: t("Voided"), color: COLORS.voided },
73
+ } satisfies ChartConfig;
74
+
75
+ const total = data.paid + data.pending + data.overdue + data.voided;
76
+ const hasData = total > 0;
77
+
78
+ // Use actual data or placeholder for empty state
79
+ const chartData = hasData
80
+ ? [
81
+ { name: "paid", value: data.paid, fill: COLORS.paid },
82
+ { name: "pending", value: data.pending, fill: COLORS.pending },
83
+ { name: "overdue", value: data.overdue, fill: COLORS.overdue },
84
+ { name: "voided", value: data.voided, fill: COLORS.voided },
85
+ ].filter((d) => d.value > 0)
86
+ : [
87
+ { name: "paid", value: 40, fill: COLORS.paid },
88
+ { name: "pending", value: 30, fill: COLORS.pending },
89
+ { name: "overdue", value: 20, fill: COLORS.overdue },
90
+ { name: "voided", value: 10, fill: COLORS.voided },
91
+ ];
92
+
93
+ const chartContent = (
94
+ <ChartContainer config={chartConfig} className="mx-auto h-[200px] w-full">
95
+ <PieChart>
96
+ <Pie
97
+ data={chartData}
98
+ dataKey="value"
99
+ nameKey="name"
100
+ cx="50%"
101
+ cy="50%"
102
+ innerRadius={50}
103
+ outerRadius={80}
104
+ paddingAngle={2}
105
+ >
106
+ {chartData.map((entry) => (
107
+ <Cell key={entry.name} fill={entry.fill} />
108
+ ))}
109
+ </Pie>
110
+ <ChartTooltip content={<ChartTooltipContent nameKey="name" formatter={(value) => `${value} invoices`} />} />
111
+ <ChartLegend
112
+ content={<ChartLegendContent nameKey="name" />}
113
+ className="-translate-y-2 flex-wrap gap-2 [&>*]:basis-1/4 [&>*]:justify-center"
114
+ />
115
+ </PieChart>
116
+ </ChartContainer>
117
+ );
118
+
119
+ return (
120
+ <Card>
121
+ <CardHeader>
122
+ <CardTitle>{t("Invoice Status")}</CardTitle>
123
+ <CardDescription>{t("Breakdown of invoices by payment status")}</CardDescription>
124
+ </CardHeader>
125
+ <CardContent>
126
+ {hasData ? chartContent : <ChartEmptyState label={t("No data available")}>{chartContent}</ChartEmptyState>}
127
+ </CardContent>
128
+ </Card>
129
+ );
130
+ }
@@ -0,0 +1,9 @@
1
+ export default {
2
+ "Invoice Status": "Status računov",
3
+ "Breakdown of invoices by payment status": "Razčlenitev računov po statusu plačila",
4
+ Paid: "Plačano",
5
+ Pending: "V čakanju",
6
+ Overdue: "Zapadlo",
7
+ Voided: "Stornirano",
8
+ "No data available": "Ni podatkov",
9
+ } as const;
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Invoice status hook using the entity stats API.
3
+ * Server-side counting by invoice status.
4
+ */
5
+ import type { StatsQueryDataItem } from "@spaceinvoices/js-sdk";
6
+ import { useQueries } from "@tanstack/react-query";
7
+ import { useSDK } from "@/ui/providers/sdk-provider";
8
+ import { STATS_QUERY_CACHE_KEY } from "../shared/use-stats-query";
9
+
10
+ export const INVOICE_STATUS_CACHE_KEY = "dashboard-invoice-status";
11
+
12
+ export type InvoiceStatusData = {
13
+ paid: number;
14
+ pending: number;
15
+ overdue: number;
16
+ voided: number;
17
+ };
18
+
19
+ export function useInvoiceStatusData(entityId: string | undefined) {
20
+ const { sdk } = useSDK();
21
+
22
+ const queries = useQueries({
23
+ queries: [
24
+ // Paid invoices
25
+ {
26
+ queryKey: [STATS_QUERY_CACHE_KEY, entityId, "invoice-status-paid"],
27
+ queryFn: async () => {
28
+ if (!entityId || !sdk) throw new Error("Missing entity or SDK");
29
+ return sdk.entityStats.queryEntityStats(
30
+ {
31
+ metrics: [{ type: "count", alias: "count" }],
32
+ table: "invoices",
33
+ filters: { is_draft: false, voided_at: null, paid_in_full: true },
34
+ },
35
+ { entity_id: entityId },
36
+ );
37
+ },
38
+ enabled: !!entityId && !!sdk,
39
+ staleTime: 30_000,
40
+ },
41
+ // Unpaid invoices grouped by overdue bucket (current = pending, others = overdue)
42
+ {
43
+ queryKey: [STATS_QUERY_CACHE_KEY, entityId, "invoice-status-unpaid"],
44
+ queryFn: async () => {
45
+ if (!entityId || !sdk) throw new Error("Missing entity or SDK");
46
+ return sdk.entityStats.queryEntityStats(
47
+ {
48
+ metrics: [{ type: "count", alias: "count" }],
49
+ table: "invoices",
50
+ filters: { is_draft: false, voided_at: null, paid_in_full: false },
51
+ group_by: ["overdue_bucket"],
52
+ },
53
+ { entity_id: entityId },
54
+ );
55
+ },
56
+ enabled: !!entityId && !!sdk,
57
+ staleTime: 30_000,
58
+ },
59
+ // Total count to derive voided
60
+ {
61
+ queryKey: [STATS_QUERY_CACHE_KEY, entityId, "invoice-status-total"],
62
+ queryFn: async () => {
63
+ if (!entityId || !sdk) throw new Error("Missing entity or SDK");
64
+ return sdk.entityStats.queryEntityStats(
65
+ {
66
+ metrics: [{ type: "count", alias: "count" }],
67
+ table: "invoices",
68
+ filters: { is_draft: false },
69
+ },
70
+ { entity_id: entityId },
71
+ );
72
+ },
73
+ enabled: !!entityId && !!sdk,
74
+ staleTime: 30_000,
75
+ },
76
+ ],
77
+ });
78
+
79
+ const [paidQuery, unpaidQuery, totalQuery] = queries;
80
+
81
+ const paid = Number(paidQuery.data?.data?.[0]?.count) || 0;
82
+
83
+ // Parse unpaid buckets
84
+ const unpaidData = unpaidQuery.data?.data || [];
85
+ let pending = 0;
86
+ let overdue = 0;
87
+ for (const row of unpaidData as StatsQueryDataItem[]) {
88
+ const bucket = String(row.overdue_bucket);
89
+ const count = Number(row.count) || 0;
90
+ if (bucket === "current") {
91
+ pending = count;
92
+ } else {
93
+ overdue += count;
94
+ }
95
+ }
96
+
97
+ // Calculate voided as: total - paid - pending - overdue
98
+ const total = Number(totalQuery.data?.data?.[0]?.count) || 0;
99
+ const voided = Math.max(0, total - paid - pending - overdue);
100
+
101
+ return {
102
+ data: { paid, pending, overdue, voided } as InvoiceStatusData,
103
+ isLoading: queries.some((q) => q.isLoading),
104
+ };
105
+ }
@@ -0,0 +1,19 @@
1
+ import { Card, CardContent, CardHeader } from "@/ui/components/ui/card";
2
+ import { cn } from "@/ui/lib/utils";
3
+
4
+ export type LoadingCardProps = {
5
+ className?: string;
6
+ };
7
+
8
+ export function LoadingCard({ className }: LoadingCardProps) {
9
+ return (
10
+ <Card className={cn(className)}>
11
+ <CardHeader className="pb-2">
12
+ <div className="h-4 w-24 animate-pulse rounded bg-muted" />
13
+ </CardHeader>
14
+ <CardContent>
15
+ <div className="h-8 w-16 animate-pulse rounded bg-muted" />
16
+ </CardContent>
17
+ </Card>
18
+ );
19
+ }
@@ -0,0 +1,4 @@
1
+ export type { PaymentMethodsChartData, PaymentMethodsChartProps } from "./payment-methods-chart";
2
+ export { PaymentMethodsChart } from "./payment-methods-chart";
3
+ export type { PaymentMethodsData } from "./use-payment-methods";
4
+ export { PAYMENT_METHODS_CACHE_KEY, usePaymentMethodsData } from "./use-payment-methods";
@@ -0,0 +1,12 @@
1
+ export default {
2
+ "Payment Methods": "Načini plačila",
3
+ "Breakdown of payments by method": "Razčlenitev plačil po načinu",
4
+ Cash: "Gotovina",
5
+ "Bank Transfer": "Bančno nakazilo",
6
+ Card: "Kartica",
7
+ Check: "Ček",
8
+ "Credit Note": "Dobropis",
9
+ Advance: "Avans",
10
+ Other: "Drugo",
11
+ "No data available": "Ni podatkov",
12
+ } as const;
@@ -0,0 +1,152 @@
1
+ "use client";
2
+
3
+ import { Cell, Pie, PieChart } from "recharts";
4
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/ui/components/ui/card";
5
+ import {
6
+ type ChartConfig,
7
+ ChartContainer,
8
+ ChartLegend,
9
+ ChartLegendContent,
10
+ ChartTooltip,
11
+ ChartTooltipContent,
12
+ } from "@/ui/components/ui/chart";
13
+ import { createTranslation } from "@/ui/lib/translation";
14
+ import { ChartEmptyState } from "../chart-empty-state";
15
+ import { LoadingCard } from "../loading-card";
16
+ import sl from "./locales/sl";
17
+ import { usePaymentMethodsData } from "./use-payment-methods";
18
+
19
+ const translations = { sl } as const;
20
+
21
+ export type PaymentMethodsChartData = { type: string; count: number; amount: number }[];
22
+
23
+ type BaseProps = {
24
+ locale?: string;
25
+ t?: (key: string) => string;
26
+ namespace?: string;
27
+ };
28
+
29
+ type DataProps = BaseProps & {
30
+ data: PaymentMethodsChartData;
31
+ entityId?: never;
32
+ };
33
+
34
+ type TurnkeyProps = BaseProps & {
35
+ entityId: string;
36
+ data?: never;
37
+ };
38
+
39
+ export type PaymentMethodsChartProps = DataProps | TurnkeyProps;
40
+
41
+ const COLORS: Record<string, string> = {
42
+ cash: "var(--chart-1)",
43
+ bank_transfer: "var(--chart-2)",
44
+ card: "var(--chart-3)",
45
+ check: "var(--chart-4)",
46
+ credit_note: "var(--chart-5)",
47
+ advance: "var(--chart-6)",
48
+ other: "var(--chart-7)",
49
+ };
50
+
51
+ const PAYMENT_TYPE_LABELS: Record<string, string> = {
52
+ cash: "Cash",
53
+ bank_transfer: "Bank Transfer",
54
+ card: "Card",
55
+ check: "Check",
56
+ credit_note: "Credit Note",
57
+ advance: "Advance",
58
+ other: "Other",
59
+ };
60
+
61
+ export function PaymentMethodsChart(props: PaymentMethodsChartProps) {
62
+ const { locale, t: externalT, namespace } = props;
63
+ const t = createTranslation({ t: externalT, namespace, locale, translations });
64
+
65
+ // Turnkey mode - fetch own data
66
+ const hookResult = usePaymentMethodsData("entityId" in props ? props.entityId : undefined);
67
+
68
+ // Determine data source
69
+ const data = "entityId" in props ? hookResult.data : props.data;
70
+ const isLoading = "entityId" in props ? hookResult.isLoading : false;
71
+
72
+ if (isLoading) {
73
+ return <LoadingCard className="h-[280px]" />;
74
+ }
75
+
76
+ const hasData = data.length > 0 && data.some((d) => d.amount > 0);
77
+
78
+ // Placeholder data for empty state
79
+ const placeholderData = [
80
+ { name: "cash", value: 35, fill: COLORS.cash },
81
+ { name: "bank_transfer", value: 40, fill: COLORS.bank_transfer },
82
+ { name: "card", value: 20, fill: COLORS.card },
83
+ { name: "other", value: 5, fill: COLORS.other },
84
+ ];
85
+
86
+ const chartData = hasData
87
+ ? data.map((d) => ({
88
+ name: d.type,
89
+ value: d.amount,
90
+ fill: COLORS[d.type] || "var(--chart-5)",
91
+ }))
92
+ : placeholderData;
93
+
94
+ const chartConfig = (hasData ? data : placeholderData).reduce((acc, item) => {
95
+ const type = "type" in item ? item.type : item.name;
96
+ acc[type] = {
97
+ label: t(PAYMENT_TYPE_LABELS[type] || type),
98
+ color: COLORS[type] || "var(--chart-5)",
99
+ };
100
+ return acc;
101
+ }, {} as ChartConfig);
102
+
103
+ const chartContent = (
104
+ <ChartContainer config={chartConfig} className="mx-auto h-[200px] w-full">
105
+ <PieChart>
106
+ <Pie
107
+ data={chartData}
108
+ dataKey="value"
109
+ nameKey="name"
110
+ cx="30%"
111
+ cy="50%"
112
+ innerRadius={40}
113
+ outerRadius={70}
114
+ paddingAngle={2}
115
+ >
116
+ {chartData.map((entry) => (
117
+ <Cell key={entry.name} fill={entry.fill} />
118
+ ))}
119
+ </Pie>
120
+ <ChartTooltip
121
+ content={
122
+ <ChartTooltipContent
123
+ nameKey="name"
124
+ formatter={(value) =>
125
+ new Intl.NumberFormat(locale, { style: "currency", currency: "EUR" }).format(Number(value))
126
+ }
127
+ />
128
+ }
129
+ />
130
+ <ChartLegend
131
+ content={<ChartLegendContent nameKey="name" />}
132
+ layout="vertical"
133
+ verticalAlign="middle"
134
+ align="right"
135
+ className="flex-col gap-1 [&>*]:justify-start"
136
+ />
137
+ </PieChart>
138
+ </ChartContainer>
139
+ );
140
+
141
+ return (
142
+ <Card>
143
+ <CardHeader>
144
+ <CardTitle>{t("Payment Methods")}</CardTitle>
145
+ <CardDescription>{t("Breakdown of payments by method")}</CardDescription>
146
+ </CardHeader>
147
+ <CardContent>
148
+ {hasData ? chartContent : <ChartEmptyState label={t("No data available")}>{chartContent}</ChartEmptyState>}
149
+ </CardContent>
150
+ </Card>
151
+ );
152
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Payment methods hook using the entity stats API.
3
+ * Server-side aggregation by payment type.
4
+ */
5
+ import type { StatsQueryDataItem } from "@spaceinvoices/js-sdk";
6
+ import { useQuery } from "@tanstack/react-query";
7
+ import { useSDK } from "@/ui/providers/sdk-provider";
8
+ import { STATS_QUERY_CACHE_KEY } from "../shared/use-stats-query";
9
+
10
+ export const PAYMENT_METHODS_CACHE_KEY = "dashboard-payment-methods";
11
+
12
+ export type PaymentMethodsData = { type: string; count: number; amount: number }[];
13
+
14
+ export function usePaymentMethodsData(entityId: string | undefined) {
15
+ const { sdk } = useSDK();
16
+
17
+ const query = useQuery({
18
+ queryKey: [STATS_QUERY_CACHE_KEY, entityId, "payment-methods"],
19
+ queryFn: async () => {
20
+ if (!entityId || !sdk) throw new Error("Missing entity or SDK");
21
+ return sdk.entityStats.queryEntityStats(
22
+ {
23
+ metrics: [
24
+ { type: "count", alias: "count" },
25
+ { type: "sum", field: "amount", alias: "amount" },
26
+ ],
27
+ table: "payments",
28
+ group_by: ["type"],
29
+ order_by: [{ field: "amount", direction: "desc" }],
30
+ },
31
+ { entity_id: entityId },
32
+ );
33
+ },
34
+ enabled: !!entityId && !!sdk,
35
+ staleTime: 30_000,
36
+ select: (response) => {
37
+ const data = response.data || [];
38
+ return (data as StatsQueryDataItem[]).map((row) => ({
39
+ type: String(row.type || "other"),
40
+ count: Number(row.count) || 0,
41
+ amount: Number(row.amount) || 0,
42
+ }));
43
+ },
44
+ });
45
+
46
+ return {
47
+ data: query.data || [],
48
+ isLoading: query.isLoading,
49
+ };
50
+ }
@@ -0,0 +1,4 @@
1
+ export type { PaymentTrendChartData, PaymentTrendChartProps } from "./payment-trend-chart";
2
+ export { PaymentTrendChart } from "./payment-trend-chart";
3
+ export type { PaymentTrendData } from "./use-payment-trend";
4
+ export { PAYMENT_TREND_CACHE_KEY, usePaymentTrendData } from "./use-payment-trend";
@@ -0,0 +1,5 @@
1
+ export default {
2
+ "Payment Trend": "Trend plačil",
3
+ "Monthly payments received over the last 6 months": "Mesečna prejeta plačila v zadnjih 6 mesecih",
4
+ "No data available": "Ni podatkov",
5
+ } as const;
@@ -0,0 +1,137 @@
1
+ "use client";
2
+
3
+ import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts";
4
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/ui/components/ui/card";
5
+ import { type ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent } from "@/ui/components/ui/chart";
6
+ import { createTranslation } from "@/ui/lib/translation";
7
+ import { ChartEmptyState } from "../chart-empty-state";
8
+ import { LoadingCard } from "../loading-card";
9
+ import sl from "./locales/sl";
10
+ import { usePaymentTrendData } from "./use-payment-trend";
11
+
12
+ const translations = { sl } as const;
13
+
14
+ export type PaymentTrendChartData = { month: string; amount: number }[];
15
+
16
+ type BaseProps = {
17
+ locale?: string;
18
+ t?: (key: string) => string;
19
+ namespace?: string;
20
+ };
21
+
22
+ type DataProps = BaseProps & {
23
+ data: PaymentTrendChartData;
24
+ currency: string;
25
+ entityId?: never;
26
+ };
27
+
28
+ type TurnkeyProps = BaseProps & {
29
+ entityId: string;
30
+ data?: never;
31
+ currency?: never;
32
+ };
33
+
34
+ export type PaymentTrendChartProps = DataProps | TurnkeyProps;
35
+
36
+ const chartConfig = {
37
+ amount: {
38
+ label: "Payments",
39
+ color: "var(--chart-3)",
40
+ },
41
+ } satisfies ChartConfig;
42
+
43
+ function formatMonth(month: string, locale?: string): string {
44
+ const date = new Date(`${month}-01`);
45
+ return date.toLocaleDateString(locale, { month: "short" });
46
+ }
47
+
48
+ function formatCurrency(value: number, currency: string, locale?: string): string {
49
+ return new Intl.NumberFormat(locale, {
50
+ style: "currency",
51
+ currency,
52
+ minimumFractionDigits: 0,
53
+ maximumFractionDigits: 0,
54
+ }).format(value);
55
+ }
56
+
57
+ export function PaymentTrendChart(props: PaymentTrendChartProps) {
58
+ const { locale, t: externalT, namespace } = props;
59
+ const t = createTranslation({ t: externalT, namespace, locale, translations });
60
+
61
+ // Turnkey mode - fetch own data
62
+ const hookResult = usePaymentTrendData("entityId" in props ? props.entityId : undefined);
63
+
64
+ // Determine data source
65
+ const data = "entityId" in props ? hookResult.data : props.data;
66
+ const currency = "entityId" in props ? hookResult.currency : props.currency;
67
+ const isLoading = "entityId" in props ? hookResult.isLoading : false;
68
+
69
+ if (isLoading) {
70
+ return <LoadingCard className="h-[280px]" />;
71
+ }
72
+
73
+ const hasData = data.some((d) => d.amount > 0);
74
+
75
+ // Placeholder data for empty state
76
+ const placeholderData =
77
+ data.length > 0
78
+ ? data.map((d) => ({ ...d, amount: 100 }))
79
+ : [
80
+ { month: "2024-01", amount: 70 },
81
+ { month: "2024-02", amount: 110 },
82
+ { month: "2024-03", amount: 85 },
83
+ { month: "2024-04", amount: 130 },
84
+ { month: "2024-05", amount: 95 },
85
+ { month: "2024-06", amount: 120 },
86
+ ];
87
+
88
+ const chartContent = (
89
+ <ChartContainer config={chartConfig} className="h-[200px] w-full">
90
+ <AreaChart data={hasData ? data : placeholderData} margin={{ left: 12, right: 12 }}>
91
+ <CartesianGrid vertical={false} strokeDasharray="3 3" />
92
+ <XAxis
93
+ dataKey="month"
94
+ tickLine={false}
95
+ axisLine={false}
96
+ tickMargin={8}
97
+ tickFormatter={(m) => formatMonth(m, locale)}
98
+ />
99
+ <YAxis
100
+ tickLine={false}
101
+ axisLine={false}
102
+ tickMargin={8}
103
+ tickFormatter={(value) => formatCurrency(value, currency, locale)}
104
+ width={80}
105
+ />
106
+ <defs>
107
+ <linearGradient id="fillPayments" x1="0" y1="0" x2="0" y2="1">
108
+ <stop offset="5%" stopColor="var(--chart-3)" stopOpacity={0.8} />
109
+ <stop offset="95%" stopColor="var(--chart-3)" stopOpacity={0.1} />
110
+ </linearGradient>
111
+ </defs>
112
+ <ChartTooltip
113
+ cursor={false}
114
+ content={
115
+ <ChartTooltipContent
116
+ labelFormatter={(label) => formatMonth(label, locale)}
117
+ formatter={(value) => formatCurrency(Number(value), currency, locale)}
118
+ />
119
+ }
120
+ />
121
+ <Area dataKey="amount" type="monotone" fill="url(#fillPayments)" stroke="var(--chart-3)" strokeWidth={2} />
122
+ </AreaChart>
123
+ </ChartContainer>
124
+ );
125
+
126
+ return (
127
+ <Card>
128
+ <CardHeader>
129
+ <CardTitle>{t("Payment Trend")}</CardTitle>
130
+ <CardDescription>{t("Monthly payments received over the last 6 months")}</CardDescription>
131
+ </CardHeader>
132
+ <CardContent>
133
+ {hasData ? chartContent : <ChartEmptyState label={t("No data available")}>{chartContent}</ChartEmptyState>}
134
+ </CardContent>
135
+ </Card>
136
+ );
137
+ }