@spaceinvoices/react-ui 0.4.8 → 0.4.11

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 (276) hide show
  1. package/README.md +24 -8
  2. package/cli/dist/index.js +89 -26
  3. package/package.json +4 -1
  4. package/spaceinvoices.schema.json +6 -1
  5. package/src/common/autocomplete.tsx +69 -6
  6. package/src/components/advance-invoices/create/create-advance-invoice-form.tsx +124 -285
  7. package/src/components/advance-invoices/list/list-table.tsx +10 -3
  8. package/src/components/advance-invoices/list/locales/de.ts +2 -0
  9. package/src/components/advance-invoices/list/locales/en.ts +1 -0
  10. package/src/components/advance-invoices/list/locales/es.ts +1 -0
  11. package/src/components/advance-invoices/list/locales/fr.ts +1 -0
  12. package/src/components/advance-invoices/list/locales/hr.ts +1 -0
  13. package/src/components/advance-invoices/list/locales/it.ts +1 -0
  14. package/src/components/advance-invoices/list/locales/nl.ts +1 -0
  15. package/src/components/advance-invoices/list/locales/pl.ts +1 -0
  16. package/src/components/advance-invoices/list/locales/pt.ts +1 -0
  17. package/src/components/advance-invoices/list/locales/sl.ts +1 -0
  18. package/src/components/advance-invoices/list/use-advance-invoice-download.ts +1 -12
  19. package/src/components/credit-notes/create/create-credit-note-form.tsx +116 -238
  20. package/src/components/credit-notes/list/list-table.tsx +6 -3
  21. package/src/components/credit-notes/list/use-credit-note-download.ts +1 -12
  22. package/src/components/customers/customer-autocomplete.tsx +64 -11
  23. package/src/components/customers/customer-list-table/customer-list-table.tsx +3 -2
  24. package/src/components/dashboard/collection-rate-card/collection-rate-card.tsx +9 -1
  25. package/src/components/dashboard/collection-rate-card/locales/bg.ts +3 -0
  26. package/src/components/dashboard/collection-rate-card/locales/cs.ts +3 -0
  27. package/src/components/dashboard/collection-rate-card/locales/et.ts +3 -0
  28. package/src/components/dashboard/collection-rate-card/locales/fi.ts +3 -0
  29. package/src/components/dashboard/collection-rate-card/locales/is.ts +3 -0
  30. package/src/components/dashboard/collection-rate-card/locales/nb.ts +3 -0
  31. package/src/components/dashboard/collection-rate-card/locales/sk.ts +3 -0
  32. package/src/components/dashboard/collection-rate-card/locales/sv.ts +3 -0
  33. package/src/components/dashboard/invoice-status-chart/invoice-status-chart.tsx +10 -2
  34. package/src/components/dashboard/invoice-status-chart/locales/bg.ts +10 -0
  35. package/src/components/dashboard/invoice-status-chart/locales/cs.ts +10 -0
  36. package/src/components/dashboard/invoice-status-chart/locales/de.ts +1 -0
  37. package/src/components/dashboard/invoice-status-chart/locales/es.ts +1 -0
  38. package/src/components/dashboard/invoice-status-chart/locales/et.ts +10 -0
  39. package/src/components/dashboard/invoice-status-chart/locales/fi.ts +10 -0
  40. package/src/components/dashboard/invoice-status-chart/locales/fr.ts +1 -0
  41. package/src/components/dashboard/invoice-status-chart/locales/hr.ts +1 -0
  42. package/src/components/dashboard/invoice-status-chart/locales/is.ts +10 -0
  43. package/src/components/dashboard/invoice-status-chart/locales/it.ts +1 -0
  44. package/src/components/dashboard/invoice-status-chart/locales/nb.ts +10 -0
  45. package/src/components/dashboard/invoice-status-chart/locales/nl.ts +1 -0
  46. package/src/components/dashboard/invoice-status-chart/locales/pl.ts +1 -0
  47. package/src/components/dashboard/invoice-status-chart/locales/pt.ts +1 -0
  48. package/src/components/dashboard/invoice-status-chart/locales/sk.ts +10 -0
  49. package/src/components/dashboard/invoice-status-chart/locales/sl.ts +1 -0
  50. package/src/components/dashboard/invoice-status-chart/locales/sv.ts +10 -0
  51. package/src/components/dashboard/payment-methods-chart/locales/bg.ts +12 -0
  52. package/src/components/dashboard/payment-methods-chart/locales/cs.ts +12 -0
  53. package/src/components/dashboard/payment-methods-chart/locales/et.ts +12 -0
  54. package/src/components/dashboard/payment-methods-chart/locales/fi.ts +12 -0
  55. package/src/components/dashboard/payment-methods-chart/locales/is.ts +12 -0
  56. package/src/components/dashboard/payment-methods-chart/locales/nb.ts +12 -0
  57. package/src/components/dashboard/payment-methods-chart/locales/sk.ts +12 -0
  58. package/src/components/dashboard/payment-methods-chart/locales/sv.ts +12 -0
  59. package/src/components/dashboard/payment-methods-chart/payment-methods-chart.tsx +9 -1
  60. package/src/components/dashboard/payment-trend-chart/locales/bg.ts +6 -0
  61. package/src/components/dashboard/payment-trend-chart/locales/cs.ts +6 -0
  62. package/src/components/dashboard/payment-trend-chart/locales/de.ts +1 -0
  63. package/src/components/dashboard/payment-trend-chart/locales/es.ts +1 -0
  64. package/src/components/dashboard/payment-trend-chart/locales/et.ts +6 -0
  65. package/src/components/dashboard/payment-trend-chart/locales/fi.ts +6 -0
  66. package/src/components/dashboard/payment-trend-chart/locales/fr.ts +1 -0
  67. package/src/components/dashboard/payment-trend-chart/locales/hr.ts +1 -0
  68. package/src/components/dashboard/payment-trend-chart/locales/is.ts +6 -0
  69. package/src/components/dashboard/payment-trend-chart/locales/it.ts +1 -0
  70. package/src/components/dashboard/payment-trend-chart/locales/nb.ts +6 -0
  71. package/src/components/dashboard/payment-trend-chart/locales/nl.ts +1 -0
  72. package/src/components/dashboard/payment-trend-chart/locales/pl.ts +1 -0
  73. package/src/components/dashboard/payment-trend-chart/locales/pt.ts +1 -0
  74. package/src/components/dashboard/payment-trend-chart/locales/sk.ts +6 -0
  75. package/src/components/dashboard/payment-trend-chart/locales/sl.ts +1 -0
  76. package/src/components/dashboard/payment-trend-chart/locales/sv.ts +6 -0
  77. package/src/components/dashboard/payment-trend-chart/payment-trend-chart.tsx +15 -8
  78. package/src/components/dashboard/revenue-trend-chart/locales/bg.ts +6 -0
  79. package/src/components/dashboard/revenue-trend-chart/locales/cs.ts +6 -0
  80. package/src/components/dashboard/revenue-trend-chart/locales/de.ts +1 -0
  81. package/src/components/dashboard/revenue-trend-chart/locales/es.ts +1 -0
  82. package/src/components/dashboard/revenue-trend-chart/locales/et.ts +6 -0
  83. package/src/components/dashboard/revenue-trend-chart/locales/fi.ts +6 -0
  84. package/src/components/dashboard/revenue-trend-chart/locales/fr.ts +1 -0
  85. package/src/components/dashboard/revenue-trend-chart/locales/hr.ts +1 -0
  86. package/src/components/dashboard/revenue-trend-chart/locales/is.ts +6 -0
  87. package/src/components/dashboard/revenue-trend-chart/locales/it.ts +1 -0
  88. package/src/components/dashboard/revenue-trend-chart/locales/nb.ts +6 -0
  89. package/src/components/dashboard/revenue-trend-chart/locales/nl.ts +1 -0
  90. package/src/components/dashboard/revenue-trend-chart/locales/pl.ts +1 -0
  91. package/src/components/dashboard/revenue-trend-chart/locales/pt.ts +1 -0
  92. package/src/components/dashboard/revenue-trend-chart/locales/sk.ts +6 -0
  93. package/src/components/dashboard/revenue-trend-chart/locales/sl.ts +1 -0
  94. package/src/components/dashboard/revenue-trend-chart/locales/sv.ts +6 -0
  95. package/src/components/dashboard/revenue-trend-chart/revenue-trend-chart.tsx +15 -8
  96. package/src/components/dashboard/tax-collected-card/locales.ts +110 -0
  97. package/src/components/dashboard/tax-collected-card/tax-collected-card.tsx +8 -2
  98. package/src/components/dashboard/tax-collected-card/use-tax-collected.ts +4 -4
  99. package/src/components/dashboard/top-customers-chart/locales/bg.ts +7 -0
  100. package/src/components/dashboard/top-customers-chart/locales/cs.ts +7 -0
  101. package/src/components/dashboard/top-customers-chart/locales/de.ts +2 -0
  102. package/src/components/dashboard/top-customers-chart/locales/es.ts +2 -0
  103. package/src/components/dashboard/top-customers-chart/locales/et.ts +7 -0
  104. package/src/components/dashboard/top-customers-chart/locales/fi.ts +7 -0
  105. package/src/components/dashboard/top-customers-chart/locales/fr.ts +2 -0
  106. package/src/components/dashboard/top-customers-chart/locales/hr.ts +2 -0
  107. package/src/components/dashboard/top-customers-chart/locales/is.ts +7 -0
  108. package/src/components/dashboard/top-customers-chart/locales/it.ts +2 -0
  109. package/src/components/dashboard/top-customers-chart/locales/nb.ts +7 -0
  110. package/src/components/dashboard/top-customers-chart/locales/nl.ts +2 -0
  111. package/src/components/dashboard/top-customers-chart/locales/pl.ts +2 -0
  112. package/src/components/dashboard/top-customers-chart/locales/pt.ts +2 -0
  113. package/src/components/dashboard/top-customers-chart/locales/sk.ts +7 -0
  114. package/src/components/dashboard/top-customers-chart/locales/sl.ts +2 -0
  115. package/src/components/dashboard/top-customers-chart/locales/sv.ts +7 -0
  116. package/src/components/dashboard/top-customers-chart/top-customers-chart.tsx +23 -12
  117. package/src/components/delivery-notes/create/create-delivery-note-form.tsx +33 -20
  118. package/src/components/delivery-notes/list/list-table.tsx +22 -13
  119. package/src/components/delivery-notes/list/locales/de.ts +2 -0
  120. package/src/components/delivery-notes/list/locales/en.ts +1 -0
  121. package/src/components/delivery-notes/list/locales/es.ts +1 -0
  122. package/src/components/delivery-notes/list/locales/fr.ts +1 -0
  123. package/src/components/delivery-notes/list/locales/hr.ts +1 -0
  124. package/src/components/delivery-notes/list/locales/it.ts +1 -0
  125. package/src/components/delivery-notes/list/locales/nl.ts +1 -0
  126. package/src/components/delivery-notes/list/locales/pl.ts +1 -0
  127. package/src/components/delivery-notes/list/locales/pt.ts +1 -0
  128. package/src/components/delivery-notes/list/locales/sl.ts +1 -0
  129. package/src/components/delivery-notes/list/use-delivery-note-download.ts +1 -12
  130. package/src/components/documents/create/document-add-item-form.tsx +28 -16
  131. package/src/components/documents/create/document-add-item-tax-rate-field.tsx +12 -2
  132. package/src/components/documents/create/document-items-section.tsx +70 -39
  133. package/src/components/documents/create/document-recipient-section.tsx +10 -1
  134. package/src/components/documents/create/live-preview.tsx +113 -15
  135. package/src/components/documents/create/prepare-document-submission.ts +35 -16
  136. package/src/components/documents/create/use-document-customer-form.ts +14 -3
  137. package/src/components/documents/documents.hooks.ts +7 -2
  138. package/src/components/documents/shared/document-preview-display.tsx +136 -67
  139. package/src/components/documents/shared/scaled-document-preview.tsx +45 -5
  140. package/src/components/documents/view/document-actions-bar.tsx +284 -182
  141. package/src/components/documents/view/document-activities-list.tsx +3 -0
  142. package/src/components/documents/view/document-payments-list.tsx +3 -0
  143. package/src/components/documents/view/locales/de.ts +8 -0
  144. package/src/components/documents/view/locales/es.ts +8 -0
  145. package/src/components/documents/view/locales/fr.ts +8 -0
  146. package/src/components/documents/view/locales/hr.ts +8 -0
  147. package/src/components/documents/view/locales/it.ts +8 -0
  148. package/src/components/documents/view/locales/nl.ts +8 -0
  149. package/src/components/documents/view/locales/pl.ts +8 -0
  150. package/src/components/documents/view/locales/pt.ts +8 -0
  151. package/src/components/documents/view/locales/sl.ts +8 -0
  152. package/src/components/documents/view/use-document-download.ts +14 -25
  153. package/src/components/entities/create-entity-form.tsx +101 -16
  154. package/src/components/entities/entity-settings-form/entity-settings-form.tsx +10 -10
  155. package/src/components/entities/entity-settings-form/locales/de.ts +10 -0
  156. package/src/components/entities/entity-settings-form/locales/es.ts +10 -0
  157. package/src/components/entities/entity-settings-form/locales/fr.ts +10 -0
  158. package/src/components/entities/entity-settings-form/locales/hr.ts +10 -0
  159. package/src/components/entities/entity-settings-form/locales/it.ts +10 -0
  160. package/src/components/entities/entity-settings-form/locales/nl.ts +10 -0
  161. package/src/components/entities/entity-settings-form/locales/pl.ts +10 -0
  162. package/src/components/entities/entity-settings-form/locales/pt.ts +10 -0
  163. package/src/components/entities/entity-settings-form/locales/sl.ts +10 -0
  164. package/src/components/entities/fina-settings-form/fina-operator-required-dialog.tsx +3 -3
  165. package/src/components/entities/fina-settings-form/fina-settings-form.tsx +78 -124
  166. package/src/components/entities/fina-settings-form/sections/certificate-settings-section.tsx +8 -1
  167. package/src/components/entities/fina-settings-form/sections/premises-management-section.tsx +14 -2
  168. package/src/components/entities/fina-settings-form/sections/register-premise-dialog.tsx +7 -2
  169. package/src/components/entities/furs-settings-form/furs-settings-form.tsx +56 -130
  170. package/src/components/entities/furs-settings-form/sections/certificate-settings-section.tsx +8 -1
  171. package/src/components/entities/furs-settings-form/sections/enable-fiscalization-section.tsx +1 -0
  172. package/src/components/entities/furs-settings-form/sections/general-settings-section.tsx +15 -2
  173. package/src/components/entities/furs-settings-form/sections/premises-management-section.tsx +20 -3
  174. package/src/components/entities/furs-settings-form/sections/register-premise-dialog.tsx +38 -12
  175. package/src/components/entities/settings/defaults-settings-form.tsx +6 -6
  176. package/src/components/entities/settings/eslog-settings-form.tsx +13 -1
  177. package/src/components/entities/settings/pdf-template-selector/demo-invoice-data.ts +3 -22
  178. package/src/components/entities/shared/fiscalization-step-flow.ts +77 -0
  179. package/src/components/entities/shared/fiscalization-step-tabs.tsx +71 -0
  180. package/src/components/estimates/create/create-estimate-form.tsx +34 -21
  181. package/src/components/estimates/list/list-table.tsx +23 -14
  182. package/src/components/estimates/list/locales/de.ts +2 -0
  183. package/src/components/estimates/list/locales/en.ts +1 -0
  184. package/src/components/estimates/list/locales/es.ts +1 -0
  185. package/src/components/estimates/list/locales/fr.ts +1 -0
  186. package/src/components/estimates/list/locales/hr.ts +1 -0
  187. package/src/components/estimates/list/locales/it.ts +1 -0
  188. package/src/components/estimates/list/locales/nl.ts +1 -0
  189. package/src/components/estimates/list/locales/pl.ts +1 -0
  190. package/src/components/estimates/list/locales/pt.ts +1 -0
  191. package/src/components/estimates/list/locales/sl.ts +1 -0
  192. package/src/components/estimates/list/use-estimate-download.ts +1 -12
  193. package/src/components/export/document-export-form.tsx +33 -7
  194. package/src/components/export/sales-per-item-export-form.tsx +23 -7
  195. package/src/components/invoices/create/create-invoice-form.tsx +295 -329
  196. package/src/components/invoices/create/prepare-invoice-submission.ts +0 -8
  197. package/src/components/invoices/list/list-table.tsx +7 -4
  198. package/src/components/invoices/list/use-invoice-download.ts +1 -11
  199. package/src/components/invoices/send-email-dialog/locales/de.ts +20 -0
  200. package/src/components/invoices/send-email-dialog/locales/es.ts +20 -0
  201. package/src/components/invoices/send-email-dialog/locales/fr.ts +20 -0
  202. package/src/components/invoices/send-email-dialog/locales/hr.ts +20 -0
  203. package/src/components/invoices/send-email-dialog/locales/it.ts +20 -0
  204. package/src/components/invoices/send-email-dialog/locales/nl.ts +20 -0
  205. package/src/components/invoices/send-email-dialog/locales/pl.ts +20 -0
  206. package/src/components/invoices/send-email-dialog/locales/pt.ts +20 -0
  207. package/src/components/invoices/send-email-dialog/locales/sl.ts +20 -0
  208. package/src/components/invoices/send-email-dialog/send-email-dialog.tsx +77 -8
  209. package/src/components/invoices/view/eslog-info-display.tsx +17 -1
  210. package/src/components/invoices/view/fiscalization-status-card.tsx +7 -3
  211. package/src/components/items/item-combobox.tsx +26 -6
  212. package/src/components/items/item-list-table/item-list-table.tsx +5 -2
  213. package/src/components/payments/create-payment-form/index.ts +1 -0
  214. package/src/components/payments/list/list-table.tsx +14 -4
  215. package/src/components/recurring-invoices/list/list-table.tsx +7 -4
  216. package/src/components/request-logs/locales.ts +412 -0
  217. package/src/components/request-logs/request-log-detail.tsx +37 -21
  218. package/src/components/request-logs/request-log-list-table.tsx +57 -11
  219. package/src/components/table/data-table.tsx +5 -2
  220. package/src/components/table/date-cell.tsx +3 -1
  221. package/src/components/table/filter-bar.tsx +14 -2
  222. package/src/components/table/hooks/use-table-query.ts +1 -1
  223. package/src/components/table/locales.ts +1116 -0
  224. package/src/components/table/search-input.tsx +12 -3
  225. package/src/components/table/selection-toolbar.tsx +23 -6
  226. package/src/components/table/table-empty-state.tsx +43 -3
  227. package/src/components/table/table-no-results.tsx +3 -3
  228. package/src/components/table/table-pagination.tsx +4 -3
  229. package/src/components/table/types.ts +1 -0
  230. package/src/components/tax-reports/index.ts +1 -0
  231. package/src/components/tax-reports/kir-export-form.tsx +46 -8
  232. package/src/components/tax-reports/slovenia-tax-profile-step.tsx +191 -0
  233. package/src/components/tax-reports/slovenia-yearly-export-form.tsx +509 -0
  234. package/src/components/tax-reports/slovenia-yearly-review-step.tsx +253 -0
  235. package/src/components/tax-reports/slovenia-yearly-summary.tsx +19 -0
  236. package/src/components/taxes/tax-list-table/tax-list-table.tsx +3 -2
  237. package/src/components/ui/sidebar.tsx +3 -2
  238. package/src/components/ui/sticky-form-footer.tsx +7 -1
  239. package/src/components/webhook-logs/index.ts +6 -0
  240. package/src/components/webhook-logs/locales.ts +392 -0
  241. package/src/components/webhook-logs/webhook-delivery-detail.tsx +255 -0
  242. package/src/components/webhook-logs/webhook-delivery-list-table.tsx +278 -0
  243. package/src/components/wl-subscription/index.ts +1 -0
  244. package/src/components/wl-subscription/locked-feature.tsx +1 -0
  245. package/src/components/wl-subscription/paywall.tsx +193 -0
  246. package/src/components/wl-subscription/upgrade-modal.tsx +93 -29
  247. package/src/generate-schemas.ts +12 -7
  248. package/src/generated/schemas/customer.ts +2 -0
  249. package/src/generated/schemas/entity.ts +134 -0
  250. package/src/generated/schemas/exportsloveniayearlynormiranireport_body.ts +27 -0
  251. package/src/generated/schemas/index.ts +2 -0
  252. package/src/generated/schemas/me.ts +20 -1
  253. package/src/generated/schemas/renderadvanceinvoicepreview_body.ts +40 -34
  254. package/src/generated/schemas/rendercreditnotepreview_body.ts +42 -36
  255. package/src/generated/schemas/renderdeliverynotepreview_body.ts +23 -13
  256. package/src/generated/schemas/renderestimatepreview_body.ts +23 -13
  257. package/src/generated/schemas/renderinvoicepreview_body.ts +40 -34
  258. package/src/generated/schemas/sendemail_body.ts +44 -0
  259. package/src/generated/schemas/sloveniataxprofile.ts +42 -0
  260. package/src/generated/schemas/startpdfexport_body.ts +91 -1
  261. package/src/generated/schemas/webhook.ts +10 -0
  262. package/src/hooks/use-duplicate-document.ts +51 -13
  263. package/src/hooks/use-eslog-validation.ts +59 -0
  264. package/src/hooks/use-premise-selection.ts +186 -0
  265. package/src/lib/browser-cookies.ts +4 -4
  266. package/src/lib/date-fns-locale.ts +48 -0
  267. package/src/lib/fiscalization-options.ts +81 -0
  268. package/src/lib/locale.ts +38 -0
  269. package/src/lib/template-variables.tsx +1 -1
  270. package/src/lib/translation.ts +14 -3
  271. package/src/providers/entities-context.tsx +1 -0
  272. package/src/providers/entities-provider.tsx +102 -3
  273. package/src/providers/form-footer-context.tsx +37 -4
  274. package/src/providers/sdk-provider.tsx +7 -2
  275. package/src/providers/white-label-provider.tsx +4 -1
  276. package/src/providers/wl-subscription-provider.tsx +90 -3
@@ -122,6 +122,14 @@ export default {
122
122
  Dutch: "Neerlandês",
123
123
  Polish: "Polaco",
124
124
  Croatian: "Croata",
125
+ Swedish: "Sueco",
126
+ Finnish: "Finlandês",
127
+ Estonian: "Estónio",
128
+ Bulgarian: "Búlgaro",
129
+ Czech: "Checo",
130
+ Slovak: "Eslovaco",
131
+ Norwegian: "Norueguês",
132
+ Icelandic: "Islandês",
125
133
 
126
134
  // Linked documents
127
135
  "Linked documents": "Documentos vinculados",
@@ -123,6 +123,14 @@ export default {
123
123
  Dutch: "Nizozemščina",
124
124
  Polish: "Poljščina",
125
125
  Croatian: "Hrvaščina",
126
+ Swedish: "Švedščina",
127
+ Finnish: "Finščina",
128
+ Estonian: "Estonščina",
129
+ Bulgarian: "Bolgarščina",
130
+ Czech: "Češčina",
131
+ Slovak: "Slovaščina",
132
+ Norwegian: "Norveščina",
133
+ Icelandic: "Islandščina",
126
134
 
127
135
  // Linked documents
128
136
  "Linked documents": "Povezani dokumenti",
@@ -1,4 +1,11 @@
1
- import type { AdvanceInvoice, CreditNote, DeliveryNote, Estimate, Invoice } from "@spaceinvoices/js-sdk";
1
+ import {
2
+ type AdvanceInvoice,
3
+ type CreditNote,
4
+ type DeliveryNote,
5
+ downloadBlob,
6
+ type Estimate,
7
+ type Invoice,
8
+ } from "@spaceinvoices/js-sdk";
2
9
  import { useState } from "react";
3
10
  import { useEntities } from "@/ui/providers/entities-context";
4
11
  import { useSDK } from "@/ui/providers/sdk-provider";
@@ -36,11 +43,10 @@ export function useDocumentDownload({
36
43
  const [isDownloadingEslog, setIsDownloadingEslog] = useState(false);
37
44
 
38
45
  /**
39
- * Download PDF with optional language override for translations
40
- * Formatting (decimal separators, dates) always uses entity locale.
41
- * The language param only changes labels/translations on the PDF.
46
+ * Download PDF with optional locale override.
47
+ * When a locale is selected, it is sent as both the formatting locale and label language.
42
48
  */
43
- const downloadPdf = async (document: Document, documentType: DocumentType, language?: string) => {
49
+ const downloadPdf = async (document: Document, documentType: DocumentType, locale?: string) => {
44
50
  if (!sdk || !activeEntity?.id) {
45
51
  onDownloadError?.("Download failed");
46
52
  return;
@@ -53,21 +59,11 @@ export function useDocumentDownload({
53
59
  // SDK signature: renderPdf(id, params?, SDKMethodOptions?)
54
60
  // entity_id goes in SDKMethodOptions (last arg), not params
55
61
  // Note: renderPdf is on invoices module but works with any document ID via /documents/{id}/pdf
56
- // Don't send locale entity locale drives formatting. Send language for translation override.
57
- const params = language ? { language } : {};
58
- const blob = await sdk.invoices.renderPdf(document.id, params, { entity_id: activeEntity.id });
59
- const downloadUrl = window.URL.createObjectURL(blob);
60
- const link = window.document.createElement("a");
61
- link.href = downloadUrl;
62
-
62
+ const params = locale ? { locale, language: locale } : {};
63
63
  const typeLabel = TYPE_LABELS[documentType] || "Document";
64
64
  const fileName = `${typeLabel} ${document.number}.pdf`;
65
- link.download = fileName;
66
65
 
67
- window.document.body.appendChild(link);
68
- link.click();
69
- window.document.body.removeChild(link);
70
- window.URL.revokeObjectURL(downloadUrl);
66
+ await sdk.invoices.downloadPdf(document.id, fileName, params, { entity_id: activeEntity.id });
71
67
 
72
68
  onDownloadSuccess?.(fileName);
73
69
  } catch (error) {
@@ -106,14 +102,7 @@ export function useDocumentDownload({
106
102
  const xml = await eSlogModule.download(document.id, typeMap[documentType], { entity_id: activeEntity.id });
107
103
 
108
104
  const blob = new Blob([xml], { type: "application/xml" });
109
- const url = window.URL.createObjectURL(blob);
110
- const a = window.document.createElement("a");
111
- a.href = url;
112
- a.download = `${document.number}.xml`;
113
- window.document.body.appendChild(a);
114
- a.click();
115
- window.URL.revokeObjectURL(url);
116
- window.document.body.removeChild(a);
105
+ downloadBlob(blob, `${document.number}.xml`);
117
106
  } catch (error) {
118
107
  console.error("Error downloading e-SLOG:", error);
119
108
  onDownloadError?.("e-SLOG download failed");
@@ -10,6 +10,7 @@ import { Button } from "@/ui/components/ui/button";
10
10
  import { Checkbox } from "@/ui/components/ui/checkbox";
11
11
  import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/ui/components/ui/form";
12
12
  import { type CreateEntitySchema, createEntitySchema } from "@/ui/generated/schemas";
13
+ import { createTranslation } from "@/ui/lib/translation";
13
14
 
14
15
  import ButtonLoader from "../button-loader";
15
16
  import { useCreateEntity } from "./entities.hooks";
@@ -27,10 +28,85 @@ export type CreateEntityFormProps = {
27
28
  onError?: (error: unknown) => void;
28
29
  };
29
30
 
30
- const defaultTranslate = (text: string) => text;
31
+ const translations = {
32
+ en: {
33
+ name: "Name",
34
+ "search-hint": "Search companies by name",
35
+ "no-results": "No companies found",
36
+ country: "Country",
37
+ address: "Address",
38
+ "address-2": "Address 2",
39
+ "post-code": "Post Code",
40
+ city: "City",
41
+ state: "State",
42
+ "tax-number": "Tax Number",
43
+ "is-tax-subject": "Tax subject",
44
+ "company-number": "Company Number",
45
+ submit: "Create entity",
46
+ },
47
+ } as const;
48
+
49
+ const ISO_COUNTRY_CODES = [
50
+ "AD", "AE", "AF", "AG", "AL", "AM", "AO", "AR", "AT", "AU", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI",
51
+ "BJ", "BN", "BO", "BR", "BS", "BT", "BW", "BY", "BZ", "CA", "CD", "CF", "CG", "CH", "CI", "CL", "CM", "CN", "CO",
52
+ "CR", "CU", "CV", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "ER", "ES", "ET", "FI", "FJ",
53
+ "FM", "FR", "GA", "GB", "GD", "GE", "GH", "GM", "GN", "GQ", "GR", "GT", "GW", "GY", "HK", "HN", "HR", "HT", "HU",
54
+ "ID", "IE", "IL", "IN", "IQ", "IR", "IS", "IT", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KP", "KR",
55
+ "KW", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MG", "MH",
56
+ "MK", "ML", "MM", "MN", "MR", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NE", "NG", "NI", "NL", "NO", "NP",
57
+ "NR", "NZ", "OM", "PA", "PE", "PG", "PH", "PK", "PL", "PT", "PW", "PY", "QA", "RO", "RS", "RU", "RW", "SA", "SB",
58
+ "SC", "SD", "SE", "SG", "SI", "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", "SY", "SZ", "TD", "TG", "TH",
59
+ "TJ", "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "US", "UY", "UZ", "VA", "VC", "VE", "VN",
60
+ "VU", "WS", "XK", "YE", "ZA", "ZM", "ZW",
61
+ ] as const;
62
+
63
+ const COUNTRY_CODE_ALIASES: Record<string, string> = {
64
+ uk: "GB",
65
+ "u.k.": "GB",
66
+ usa: "US",
67
+ "u.s.": "US",
68
+ "u.s.a.": "US",
69
+ };
70
+
71
+ function normalizeCountryName(value: string): string {
72
+ return value
73
+ .normalize("NFKD")
74
+ .replace(/\p{Diacritic}/gu, "")
75
+ .replace(/[.'’]/g, "")
76
+ .replace(/\s+/g, " ")
77
+ .trim()
78
+ .toLowerCase();
79
+ }
80
+
81
+ function resolveCountryCodeFromName(value: string | undefined, locale: string): string | undefined {
82
+ const trimmed = value?.trim();
83
+ if (!trimmed) return undefined;
84
+
85
+ const alias = COUNTRY_CODE_ALIASES[normalizeCountryName(trimmed)];
86
+ if (alias) return alias;
87
+
88
+ const upper = trimmed.toUpperCase();
89
+ if (upper.length === 2 && ISO_COUNTRY_CODES.includes(upper as (typeof ISO_COUNTRY_CODES)[number])) {
90
+ return upper;
91
+ }
92
+
93
+ const localesToTry = Array.from(new Set([locale, "en", "en-US"]));
94
+
95
+ for (const candidateLocale of localesToTry) {
96
+ const displayNames = new Intl.DisplayNames([candidateLocale], { type: "region" });
97
+ for (const code of ISO_COUNTRY_CODES) {
98
+ const label = displayNames.of(code);
99
+ if (label && normalizeCountryName(label) === normalizeCountryName(trimmed)) {
100
+ return code;
101
+ }
102
+ }
103
+ }
104
+
105
+ return undefined;
106
+ }
31
107
 
32
108
  export function CreateEntityForm({
33
- t = defaultTranslate,
109
+ t,
34
110
  namespace = "",
35
111
  accountId,
36
112
  environment,
@@ -41,7 +117,7 @@ export function CreateEntityForm({
41
117
  onSuccess,
42
118
  onError,
43
119
  }: CreateEntityFormProps) {
44
- const translate = (key: string) => t(namespace ? `${namespace}.${key}` : key);
120
+ const translate = createTranslation({ t, namespace, locale, translations });
45
121
 
46
122
  const countryName = countryCode ? new Intl.DisplayNames([locale], { type: "region" }).of(countryCode) : undefined;
47
123
 
@@ -50,12 +126,13 @@ export function CreateEntityForm({
50
126
  const autoFilledCountryRef = useRef(countryName);
51
127
 
52
128
  // Company registry autocomplete state
129
+ // showAutocomplete is based on the initial countryCode prop to avoid component switch mid-typing
53
130
  const [nameSearch, setNameSearch] = useState("");
54
- const { isSupported: isRegistrySupported } = useIsCountrySupported(activeCountryCode || "");
131
+ const { isSupported: isRegistrySupported } = useIsCountrySupported(countryCode || "");
55
132
  const { data: searchData, isLoading: isSearching } = useCompanyRegistrySearch(activeCountryCode || "", nameSearch);
56
133
  const companies = searchData?.data || [];
57
134
 
58
- const showAutocomplete = !!activeCountryCode && isRegistrySupported;
135
+ const showAutocomplete = !!countryCode && isRegistrySupported;
59
136
 
60
137
  const nameOptions = companies.map((company) => {
61
138
  const addressParts = [company.address, company.city].filter(Boolean);
@@ -97,13 +174,14 @@ export function CreateEntityForm({
97
174
  // Watch country field — clear activeCountryCode when user edits away from auto-filled value
98
175
  const countryValue = form.watch("country");
99
176
  useEffect(() => {
100
- if (countryValue !== autoFilledCountryRef.current) {
101
- setActiveCountryCode(undefined);
102
- form.setValue("country_code", "");
103
- } else {
104
- setActiveCountryCode(countryCode);
105
- }
106
- }, [countryValue, countryCode, form]);
177
+ const nextCountryCode =
178
+ countryValue === autoFilledCountryRef.current
179
+ ? countryCode
180
+ : resolveCountryCodeFromName(countryValue, locale) || undefined;
181
+
182
+ setActiveCountryCode(nextCountryCode);
183
+ form.setValue("country_code", nextCountryCode || "");
184
+ }, [countryValue, countryCode, form, locale]);
107
185
 
108
186
  const handleCompanySelect = (company: CompanyRegistryResult) => {
109
187
  form.setValue("name", company.name);
@@ -133,9 +211,10 @@ export function CreateEntityForm({
133
211
 
134
212
  const onSubmit = async (values: CreateEntitySchema) => {
135
213
  try {
136
- // Zod validation ensures required fields are present before this is called
137
- // The type cast is safe because React Hook Form's DeepPartial doesn't reflect runtime validation
138
- createEntity(values as CreateEntityRequest);
214
+ const resolvedCountryCode = values.country_code || resolveCountryCodeFromName(values.country, locale);
215
+ const { country_code: _countryCode, ...rest } = values;
216
+ const payload = resolvedCountryCode ? { ...rest, country_code: resolvedCountryCode } : rest;
217
+ createEntity(payload as CreateEntityRequest);
139
218
  } catch (e) {
140
219
  onError?.(e);
141
220
  form.setError("root", {
@@ -259,7 +338,13 @@ export function CreateEntityForm({
259
338
  placeholder={translate("company-number")}
260
339
  />
261
340
 
262
- <Button type="submit" className="w-full cursor-pointer" disabled={isPending} aria-busy={isPending}>
341
+ <Button
342
+ type="submit"
343
+ className="w-full cursor-pointer"
344
+ disabled={isPending}
345
+ aria-busy={isPending}
346
+ data-testid="entity-create-submit"
347
+ >
263
348
  {isPending ? <ButtonLoader /> : translate("submit")}
264
349
  </Button>
265
350
  </form>
@@ -56,15 +56,15 @@ const translations = {
56
56
  // Supported locales (matching backend)
57
57
  const SUPPORTED_LOCALES = [
58
58
  { value: "en-US", label: "English (US)" },
59
- { value: "de-DE", label: "Deutsch (DE)" },
60
- { value: "it-IT", label: "Italiano (IT)" },
61
- { value: "fr-FR", label: "Français (FR)" },
62
- { value: "es-ES", label: "Español (ES)" },
63
- { value: "pt-PT", label: "Português (Portugal)" },
64
- { value: "nl-NL", label: "Nederlands" },
65
- { value: "pl-PL", label: "Polski" },
66
- { value: "hr-HR", label: "Hrvatski" },
67
- { value: "sl-SI", label: "Slovenščina (SI)" },
59
+ { value: "de-DE", label: "German (DE)" },
60
+ { value: "it-IT", label: "Italian (IT)" },
61
+ { value: "fr-FR", label: "French (FR)" },
62
+ { value: "es-ES", label: "Spanish (ES)" },
63
+ { value: "pt-PT", label: "Portuguese (Portugal)" },
64
+ { value: "nl-NL", label: "Dutch" },
65
+ { value: "pl-PL", label: "Polish" },
66
+ { value: "hr-HR", label: "Croatian" },
67
+ { value: "sl-SI", label: "Slovenian (SI)" },
68
68
  ] as const;
69
69
 
70
70
  // Countries with EPC QR feature (EU 27 + Switzerland)
@@ -805,7 +805,7 @@ export function EntitySettingsForm({
805
805
  <SelectContent>
806
806
  {SUPPORTED_LOCALES.map((locale) => (
807
807
  <SelectItem key={locale.value} value={locale.value}>
808
- {locale.label}
808
+ {translate(locale.label)}
809
809
  </SelectItem>
810
810
  ))}
811
811
  </SelectContent>
@@ -38,6 +38,16 @@ export default {
38
38
  "Select currency": "Währung auswählen",
39
39
  "Select locale": "Gebietsschema auswählen",
40
40
  "Configure entity localization": "Lokalisierung konfigurieren",
41
+ "English (US)": "Englisch (US)",
42
+ "German (DE)": "Deutsch (DE)",
43
+ "Italian (IT)": "Italienisch (IT)",
44
+ "French (FR)": "Französisch (FR)",
45
+ "Spanish (ES)": "Spanisch (ES)",
46
+ "Portuguese (Portugal)": "Portugiesisch (Portugal)",
47
+ Dutch: "Niederländisch",
48
+ Polish: "Polnisch",
49
+ Croatian: "Kroatisch",
50
+ "Slovenian (SI)": "Slowenisch (SI)",
41
51
  "Email Settings": "E-Mail-Einstellungen",
42
52
  "Configure email settings for invoices": "Konfigurieren Sie E-Mail-Einstellungen für Rechnungen",
43
53
  "Email Address": "E-Mail-Adresse",
@@ -37,6 +37,16 @@ export default {
37
37
  "Select currency": "Seleccionar moneda",
38
38
  "Select locale": "Seleccionar configuración regional",
39
39
  "Configure entity localization": "Configurar la localización de la entidad",
40
+ "English (US)": "Inglés (US)",
41
+ "German (DE)": "Alemán (DE)",
42
+ "Italian (IT)": "Italiano (IT)",
43
+ "French (FR)": "Francés (FR)",
44
+ "Spanish (ES)": "Español (ES)",
45
+ "Portuguese (Portugal)": "Portugués (Portugal)",
46
+ Dutch: "Neerlandés",
47
+ Polish: "Polaco",
48
+ Croatian: "Croata",
49
+ "Slovenian (SI)": "Esloveno (SI)",
40
50
  "Email Settings": "Configuración de email",
41
51
  "Configure email settings for invoices": "Configurar las opciones de email para las facturas",
42
52
  "Email Address": "Dirección de email",
@@ -37,6 +37,16 @@ export default {
37
37
  "Select currency": "Sélectionner la devise",
38
38
  "Select locale": "Sélectionner les paramètres régionaux",
39
39
  "Configure entity localization": "Configurer la localisation de l'entité",
40
+ "English (US)": "Anglais (US)",
41
+ "German (DE)": "Allemand (DE)",
42
+ "Italian (IT)": "Italien (IT)",
43
+ "French (FR)": "Français (FR)",
44
+ "Spanish (ES)": "Espagnol (ES)",
45
+ "Portuguese (Portugal)": "Portugais (Portugal)",
46
+ Dutch: "Néerlandais",
47
+ Polish: "Polonais",
48
+ Croatian: "Croate",
49
+ "Slovenian (SI)": "Slovène (SI)",
40
50
  "Email Settings": "Paramètres email",
41
51
  "Configure email settings for invoices": "Configurer les paramètres email pour les factures",
42
52
  "Email Address": "Adresse email",
@@ -37,6 +37,16 @@ export default {
37
37
  "Select currency": "Odaberite valutu",
38
38
  "Select locale": "Odaberite regionalne postavke",
39
39
  "Configure entity localization": "Konfigurirajte lokalizaciju subjekta",
40
+ "English (US)": "Engleski (US)",
41
+ "German (DE)": "Njemački (DE)",
42
+ "Italian (IT)": "Talijanski (IT)",
43
+ "French (FR)": "Francuski (FR)",
44
+ "Spanish (ES)": "Španjolski (ES)",
45
+ "Portuguese (Portugal)": "Portugalski (Portugal)",
46
+ Dutch: "Nizozemski",
47
+ Polish: "Poljski",
48
+ Croatian: "Hrvatski",
49
+ "Slovenian (SI)": "Slovenski (SI)",
40
50
  "Email Settings": "Postavke e-pošte",
41
51
  "Configure email settings for invoices": "Konfigurirajte postavke e-pošte za račune",
42
52
  "Email Address": "Adresa e-pošte",
@@ -37,6 +37,16 @@ export default {
37
37
  "Select currency": "Seleziona valuta",
38
38
  "Select locale": "Seleziona localizzazione",
39
39
  "Configure entity localization": "Configura la localizzazione dell'entità",
40
+ "English (US)": "Inglese (US)",
41
+ "German (DE)": "Tedesco (DE)",
42
+ "Italian (IT)": "Italiano (IT)",
43
+ "French (FR)": "Francese (FR)",
44
+ "Spanish (ES)": "Spagnolo (ES)",
45
+ "Portuguese (Portugal)": "Portoghese (Portogallo)",
46
+ Dutch: "Olandese",
47
+ Polish: "Polacco",
48
+ Croatian: "Croato",
49
+ "Slovenian (SI)": "Sloveno (SI)",
40
50
  "Email Settings": "Impostazioni email",
41
51
  "Configure email settings for invoices": "Configura le impostazioni email per le fatture",
42
52
  "Email Address": "Indirizzo email",
@@ -37,6 +37,16 @@ export default {
37
37
  "Select currency": "Valuta selecteren",
38
38
  "Select locale": "Landinstelling selecteren",
39
39
  "Configure entity localization": "Lokalisatie van de entiteit configureren",
40
+ "English (US)": "Engels (US)",
41
+ "German (DE)": "Duits (DE)",
42
+ "Italian (IT)": "Italiaans (IT)",
43
+ "French (FR)": "Frans (FR)",
44
+ "Spanish (ES)": "Spaans (ES)",
45
+ "Portuguese (Portugal)": "Portugees (Portugal)",
46
+ Dutch: "Nederlands",
47
+ Polish: "Pools",
48
+ Croatian: "Kroatisch",
49
+ "Slovenian (SI)": "Sloveens (SI)",
40
50
  "Email Settings": "E-mailinstellingen",
41
51
  "Configure email settings for invoices": "E-mailinstellingen configureren voor facturen",
42
52
  "Email Address": "E-mailadres",
@@ -37,6 +37,16 @@ export default {
37
37
  "Select currency": "Wybierz walutę",
38
38
  "Select locale": "Wybierz ustawienia regionalne",
39
39
  "Configure entity localization": "Skonfiguruj lokalizację podmiotu",
40
+ "English (US)": "Angielski (US)",
41
+ "German (DE)": "Niemiecki (DE)",
42
+ "Italian (IT)": "Włoski (IT)",
43
+ "French (FR)": "Francuski (FR)",
44
+ "Spanish (ES)": "Hiszpański (ES)",
45
+ "Portuguese (Portugal)": "Portugalski (Portugalia)",
46
+ Dutch: "Niderlandzki",
47
+ Polish: "Polski",
48
+ Croatian: "Chorwacki",
49
+ "Slovenian (SI)": "Słoweński (SI)",
40
50
  "Email Settings": "Ustawienia email",
41
51
  "Configure email settings for invoices": "Skonfiguruj ustawienia email dla faktur",
42
52
  "Email Address": "Adres email",
@@ -37,6 +37,16 @@ export default {
37
37
  "Select currency": "Selecionar moeda",
38
38
  "Select locale": "Selecionar configuração regional",
39
39
  "Configure entity localization": "Configurar a localização da entidade",
40
+ "English (US)": "Inglês (US)",
41
+ "German (DE)": "Alemão (DE)",
42
+ "Italian (IT)": "Italiano (IT)",
43
+ "French (FR)": "Francês (FR)",
44
+ "Spanish (ES)": "Espanhol (ES)",
45
+ "Portuguese (Portugal)": "Português (Portugal)",
46
+ Dutch: "Neerlandês",
47
+ Polish: "Polaco",
48
+ Croatian: "Croata",
49
+ "Slovenian (SI)": "Esloveno (SI)",
40
50
  "Email Settings": "Definições de email",
41
51
  "Configure email settings for invoices": "Configurar as definições de email para as faturas",
42
52
  "Email Address": "Endereço de email",
@@ -37,6 +37,16 @@ export default {
37
37
  "Select currency": "Izberite valuto",
38
38
  "Select locale": "Izberite lokalnost",
39
39
  "Configure entity localization": "Konfigurirajte lokalizacijo pravne osebe",
40
+ "English (US)": "Angleščina (US)",
41
+ "German (DE)": "Nemščina (DE)",
42
+ "Italian (IT)": "Italijanščina (IT)",
43
+ "French (FR)": "Francoščina (FR)",
44
+ "Spanish (ES)": "Španščina (ES)",
45
+ "Portuguese (Portugal)": "Portugalščina (Portugalska)",
46
+ Dutch: "Nizozemščina",
47
+ Polish: "Poljščina",
48
+ Croatian: "Hrvaščina",
49
+ "Slovenian (SI)": "Slovenščina (SI)",
40
50
  "Email Settings": "Nastavitve e-pošte",
41
51
  "Configure email settings for invoices": "Konfigurirajte nastavitve e-pošte za račune",
42
52
  "Email Address": "Naslov e-pošte",
@@ -40,18 +40,18 @@ export const FinaOperatorRequiredDialog: FC<FinaOperatorRequiredDialogProps> = (
40
40
  const handleSubmit = (e: React.FormEvent) => {
41
41
  e.preventDefault();
42
42
  e.stopPropagation();
43
- if (!operatorOib || !operatorLabel) return;
43
+ if (!operatorOib) return;
44
44
  updateUserSettings({
45
45
  entityId,
46
46
  data: {
47
47
  operator_oib: operatorOib,
48
- operator_label: operatorLabel,
48
+ operator_label: operatorLabel || undefined,
49
49
  },
50
50
  });
51
51
  };
52
52
 
53
53
  const oibError = operatorOib !== "" && !/^\d{11}$/.test(operatorOib);
54
- const isValid = /^\d{11}$/.test(operatorOib) && operatorLabel.trim() !== "";
54
+ const isValid = /^\d{11}$/.test(operatorOib);
55
55
 
56
56
  return (
57
57
  <Dialog open={open} onOpenChange={onOpenChange}>