@spaceinvoices/react-ui 0.4.11 → 0.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/dist/index.js +1 -1
- package/package.json +3 -2
- package/registry.json +30 -31
- package/src/common/autocomplete.tsx +41 -25
- package/src/components/activities/locales/bg.ts +21 -0
- package/src/components/activities/locales/cs.ts +21 -0
- package/src/components/activities/locales/en.ts +21 -0
- package/src/components/activities/locales/et.ts +21 -0
- package/src/components/activities/locales/fi.ts +21 -0
- package/src/components/activities/locales/is.ts +21 -0
- package/src/components/activities/locales/nb.ts +21 -0
- package/src/components/activities/locales/sk.ts +21 -0
- package/src/components/activities/locales/sv.ts +21 -0
- package/src/components/advance-invoices/advance-invoices.hooks.ts +2 -3
- package/src/components/advance-invoices/create/create-advance-invoice-form.tsx +290 -69
- package/src/components/advance-invoices/create/locales/bg.ts +48 -0
- package/src/components/advance-invoices/create/locales/cs.ts +48 -0
- package/src/components/advance-invoices/create/locales/en.ts +48 -0
- package/src/components/advance-invoices/create/locales/et.ts +48 -0
- package/src/components/advance-invoices/create/locales/fi.ts +48 -0
- package/src/components/advance-invoices/create/locales/hr.ts +17 -17
- package/src/components/advance-invoices/create/locales/is.ts +48 -0
- package/src/components/advance-invoices/create/locales/nb.ts +48 -0
- package/src/components/advance-invoices/create/locales/sk.ts +48 -0
- package/src/components/advance-invoices/create/locales/sl.ts +9 -7
- package/src/components/advance-invoices/create/locales/sv.ts +48 -0
- package/src/components/advance-invoices/create/prepare-advance-invoice-submission.ts +16 -2
- package/src/components/advance-invoices/list/list-row-actions.tsx +48 -16
- package/src/components/advance-invoices/list/list-table.tsx +33 -8
- package/src/components/advance-invoices/list/locales/bg.ts +51 -0
- package/src/components/advance-invoices/list/locales/cs.ts +51 -0
- package/src/components/advance-invoices/list/locales/en.ts +33 -2
- package/src/components/advance-invoices/list/locales/et.ts +51 -0
- package/src/components/advance-invoices/list/locales/fi.ts +51 -0
- package/src/components/advance-invoices/list/locales/hr.ts +15 -15
- package/src/components/advance-invoices/list/locales/is.ts +51 -0
- package/src/components/advance-invoices/list/locales/nb.ts +51 -0
- package/src/components/advance-invoices/list/locales/sk.ts +51 -0
- package/src/components/advance-invoices/list/locales/sv.ts +51 -0
- package/src/components/advance-invoices/list/use-advance-invoice-download.ts +3 -5
- package/src/components/common/autocomplete-locales.ts +101 -0
- package/src/components/company-registry/company-registry.hooks.ts +3 -7
- package/src/components/credit-notes/create/create-credit-note-form.tsx +211 -22
- package/src/components/credit-notes/create/locales/bg.ts +87 -0
- package/src/components/credit-notes/create/locales/cs.ts +87 -0
- package/src/components/credit-notes/create/locales/en.ts +87 -0
- package/src/components/credit-notes/create/locales/et.ts +87 -0
- package/src/components/credit-notes/create/locales/fi.ts +87 -0
- package/src/components/credit-notes/create/locales/hr.ts +24 -24
- package/src/components/credit-notes/create/locales/is.ts +87 -0
- package/src/components/credit-notes/create/locales/nb.ts +87 -0
- package/src/components/credit-notes/create/locales/sk.ts +87 -0
- package/src/components/credit-notes/create/locales/sl.ts +9 -9
- package/src/components/credit-notes/create/locales/sv.ts +87 -0
- package/src/components/credit-notes/create/prepare-credit-note-submission.ts +32 -0
- package/src/components/credit-notes/credit-notes.hooks.ts +15 -3
- package/src/components/credit-notes/list/list-row-actions.tsx +19 -7
- package/src/components/credit-notes/list/list-table.tsx +58 -7
- package/src/components/credit-notes/list/locales/bg.ts +48 -0
- package/src/components/credit-notes/list/locales/cs.ts +48 -0
- package/src/components/credit-notes/list/locales/en.ts +31 -2
- package/src/components/credit-notes/list/locales/et.ts +48 -0
- package/src/components/credit-notes/list/locales/fi.ts +48 -0
- package/src/components/credit-notes/list/locales/hr.ts +12 -12
- package/src/components/credit-notes/list/locales/is.ts +48 -0
- package/src/components/credit-notes/list/locales/nb.ts +48 -0
- package/src/components/credit-notes/list/locales/sk.ts +48 -0
- package/src/components/credit-notes/list/locales/sv.ts +48 -0
- package/src/components/credit-notes/list/use-credit-note-download.ts +3 -5
- package/src/components/customers/create-customer-form/locales/bg.ts +21 -0
- package/src/components/customers/create-customer-form/locales/cs.ts +21 -0
- package/src/components/customers/create-customer-form/locales/en.ts +21 -0
- package/src/components/customers/create-customer-form/locales/et.ts +21 -0
- package/src/components/customers/create-customer-form/locales/fi.ts +21 -0
- package/src/components/customers/create-customer-form/locales/hr.ts +11 -11
- package/src/components/customers/create-customer-form/locales/is.ts +21 -0
- package/src/components/customers/create-customer-form/locales/nb.ts +21 -0
- package/src/components/customers/create-customer-form/locales/sk.ts +21 -0
- package/src/components/customers/create-customer-form/locales/sv.ts +21 -0
- package/src/components/customers/customer-autocomplete.tsx +32 -4
- package/src/components/customers/customer-list-table/customer-list-table.tsx +8 -6
- package/src/components/customers/customer-list-table/locales/bg.ts +25 -0
- package/src/components/customers/customer-list-table/locales/cs.ts +25 -0
- package/src/components/customers/customer-list-table/locales/en.ts +17 -2
- package/src/components/customers/customer-list-table/locales/et.ts +25 -0
- package/src/components/customers/customer-list-table/locales/fi.ts +25 -0
- package/src/components/customers/customer-list-table/locales/hr.ts +11 -11
- package/src/components/customers/customer-list-table/locales/is.ts +25 -0
- package/src/components/customers/customer-list-table/locales/nb.ts +25 -0
- package/src/components/customers/customer-list-table/locales/sk.ts +25 -0
- package/src/components/customers/customer-list-table/locales/sv.ts +25 -0
- package/src/components/customers/customers.hooks.ts +14 -17
- package/src/components/customers/edit-customer-form/locales/bg.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/cs.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/en.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/et.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/fi.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/hr.ts +5 -5
- package/src/components/customers/edit-customer-form/locales/is.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/nb.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/sk.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/sv.ts +13 -0
- package/src/components/dashboard/collection-rate-card/collection-rate-card.tsx +7 -6
- package/src/components/dashboard/collection-rate-card/locales/en.ts +3 -0
- package/src/components/dashboard/collection-rate-card/use-collection-rate.ts +8 -7
- package/src/components/dashboard/invoice-status-chart/invoice-status-chart.tsx +7 -4
- package/src/components/dashboard/invoice-status-chart/locales/bg.ts +5 -5
- package/src/components/dashboard/invoice-status-chart/locales/cs.ts +5 -5
- package/src/components/dashboard/invoice-status-chart/locales/de.ts +1 -1
- package/src/components/dashboard/invoice-status-chart/locales/en.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/es.ts +1 -1
- package/src/components/dashboard/invoice-status-chart/locales/et.ts +5 -5
- package/src/components/dashboard/invoice-status-chart/locales/fi.ts +5 -5
- package/src/components/dashboard/invoice-status-chart/locales/fr.ts +1 -1
- package/src/components/dashboard/invoice-status-chart/locales/hr.ts +5 -5
- package/src/components/dashboard/invoice-status-chart/locales/is.ts +5 -5
- package/src/components/dashboard/invoice-status-chart/locales/it.ts +1 -1
- package/src/components/dashboard/invoice-status-chart/locales/nb.ts +5 -5
- package/src/components/dashboard/invoice-status-chart/locales/nl.ts +1 -1
- package/src/components/dashboard/invoice-status-chart/locales/pl.ts +1 -1
- package/src/components/dashboard/invoice-status-chart/locales/pt.ts +1 -1
- package/src/components/dashboard/invoice-status-chart/locales/sk.ts +5 -5
- package/src/components/dashboard/invoice-status-chart/locales/sl.ts +1 -1
- package/src/components/dashboard/invoice-status-chart/locales/sv.ts +5 -5
- package/src/components/dashboard/payment-methods-chart/locales/bg.ts +5 -5
- package/src/components/dashboard/payment-methods-chart/locales/cs.ts +5 -5
- package/src/components/dashboard/payment-methods-chart/locales/en.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/et.ts +5 -5
- package/src/components/dashboard/payment-methods-chart/locales/fi.ts +6 -6
- package/src/components/dashboard/payment-methods-chart/locales/hr.ts +3 -3
- package/src/components/dashboard/payment-methods-chart/locales/is.ts +5 -5
- package/src/components/dashboard/payment-methods-chart/locales/nb.ts +5 -5
- package/src/components/dashboard/payment-methods-chart/locales/sk.ts +5 -5
- package/src/components/dashboard/payment-methods-chart/locales/sv.ts +5 -5
- package/src/components/dashboard/payment-methods-chart/payment-methods-chart.tsx +4 -3
- package/src/components/dashboard/payment-trend-chart/locales/bg.ts +1 -1
- package/src/components/dashboard/payment-trend-chart/locales/cs.ts +1 -1
- package/src/components/dashboard/payment-trend-chart/locales/en.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/et.ts +1 -1
- package/src/components/dashboard/payment-trend-chart/locales/fi.ts +1 -1
- package/src/components/dashboard/payment-trend-chart/locales/is.ts +1 -1
- package/src/components/dashboard/payment-trend-chart/locales/nb.ts +1 -1
- package/src/components/dashboard/payment-trend-chart/locales/sk.ts +1 -1
- package/src/components/dashboard/payment-trend-chart/locales/sv.ts +1 -1
- package/src/components/dashboard/payment-trend-chart/payment-trend-chart.tsx +4 -3
- package/src/components/dashboard/payment-trend-chart/use-payment-trend.ts +12 -9
- package/src/components/dashboard/revenue-card.tsx +3 -3
- package/src/components/dashboard/revenue-trend-chart/locales/bg.ts +1 -1
- package/src/components/dashboard/revenue-trend-chart/locales/cs.ts +1 -1
- package/src/components/dashboard/revenue-trend-chart/locales/en.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/et.ts +1 -1
- package/src/components/dashboard/revenue-trend-chart/locales/fi.ts +1 -1
- package/src/components/dashboard/revenue-trend-chart/locales/is.ts +1 -1
- package/src/components/dashboard/revenue-trend-chart/locales/nb.ts +1 -1
- package/src/components/dashboard/revenue-trend-chart/locales/sk.ts +1 -1
- package/src/components/dashboard/revenue-trend-chart/locales/sv.ts +1 -1
- package/src/components/dashboard/revenue-trend-chart/revenue-trend-chart.tsx +4 -3
- package/src/components/dashboard/revenue-trend-chart/use-revenue-trend.ts +4 -3
- package/src/components/dashboard/shared/local-date.ts +11 -0
- package/src/components/dashboard/shared/use-revenue-data.ts +6 -5
- package/src/components/dashboard/shared/use-stats-query.ts +7 -11
- package/src/components/dashboard/stat-card.tsx +3 -3
- package/src/components/dashboard/tax-collected-card/tax-collected-card.tsx +11 -9
- package/src/components/dashboard/tax-collected-card/use-tax-collected.ts +3 -2
- package/src/components/dashboard/top-customers-chart/locales/bg.ts +2 -2
- package/src/components/dashboard/top-customers-chart/locales/cs.ts +2 -2
- package/src/components/dashboard/top-customers-chart/locales/en.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/et.ts +2 -2
- package/src/components/dashboard/top-customers-chart/locales/fi.ts +2 -2
- package/src/components/dashboard/top-customers-chart/locales/is.ts +2 -2
- package/src/components/dashboard/top-customers-chart/locales/nb.ts +2 -2
- package/src/components/dashboard/top-customers-chart/locales/sk.ts +2 -2
- package/src/components/dashboard/top-customers-chart/locales/sv.ts +2 -2
- package/src/components/dashboard/top-customers-chart/top-customers-chart.tsx +4 -3
- package/src/components/dashboard/top-customers-chart/use-top-customers.ts +7 -20
- package/src/components/delivery-notes/create/create-delivery-note-form.tsx +61 -31
- package/src/components/delivery-notes/create/locales/bg.ts +68 -0
- package/src/components/delivery-notes/create/locales/cs.ts +68 -0
- package/src/components/delivery-notes/create/locales/en.ts +68 -0
- package/src/components/delivery-notes/create/locales/et.ts +68 -0
- package/src/components/delivery-notes/create/locales/fi.ts +68 -0
- package/src/components/delivery-notes/create/locales/hr.ts +6 -6
- package/src/components/delivery-notes/create/locales/is.ts +68 -0
- package/src/components/delivery-notes/create/locales/nb.ts +68 -0
- package/src/components/delivery-notes/create/locales/sk.ts +68 -0
- package/src/components/delivery-notes/create/locales/sl.ts +5 -5
- package/src/components/delivery-notes/create/locales/sv.ts +68 -0
- package/src/components/delivery-notes/delivery-notes.hooks.ts +20 -3
- package/src/components/delivery-notes/list/list-row-actions.tsx +62 -16
- package/src/components/delivery-notes/list/list-table.tsx +42 -9
- package/src/components/delivery-notes/list/locales/bg.ts +40 -0
- package/src/components/delivery-notes/list/locales/cs.ts +40 -0
- package/src/components/delivery-notes/list/locales/et.ts +40 -0
- package/src/components/delivery-notes/list/locales/fi.ts +40 -0
- package/src/components/delivery-notes/list/locales/is.ts +40 -0
- package/src/components/delivery-notes/list/locales/nb.ts +40 -0
- package/src/components/delivery-notes/list/locales/sk.ts +40 -0
- package/src/components/delivery-notes/list/locales/sv.ts +40 -0
- package/src/components/delivery-notes/list/use-delivery-note-download.ts +3 -5
- package/src/components/documents/create/document-add-item-form.tsx +256 -147
- package/src/components/documents/create/document-add-item-tax-rate-field.tsx +2 -1
- package/src/components/documents/create/document-details-section.tsx +30 -12
- package/src/components/documents/create/document-item-validation.ts +50 -0
- package/src/components/documents/create/document-items-section.tsx +44 -6
- package/src/components/documents/create/document-recipient-section.tsx +10 -2
- package/src/components/documents/create/linked-documents-info.tsx +4 -3
- package/src/components/documents/create/live-preview.tsx +19 -15
- package/src/components/documents/create/mark-as-paid-section.tsx +77 -20
- package/src/components/documents/create/payment-rows.ts +291 -0
- package/src/components/documents/create/prepare-document-submission.ts +24 -13
- package/src/components/documents/create/scroll-to-first-invalid-field.ts +27 -0
- package/src/components/documents/create/smart-code-insert-button.tsx +5 -53
- package/src/components/documents/create/use-document-customer-form.ts +74 -25
- package/src/components/documents/documents.hooks.ts +3 -5
- package/src/components/documents/index.ts +1 -0
- package/src/components/documents/public/index.ts +1 -0
- package/src/components/documents/public/public-document-summary.tsx +343 -0
- package/src/components/documents/shared/document-preview-display.tsx +65 -39
- package/src/components/documents/shared/index.ts +6 -1
- package/src/components/documents/shared/scaled-document-preview.tsx +33 -19
- package/src/components/documents/types.ts +24 -0
- package/src/components/documents/view/document-actions-bar.tsx +241 -62
- package/src/components/documents/view/document-activities-list.tsx +23 -11
- package/src/components/documents/view/document-details-card.tsx +7 -27
- package/src/components/documents/view/document-payments-list.tsx +114 -57
- package/src/components/documents/view/document-relations-list.tsx +26 -6
- package/src/components/documents/view/document-sidebar.tsx +25 -3
- package/src/components/documents/view/document-version-history.tsx +137 -0
- package/src/components/documents/view/index.ts +1 -0
- package/src/components/documents/view/locales/bg.ts +143 -0
- package/src/components/documents/view/locales/cs.ts +143 -0
- package/src/components/documents/view/locales/de.ts +13 -0
- package/src/components/documents/view/locales/en.ts +143 -0
- package/src/components/documents/view/locales/es.ts +13 -0
- package/src/components/documents/view/locales/et.ts +143 -0
- package/src/components/documents/view/locales/fi.ts +143 -0
- package/src/components/documents/view/locales/fr.ts +13 -0
- package/src/components/documents/view/locales/hr.ts +13 -0
- package/src/components/documents/view/locales/is.ts +143 -0
- package/src/components/documents/view/locales/it.ts +13 -0
- package/src/components/documents/view/locales/nb.ts +143 -0
- package/src/components/documents/view/locales/nl.ts +13 -0
- package/src/components/documents/view/locales/pl.ts +13 -0
- package/src/components/documents/view/locales/pt.ts +13 -0
- package/src/components/documents/view/locales/sk.ts +143 -0
- package/src/components/documents/view/locales/sl.ts +13 -0
- package/src/components/documents/view/locales/sv.ts +143 -0
- package/src/components/documents/view/use-document-download.ts +18 -17
- package/src/components/entities/create-entity-form.tsx +200 -12
- package/src/components/entities/entities.hooks.ts +15 -7
- package/src/components/entities/entity-settings-form/entity-settings-form.tsx +121 -65
- package/src/components/entities/entity-settings-form/input-with-preview.tsx +28 -4
- package/src/components/entities/entity-settings-form/locales/bg.ts +199 -0
- package/src/components/entities/entity-settings-form/locales/cs.ts +199 -0
- package/src/components/entities/entity-settings-form/locales/de.ts +8 -3
- package/src/components/entities/entity-settings-form/locales/en.ts +199 -0
- package/src/components/entities/entity-settings-form/locales/es.ts +8 -3
- package/src/components/entities/entity-settings-form/locales/et.ts +198 -0
- package/src/components/entities/entity-settings-form/locales/fi.ts +199 -0
- package/src/components/entities/entity-settings-form/locales/fr.ts +8 -3
- package/src/components/entities/entity-settings-form/locales/hr.ts +16 -11
- package/src/components/entities/entity-settings-form/locales/is.ts +199 -0
- package/src/components/entities/entity-settings-form/locales/it.ts +8 -3
- package/src/components/entities/entity-settings-form/locales/nb.ts +199 -0
- package/src/components/entities/entity-settings-form/locales/nl.ts +8 -3
- package/src/components/entities/entity-settings-form/locales/pl.ts +8 -3
- package/src/components/entities/entity-settings-form/locales/pt.ts +8 -3
- package/src/components/entities/entity-settings-form/locales/sk.ts +199 -0
- package/src/components/entities/entity-settings-form/locales/sl.ts +20 -15
- package/src/components/entities/entity-settings-form/locales/sv.ts +205 -0
- package/src/components/entities/fina-settings-form/fina-operator-required-dialog.tsx +34 -9
- package/src/components/entities/fina-settings-form/fina-settings-form.tsx +2 -0
- package/src/components/entities/fina-settings-form/fina-settings.hooks.ts +14 -45
- package/src/components/entities/fina-settings-form/locales/bg.ts +163 -0
- package/src/components/entities/fina-settings-form/locales/cs.ts +163 -0
- package/src/components/entities/fina-settings-form/locales/et.ts +163 -0
- package/src/components/entities/fina-settings-form/locales/fi.ts +163 -0
- package/src/components/entities/fina-settings-form/locales/hr.ts +11 -10
- package/src/components/entities/fina-settings-form/locales/is.ts +164 -0
- package/src/components/entities/fina-settings-form/locales/nb.ts +163 -0
- package/src/components/entities/fina-settings-form/locales/sk.ts +163 -0
- package/src/components/entities/fina-settings-form/locales/sl.ts +8 -7
- package/src/components/entities/fina-settings-form/locales/sv.ts +165 -0
- package/src/components/entities/furs-settings-form/furs-operator-required-dialog.tsx +34 -9
- package/src/components/entities/furs-settings-form/furs-settings-form.tsx +13 -1
- package/src/components/entities/furs-settings-form/furs-settings.hooks.ts +141 -42
- package/src/components/entities/furs-settings-form/locales/bg.ts +242 -0
- package/src/components/entities/furs-settings-form/locales/cs.ts +241 -0
- package/src/components/entities/furs-settings-form/locales/de.ts +42 -15
- package/src/components/entities/furs-settings-form/locales/en.ts +24 -0
- package/src/components/entities/furs-settings-form/locales/es.ts +42 -15
- package/src/components/entities/furs-settings-form/locales/et.ts +242 -0
- package/src/components/entities/furs-settings-form/locales/fi.ts +243 -0
- package/src/components/entities/furs-settings-form/locales/fr.ts +43 -15
- package/src/components/entities/furs-settings-form/locales/hr.ts +44 -19
- package/src/components/entities/furs-settings-form/locales/is.ts +242 -0
- package/src/components/entities/furs-settings-form/locales/it.ts +42 -15
- package/src/components/entities/furs-settings-form/locales/nb.ts +242 -0
- package/src/components/entities/furs-settings-form/locales/nl.ts +42 -15
- package/src/components/entities/furs-settings-form/locales/pl.ts +40 -15
- package/src/components/entities/furs-settings-form/locales/pt.ts +42 -15
- package/src/components/entities/furs-settings-form/locales/sk.ts +243 -0
- package/src/components/entities/furs-settings-form/locales/sl.ts +34 -10
- package/src/components/entities/furs-settings-form/locales/sv.ts +242 -0
- package/src/components/entities/furs-settings-form/sections/enable-fiscalization-section.tsx +11 -0
- package/src/components/entities/furs-settings-form/sections/furs-internal-act-download-card.tsx +111 -0
- package/src/components/entities/furs-settings-form/sections/general-settings-section.tsx +27 -0
- package/src/components/entities/furs-settings-form/sections/premises-management-section.tsx +23 -16
- package/src/components/entities/furs-settings-form/sections/register-premise-dialog.tsx +89 -31
- package/src/components/entities/settings/branding-settings-form.tsx +11 -30
- package/src/components/entities/settings/company-settings-form.tsx +2 -1
- package/src/components/entities/settings/defaults-settings-form.tsx +106 -3
- package/src/components/entities/settings/email-settings-form.tsx +245 -3
- package/src/components/entities/settings/eslog-settings-form.tsx +2 -1
- package/src/components/entities/settings/number-format-settings-form.tsx +2 -1
- package/src/components/entities/settings/pdf-template-selector/locales/bg.ts +20 -0
- package/src/components/entities/settings/pdf-template-selector/locales/cs.ts +20 -0
- package/src/components/entities/settings/pdf-template-selector/locales/en.ts +20 -0
- package/src/components/entities/settings/pdf-template-selector/locales/et.ts +19 -0
- package/src/components/entities/settings/pdf-template-selector/locales/fi.ts +20 -0
- package/src/components/entities/settings/pdf-template-selector/locales/is.ts +19 -0
- package/src/components/entities/settings/pdf-template-selector/locales/nb.ts +19 -0
- package/src/components/entities/settings/pdf-template-selector/locales/sk.ts +20 -0
- package/src/components/entities/settings/pdf-template-selector/locales/sv.ts +19 -0
- package/src/components/entities/settings/tax-rules-settings-form.tsx +21 -6
- package/src/components/estimates/create/create-estimate-form.tsx +70 -34
- package/src/components/estimates/create/locales/bg.ts +76 -0
- package/src/components/estimates/create/locales/cs.ts +76 -0
- package/src/components/estimates/create/locales/en.ts +76 -0
- package/src/components/estimates/create/locales/et.ts +76 -0
- package/src/components/estimates/create/locales/fi.ts +76 -0
- package/src/components/estimates/create/locales/hr.ts +8 -8
- package/src/components/estimates/create/locales/is.ts +76 -0
- package/src/components/estimates/create/locales/nb.ts +76 -0
- package/src/components/estimates/create/locales/sk.ts +76 -0
- package/src/components/estimates/create/locales/sl.ts +8 -8
- package/src/components/estimates/create/locales/sv.ts +76 -0
- package/src/components/estimates/create/prepare-estimate-submission.ts +4 -1
- package/src/components/estimates/estimates.hooks.ts +15 -3
- package/src/components/estimates/list/list-row-actions.tsx +34 -7
- package/src/components/estimates/list/list-table.tsx +78 -10
- package/src/components/estimates/list/locales/bg.ts +38 -0
- package/src/components/estimates/list/locales/cs.ts +38 -0
- package/src/components/estimates/list/locales/en.ts +27 -2
- package/src/components/estimates/list/locales/et.ts +38 -0
- package/src/components/estimates/list/locales/fi.ts +38 -0
- package/src/components/estimates/list/locales/hr.ts +2 -2
- package/src/components/estimates/list/locales/is.ts +38 -0
- package/src/components/estimates/list/locales/nb.ts +38 -0
- package/src/components/estimates/list/locales/sk.ts +38 -0
- package/src/components/estimates/list/locales/sv.ts +38 -0
- package/src/components/estimates/list/use-estimate-download.ts +3 -5
- package/src/components/export/document-export-form.tsx +72 -15
- package/src/components/export/sales-per-item-export-form.tsx +3 -2
- package/src/components/invoices/create/create-invoice-form.tsx +294 -76
- package/src/components/invoices/create/eslog-validation.ts +97 -8
- package/src/components/invoices/create/locales/bg.ts +164 -0
- package/src/components/invoices/create/locales/cs.ts +164 -0
- package/src/components/invoices/create/locales/de.ts +24 -0
- package/src/components/invoices/create/locales/en.ts +164 -0
- package/src/components/invoices/create/locales/es.ts +24 -0
- package/src/components/invoices/create/locales/et.ts +164 -0
- package/src/components/invoices/create/locales/fi.ts +164 -0
- package/src/components/invoices/create/locales/fr.ts +23 -0
- package/src/components/invoices/create/locales/hr.ts +32 -9
- package/src/components/invoices/create/locales/is.ts +164 -0
- package/src/components/invoices/create/locales/it.ts +24 -0
- package/src/components/invoices/create/locales/nb.ts +164 -0
- package/src/components/invoices/create/locales/nl.ts +23 -0
- package/src/components/invoices/create/locales/pl.ts +23 -0
- package/src/components/invoices/create/locales/pt.ts +24 -0
- package/src/components/invoices/create/locales/sk.ts +164 -0
- package/src/components/invoices/create/locales/sl.ts +32 -9
- package/src/components/invoices/create/locales/sv.ts +166 -0
- package/src/components/invoices/create/prepare-invoice-submission.ts +19 -2
- package/src/components/invoices/invoices-furs.hooks.ts +11 -8
- package/src/components/invoices/invoices.hooks.ts +27 -10
- package/src/components/invoices/list/list-row-actions.tsx +54 -21
- package/src/components/invoices/list/list-table.tsx +92 -11
- package/src/components/invoices/list/locales/bg.ts +49 -0
- package/src/components/invoices/list/locales/cs.ts +49 -0
- package/src/components/invoices/list/locales/en.ts +34 -2
- package/src/components/invoices/list/locales/et.ts +49 -0
- package/src/components/invoices/list/locales/fi.ts +49 -0
- package/src/components/invoices/list/locales/is.ts +49 -0
- package/src/components/invoices/list/locales/nb.ts +49 -0
- package/src/components/invoices/list/locales/sk.ts +49 -0
- package/src/components/invoices/list/locales/sv.ts +49 -0
- package/src/components/invoices/list/use-invoice-download.ts +3 -5
- package/src/components/invoices/send-email-dialog/locales/bg.ts +58 -0
- package/src/components/invoices/send-email-dialog/locales/cs.ts +58 -0
- package/src/components/invoices/send-email-dialog/locales/de.ts +21 -0
- package/src/components/invoices/send-email-dialog/locales/en.ts +58 -0
- package/src/components/invoices/send-email-dialog/locales/es.ts +21 -0
- package/src/components/invoices/send-email-dialog/locales/et.ts +58 -0
- package/src/components/invoices/send-email-dialog/locales/fi.ts +58 -0
- package/src/components/invoices/send-email-dialog/locales/fr.ts +21 -0
- package/src/components/invoices/send-email-dialog/locales/hr.ts +21 -0
- package/src/components/invoices/send-email-dialog/locales/is.ts +58 -0
- package/src/components/invoices/send-email-dialog/locales/it.ts +21 -0
- package/src/components/invoices/send-email-dialog/locales/nb.ts +58 -0
- package/src/components/invoices/send-email-dialog/locales/nl.ts +21 -0
- package/src/components/invoices/send-email-dialog/locales/pl.ts +21 -0
- package/src/components/invoices/send-email-dialog/locales/pt.ts +21 -0
- package/src/components/invoices/send-email-dialog/locales/sk.ts +58 -0
- package/src/components/invoices/send-email-dialog/locales/sl.ts +21 -0
- package/src/components/invoices/send-email-dialog/locales/sv.ts +58 -0
- package/src/components/invoices/send-email-dialog/send-email-dialog.tsx +188 -93
- package/src/components/invoices/view/eslog-info-display.tsx +2 -0
- package/src/components/invoices/view/fiscalization-status-card.tsx +2 -0
- package/src/components/items/create-item-form/create-item-form.tsx +29 -0
- package/src/components/items/create-item-form/locales/bg.ts +13 -0
- package/src/components/items/create-item-form/locales/cs.ts +13 -0
- package/src/components/items/create-item-form/locales/et.ts +13 -0
- package/src/components/items/create-item-form/locales/fi.ts +13 -0
- package/src/components/items/create-item-form/locales/is.ts +13 -0
- package/src/components/items/create-item-form/locales/nb.ts +13 -0
- package/src/components/items/create-item-form/locales/sk.ts +13 -0
- package/src/components/items/create-item-form/locales/sv.ts +13 -0
- package/src/components/items/edit-item-form/edit-item-form.tsx +39 -1
- package/src/components/items/edit-item-form/locales/bg.ts +12 -0
- package/src/components/items/edit-item-form/locales/cs.ts +12 -0
- package/src/components/items/edit-item-form/locales/en.ts +12 -0
- package/src/components/items/edit-item-form/locales/et.ts +12 -0
- package/src/components/items/edit-item-form/locales/fi.ts +12 -0
- package/src/components/items/edit-item-form/locales/is.ts +12 -0
- package/src/components/items/edit-item-form/locales/nb.ts +12 -0
- package/src/components/items/edit-item-form/locales/sk.ts +12 -0
- package/src/components/items/edit-item-form/locales/sv.ts +12 -0
- package/src/components/items/item-combobox.tsx +51 -18
- package/src/components/items/item-list-table/item-list-table.tsx +47 -23
- package/src/components/items/item-list-table/locales/bg.ts +16 -0
- package/src/components/items/item-list-table/locales/cs.ts +16 -0
- package/src/components/items/item-list-table/locales/en.ts +4 -3
- package/src/components/items/item-list-table/locales/et.ts +16 -0
- package/src/components/items/item-list-table/locales/fi.ts +16 -0
- package/src/components/items/item-list-table/locales/is.ts +16 -0
- package/src/components/items/item-list-table/locales/nb.ts +16 -0
- package/src/components/items/item-list-table/locales/sk.ts +16 -0
- package/src/components/items/item-list-table/locales/sv.ts +16 -0
- package/src/components/items/items.hooks.ts +15 -15
- package/src/components/payments/create-payment-form/create-payment-form.tsx +11 -7
- package/src/components/payments/create-payment-form/locales/bg.ts +20 -0
- package/src/components/payments/create-payment-form/locales/cs.ts +20 -0
- package/src/components/payments/create-payment-form/locales/en.ts +20 -0
- package/src/components/payments/create-payment-form/locales/et.ts +20 -0
- package/src/components/payments/create-payment-form/locales/fi.ts +20 -0
- package/src/components/payments/create-payment-form/locales/hr.ts +2 -2
- package/src/components/payments/create-payment-form/locales/is.ts +20 -0
- package/src/components/payments/create-payment-form/locales/nb.ts +20 -0
- package/src/components/payments/create-payment-form/locales/sk.ts +20 -0
- package/src/components/payments/create-payment-form/locales/sl.ts +4 -4
- package/src/components/payments/create-payment-form/locales/sv.ts +20 -0
- package/src/components/payments/edit-payment-form/edit-payment-form.tsx +5 -1
- package/src/components/payments/edit-payment-form/locales/bg.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/cs.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/en.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/et.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/fi.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/hr.ts +2 -2
- package/src/components/payments/edit-payment-form/locales/is.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/nb.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/sk.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/sl.ts +4 -4
- package/src/components/payments/edit-payment-form/locales/sv.ts +20 -0
- package/src/components/payments/list/list-row-actions.tsx +10 -2
- package/src/components/payments/list/list-table.tsx +51 -45
- package/src/components/payments/list/locales/bg.ts +42 -0
- package/src/components/payments/list/locales/cs.ts +42 -0
- package/src/components/payments/list/locales/de.ts +18 -0
- package/src/components/payments/list/locales/en.ts +37 -2
- package/src/components/payments/list/locales/es.ts +18 -0
- package/src/components/payments/list/locales/et.ts +42 -0
- package/src/components/payments/list/locales/fi.ts +42 -0
- package/src/components/payments/list/locales/fr.ts +18 -0
- package/src/components/payments/list/locales/hr.ts +18 -0
- package/src/components/payments/list/locales/is.ts +42 -0
- package/src/components/payments/list/locales/it.ts +18 -0
- package/src/components/payments/list/locales/nb.ts +42 -0
- package/src/components/payments/list/locales/nl.ts +18 -0
- package/src/components/payments/list/locales/pl.ts +18 -0
- package/src/components/payments/list/locales/pt.ts +18 -0
- package/src/components/payments/list/locales/sk.ts +42 -0
- package/src/components/payments/list/locales/sl.ts +18 -1
- package/src/components/payments/list/locales/sv.ts +42 -0
- package/src/components/payments/payments.hooks.ts +13 -6
- package/src/components/recurring-invoices/create-recurring-invoice-form/create-recurring-invoice-form.tsx +23 -17
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/bg.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/cs.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/en.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/et.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/fi.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/hr.ts +6 -6
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/is.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/nb.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/sk.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/sl.ts +4 -4
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/sv.ts +44 -0
- package/src/components/recurring-invoices/list/list-row-actions.tsx +3 -5
- package/src/components/recurring-invoices/list/list-table.tsx +10 -7
- package/src/components/recurring-invoices/list/locales/bg.ts +28 -0
- package/src/components/recurring-invoices/list/locales/cs.ts +28 -0
- package/src/components/recurring-invoices/list/locales/en.ts +23 -0
- package/src/components/recurring-invoices/list/locales/et.ts +28 -0
- package/src/components/recurring-invoices/list/locales/fi.ts +28 -0
- package/src/components/recurring-invoices/list/locales/is.ts +28 -0
- package/src/components/recurring-invoices/list/locales/nb.ts +28 -0
- package/src/components/recurring-invoices/list/locales/sk.ts +28 -0
- package/src/components/recurring-invoices/list/locales/sv.ts +28 -0
- package/src/components/recurring-invoices/recurring-invoices.hooks.ts +11 -8
- package/src/components/request-logs/request-log-detail.tsx +30 -23
- package/src/components/request-logs/request-log-list-table.tsx +88 -45
- package/src/components/table/README.md +47 -9
- package/src/components/table/data-table.tsx +232 -92
- package/src/components/table/filter-bar.tsx +1 -1
- package/src/components/table/filter-panel.tsx +51 -22
- package/src/components/table/hooks/use-table-state.ts +64 -11
- package/src/components/table/index.ts +3 -0
- package/src/components/table/locales.ts +119 -4
- package/src/components/table/selection-toolbar.tsx +65 -9
- package/src/components/table/sorting.ts +80 -0
- package/src/components/table/table-skeleton.tsx +15 -9
- package/src/components/table/types.ts +17 -0
- package/src/components/tax-reports/index.ts +8 -0
- package/src/components/tax-reports/kir-export-form.tsx +4 -5
- package/src/components/tax-reports/slovenia-accounting-mappings-fields.tsx +271 -0
- package/src/components/tax-reports/slovenia-tax-profile-step.tsx +21 -10
- package/src/components/tax-reports/slovenia-vod-export-form.tsx +452 -0
- package/src/components/tax-reports/slovenia-yearly-export-form.tsx +17 -16
- package/src/components/tax-reports/slovenia-yearly-review-step.tsx +40 -18
- package/src/components/taxes/create-tax-form/create-tax-form.tsx +48 -2
- package/src/components/taxes/create-tax-form/locales/bg.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/cs.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/et.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/fi.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/is.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/nb.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/sk.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/sv.ts +8 -0
- package/src/components/taxes/edit-tax-form/edit-tax-form.tsx +80 -11
- package/src/components/taxes/edit-tax-form/locales/bg.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/cs.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/en.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/et.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/fi.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/is.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/nb.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/sk.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/sv.ts +6 -0
- package/src/components/taxes/tax-list-table/locales/bg.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/cs.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/en.ts +4 -3
- package/src/components/taxes/tax-list-table/locales/et.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/fi.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/is.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/nb.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/sk.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/sv.ts +17 -0
- package/src/components/taxes/tax-list-table/tax-list-table.tsx +53 -19
- package/src/components/taxes/taxes.hooks.ts +53 -12
- package/src/components/ui/badge.tsx +1 -1
- package/src/components/ui/button.tsx +1 -1
- package/src/components/ui/drawer.tsx +2 -2
- package/src/components/ui/form.tsx +118 -2
- package/src/components/ui/progress.tsx +6 -4
- package/src/components/ui/select.tsx +118 -1
- package/src/components/ui/sonner.tsx +17 -36
- package/src/components/ui/sticky-form-footer.tsx +6 -1
- package/src/components/ui/tooltip.tsx +15 -2
- package/src/components/webhook-logs/webhook-delivery-detail.tsx +22 -22
- package/src/components/webhook-logs/webhook-delivery-list-table.tsx +92 -17
- package/src/components/wl-subscription/locked-feature.tsx +11 -10
- package/src/components/wl-subscription/paywall.tsx +184 -72
- package/src/components/wl-subscription/upgrade-modal.tsx +28 -31
- package/src/generate-schemas.ts +14 -4
- package/src/generated/schemas/account_webhook.ts +43 -0
- package/src/generated/schemas/accountwebhook.ts +67 -0
- package/src/generated/schemas/entity.ts +255 -16
- package/src/generated/schemas/exportsloveniavodxml_body.ts +16 -0
- package/src/generated/schemas/furssettings.ts +1 -0
- package/src/generated/schemas/incomingpurchasedocument.ts +198 -0
- package/src/generated/schemas/incomingpurchasedocumentpayment.ts +38 -0
- package/src/generated/schemas/index.ts +10 -0
- package/src/generated/schemas/item.ts +36 -0
- package/src/generated/schemas/me.ts +23 -19
- package/src/generated/schemas/order.ts +2 -0
- package/src/generated/schemas/orderintegration.ts +8 -4
- package/src/generated/schemas/payment.ts +5 -0
- package/src/generated/schemas/ptatcudseries.ts +30 -0
- package/src/generated/schemas/renderadvanceinvoicepreview_body.ts +35 -3
- package/src/generated/schemas/rendercreditnotepreview_body.ts +35 -3
- package/src/generated/schemas/renderdeliverynotepreview_body.ts +12 -5
- package/src/generated/schemas/renderestimatepreview_body.ts +38 -5
- package/src/generated/schemas/renderinvoicepreview_body.ts +39 -5
- package/src/generated/schemas/senddocument_body.ts +1 -0
- package/src/generated/schemas/sendemail_body.ts +67 -39
- package/src/generated/schemas/sloveniataxprofile.ts +97 -21
- package/src/generated/schemas/starteslogexport_body.ts +33 -0
- package/src/generated/schemas/startpdfexport_body.ts +94 -78
- package/src/generated/schemas/supplier.ts +59 -0
- package/src/generated/schemas/syncshopifyorders_body.ts +20 -0
- package/src/generated/schemas/tax.ts +2 -0
- package/src/generated/schemas/uploadfile_body.ts +1 -0
- package/src/generated/schemas/userptsettings.ts +26 -0
- package/src/generated/schemas/voidinvoice_body.ts +20 -0
- package/src/generated/schemas/webhook.ts +2 -0
- package/src/hooks/create-resource-hooks.ts +22 -19
- package/src/hooks/use-duplicate-document.ts +10 -8
- package/src/hooks/use-eslog-validation.ts +5 -1
- package/src/hooks/use-next-document-number.ts +13 -6
- package/src/hooks/use-resolved-entity-id.ts +14 -0
- package/src/hooks/use-resource-mutation.ts +11 -30
- package/src/hooks/use-transaction-type-check.ts +3 -8
- package/src/lib/browser-cookies.ts +1 -1
- package/src/lib/country-capabilities.ts +114 -0
- package/src/lib/date-fns-locale.ts +1 -20
- package/src/lib/eslog-export.ts +32 -0
- package/src/lib/fiscalization-options.ts +21 -1
- package/src/lib/formatting.ts +27 -0
- package/src/lib/furs-error-utils.ts +29 -0
- package/src/lib/locale.ts +4 -0
- package/src/lib/payment-display.ts +95 -0
- package/src/lib/pt-document-input.ts +67 -0
- package/src/lib/schemas/shared.ts +1 -0
- package/src/lib/template-variables.tsx +102 -4
- package/src/lib/translation.ts +51 -33
- package/src/lib/white-label-capabilities.ts +626 -0
- package/src/lib/zod-validation-message.ts +291 -0
- package/src/providers/entities-provider.tsx +32 -14
- package/src/providers/sdk-provider.tsx +112 -12
- package/src/providers/space-invoices-provider.tsx +129 -0
- package/src/providers/white-label-provider.tsx +96 -4
- package/src/providers/wl-subscription-provider.tsx +144 -10
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { getLocaleLanguage } from "./locale";
|
|
2
|
+
|
|
3
|
+
type ValidationDictionary = {
|
|
4
|
+
required: string;
|
|
5
|
+
minChars: (count: number) => string;
|
|
6
|
+
maxChars: (count: number) => string;
|
|
7
|
+
exactDigits: (count: number) => string;
|
|
8
|
+
digitsOnly: string;
|
|
9
|
+
invalidEmail: string;
|
|
10
|
+
invalidFormat: string;
|
|
11
|
+
invalidValue: string;
|
|
12
|
+
alphanumericRange: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const dictionaries: Record<string, ValidationDictionary> = {
|
|
16
|
+
en: {
|
|
17
|
+
required: "Required",
|
|
18
|
+
minChars: (count) => `Must be at least ${count} characters`,
|
|
19
|
+
maxChars: (count) => `Must be at most ${count} characters`,
|
|
20
|
+
exactDigits: (count) => `Must be exactly ${count} digits`,
|
|
21
|
+
digitsOnly: "Must contain only digits",
|
|
22
|
+
invalidEmail: "Invalid email address",
|
|
23
|
+
invalidFormat: "Invalid format",
|
|
24
|
+
invalidValue: "Invalid value",
|
|
25
|
+
alphanumericRange: "Must be alphanumeric, 1-20 characters",
|
|
26
|
+
},
|
|
27
|
+
de: {
|
|
28
|
+
required: "Erforderlich",
|
|
29
|
+
minChars: (count) => `Muss mindestens ${count} Zeichen enthalten`,
|
|
30
|
+
maxChars: (count) => `Darf höchstens ${count} Zeichen enthalten`,
|
|
31
|
+
exactDigits: (count) => `Muss genau ${count} Ziffern enthalten`,
|
|
32
|
+
digitsOnly: "Darf nur Ziffern enthalten",
|
|
33
|
+
invalidEmail: "Ungultige E-Mail-Adresse",
|
|
34
|
+
invalidFormat: "Ungultiges Format",
|
|
35
|
+
invalidValue: "Ungultiger Wert",
|
|
36
|
+
alphanumericRange: "Muss alphanumerisch sein, 1-20 Zeichen",
|
|
37
|
+
},
|
|
38
|
+
es: {
|
|
39
|
+
required: "Obligatorio",
|
|
40
|
+
minChars: (count) => `Debe tener al menos ${count} caracteres`,
|
|
41
|
+
maxChars: (count) => `Debe tener como maximo ${count} caracteres`,
|
|
42
|
+
exactDigits: (count) => `Debe tener exactamente ${count} digitos`,
|
|
43
|
+
digitsOnly: "Debe contener solo digitos",
|
|
44
|
+
invalidEmail: "Direccion de correo electronico no valida",
|
|
45
|
+
invalidFormat: "Formato no valido",
|
|
46
|
+
invalidValue: "Valor no valido",
|
|
47
|
+
alphanumericRange: "Debe ser alfanumerico y tener entre 1 y 20 caracteres",
|
|
48
|
+
},
|
|
49
|
+
fr: {
|
|
50
|
+
required: "Obligatoire",
|
|
51
|
+
minChars: (count) => `Doit contenir au moins ${count} caracteres`,
|
|
52
|
+
maxChars: (count) => `Doit contenir au maximum ${count} caracteres`,
|
|
53
|
+
exactDigits: (count) => `Doit contenir exactement ${count} chiffres`,
|
|
54
|
+
digitsOnly: "Doit contenir uniquement des chiffres",
|
|
55
|
+
invalidEmail: "Adresse e-mail invalide",
|
|
56
|
+
invalidFormat: "Format invalide",
|
|
57
|
+
invalidValue: "Valeur invalide",
|
|
58
|
+
alphanumericRange: "Doit etre alphanumerique, 1 a 20 caracteres",
|
|
59
|
+
},
|
|
60
|
+
hr: {
|
|
61
|
+
required: "Obavezno",
|
|
62
|
+
minChars: (count) => `Mora sadrzavati najmanje ${count} znakova`,
|
|
63
|
+
maxChars: (count) => `Smije sadrzavati najvise ${count} znakova`,
|
|
64
|
+
exactDigits: (count) => `Mora sadrzavati tocno ${count} znamenke`,
|
|
65
|
+
digitsOnly: "Mora sadrzavati samo znamenke",
|
|
66
|
+
invalidEmail: "Neispravna e-mail adresa",
|
|
67
|
+
invalidFormat: "Neispravan format",
|
|
68
|
+
invalidValue: "Neispravna vrijednost",
|
|
69
|
+
alphanumericRange: "Mora biti alfanumericko, 1-20 znakova",
|
|
70
|
+
},
|
|
71
|
+
bg: {
|
|
72
|
+
required: "Zadalzhitelno",
|
|
73
|
+
minChars: (count) => `Tryabva da sadrzha pone ${count} znaka`,
|
|
74
|
+
maxChars: (count) => `Mozhe da sadrzha nai-mnogo ${count} znaka`,
|
|
75
|
+
exactDigits: (count) => `Tryabva da sadrzha tochno ${count} cifri`,
|
|
76
|
+
digitsOnly: "Tryabva da sadrzha samo cifri",
|
|
77
|
+
invalidEmail: "Nevaliden email adres",
|
|
78
|
+
invalidFormat: "Nevaliden format",
|
|
79
|
+
invalidValue: "Nevalidna stoinost",
|
|
80
|
+
alphanumericRange: "Tryabva da e bukveno-cifrovo, 1-20 znaka",
|
|
81
|
+
},
|
|
82
|
+
cs: {
|
|
83
|
+
required: "Povinne",
|
|
84
|
+
minChars: (count) => `Musi obsahovat alespon ${count} znaku`,
|
|
85
|
+
maxChars: (count) => `Muze obsahovat nejvyse ${count} znaku`,
|
|
86
|
+
exactDigits: (count) => `Musi obsahovat presne ${count} cislice`,
|
|
87
|
+
digitsOnly: "Musi obsahovat pouze cislice",
|
|
88
|
+
invalidEmail: "Neplatna e-mailova adresa",
|
|
89
|
+
invalidFormat: "Neplatny format",
|
|
90
|
+
invalidValue: "Neplatna hodnota",
|
|
91
|
+
alphanumericRange: "Musi byt alfanumericke, 1-20 znaku",
|
|
92
|
+
},
|
|
93
|
+
et: {
|
|
94
|
+
required: "Kohustuslik",
|
|
95
|
+
minChars: (count) => `Peab sisaldama vahemalt ${count} marki`,
|
|
96
|
+
maxChars: (count) => `Voib sisaldada kuni ${count} marki`,
|
|
97
|
+
exactDigits: (count) => `Peab sisaldama tapselt ${count} numbrit`,
|
|
98
|
+
digitsOnly: "Tohib sisaldada ainult numbreid",
|
|
99
|
+
invalidEmail: "Vigane e-posti aadress",
|
|
100
|
+
invalidFormat: "Vigane vorming",
|
|
101
|
+
invalidValue: "Vigane vaartus",
|
|
102
|
+
alphanumericRange: "Peab olema tahe- ja numbrimarkidega, 1-20 marki",
|
|
103
|
+
},
|
|
104
|
+
fi: {
|
|
105
|
+
required: "Pakollinen",
|
|
106
|
+
minChars: (count) => `Vahintaan ${count} merkkiä`,
|
|
107
|
+
maxChars: (count) => `Enintaan ${count} merkkiä`,
|
|
108
|
+
exactDigits: (count) => `Taytyy olla tasan ${count} numeroa`,
|
|
109
|
+
digitsOnly: "Saa sisaltaa vain numeroita",
|
|
110
|
+
invalidEmail: "Virheellinen sahkopostiosoite",
|
|
111
|
+
invalidFormat: "Virheellinen muoto",
|
|
112
|
+
invalidValue: "Virheellinen arvo",
|
|
113
|
+
alphanumericRange: "Taytyy olla aakkosnumeerinen, 1-20 merkkia",
|
|
114
|
+
},
|
|
115
|
+
it: {
|
|
116
|
+
required: "Obbligatorio",
|
|
117
|
+
minChars: (count) => `Deve contenere almeno ${count} caratteri`,
|
|
118
|
+
maxChars: (count) => `Deve contenere al massimo ${count} caratteri`,
|
|
119
|
+
exactDigits: (count) => `Deve contenere esattamente ${count} cifre`,
|
|
120
|
+
digitsOnly: "Deve contenere solo cifre",
|
|
121
|
+
invalidEmail: "Indirizzo email non valido",
|
|
122
|
+
invalidFormat: "Formato non valido",
|
|
123
|
+
invalidValue: "Valore non valido",
|
|
124
|
+
alphanumericRange: "Deve essere alfanumerico, 1-20 caratteri",
|
|
125
|
+
},
|
|
126
|
+
nl: {
|
|
127
|
+
required: "Verplicht",
|
|
128
|
+
minChars: (count) => `Moet minimaal ${count} tekens bevatten`,
|
|
129
|
+
maxChars: (count) => `Mag maximaal ${count} tekens bevatten`,
|
|
130
|
+
exactDigits: (count) => `Moet precies ${count} cijfers bevatten`,
|
|
131
|
+
digitsOnly: "Mag alleen cijfers bevatten",
|
|
132
|
+
invalidEmail: "Ongeldig e-mailadres",
|
|
133
|
+
invalidFormat: "Ongeldig formaat",
|
|
134
|
+
invalidValue: "Ongeldige waarde",
|
|
135
|
+
alphanumericRange: "Moet alfanumeriek zijn, 1-20 tekens",
|
|
136
|
+
},
|
|
137
|
+
nb: {
|
|
138
|
+
required: "Obligatorisk",
|
|
139
|
+
minChars: (count) => `Må inneholde minst ${count} tegn`,
|
|
140
|
+
maxChars: (count) => `Kan inneholde maksimalt ${count} tegn`,
|
|
141
|
+
exactDigits: (count) => `Må inneholde nøyaktig ${count} sifre`,
|
|
142
|
+
digitsOnly: "Må bare inneholde sifre",
|
|
143
|
+
invalidEmail: "Ugyldig e-postadresse",
|
|
144
|
+
invalidFormat: "Ugyldig format",
|
|
145
|
+
invalidValue: "Ugyldig verdi",
|
|
146
|
+
alphanumericRange: "Må være alfanumerisk, 1-20 tegn",
|
|
147
|
+
},
|
|
148
|
+
pl: {
|
|
149
|
+
required: "Wymagane",
|
|
150
|
+
minChars: (count) => `Musi zawierac co najmniej ${count} znakow`,
|
|
151
|
+
maxChars: (count) => `Moze zawierac maksymalnie ${count} znakow`,
|
|
152
|
+
exactDigits: (count) => `Musi zawierac dokladnie ${count} cyfry`,
|
|
153
|
+
digitsOnly: "Musi zawierac tylko cyfry",
|
|
154
|
+
invalidEmail: "Nieprawidlowy adres e-mail",
|
|
155
|
+
invalidFormat: "Nieprawidlowy format",
|
|
156
|
+
invalidValue: "Nieprawidlowa wartosc",
|
|
157
|
+
alphanumericRange: "Musi byc alfanumeryczne, 1-20 znakow",
|
|
158
|
+
},
|
|
159
|
+
pt: {
|
|
160
|
+
required: "Obrigatorio",
|
|
161
|
+
minChars: (count) => `Tem de ter pelo menos ${count} caracteres`,
|
|
162
|
+
maxChars: (count) => `Tem de ter no maximo ${count} caracteres`,
|
|
163
|
+
exactDigits: (count) => `Tem de ter exatamente ${count} digitos`,
|
|
164
|
+
digitsOnly: "Tem de conter apenas digitos",
|
|
165
|
+
invalidEmail: "Endereco de email invalido",
|
|
166
|
+
invalidFormat: "Formato invalido",
|
|
167
|
+
invalidValue: "Valor invalido",
|
|
168
|
+
alphanumericRange: "Tem de ser alfanumerico, 1-20 caracteres",
|
|
169
|
+
},
|
|
170
|
+
sk: {
|
|
171
|
+
required: "Povinne",
|
|
172
|
+
minChars: (count) => `Musi obsahovat aspon ${count} znakov`,
|
|
173
|
+
maxChars: (count) => `Moze obsahovat najviac ${count} znakov`,
|
|
174
|
+
exactDigits: (count) => `Musi obsahovat presne ${count} cislice`,
|
|
175
|
+
digitsOnly: "Musi obsahovat iba cislice",
|
|
176
|
+
invalidEmail: "Neplatna e-mailova adresa",
|
|
177
|
+
invalidFormat: "Neplatny format",
|
|
178
|
+
invalidValue: "Neplatna hodnota",
|
|
179
|
+
alphanumericRange: "Musi byt alfanumericke, 1-20 znakov",
|
|
180
|
+
},
|
|
181
|
+
sl: {
|
|
182
|
+
required: "Obvezno",
|
|
183
|
+
minChars: (count) => `Mora vsebovati vsaj ${count} znakov`,
|
|
184
|
+
maxChars: (count) => `Lahko vsebuje najvec ${count} znakov`,
|
|
185
|
+
exactDigits: (count) => `Mora vsebovati natanko ${count} stevilke`,
|
|
186
|
+
digitsOnly: "Vsebovati mora samo stevilke",
|
|
187
|
+
invalidEmail: "Neveljaven e-postni naslov",
|
|
188
|
+
invalidFormat: "Neveljaven format",
|
|
189
|
+
invalidValue: "Neveljavna vrednost",
|
|
190
|
+
alphanumericRange: "Mora biti alfanumericno, 1-20 znakov",
|
|
191
|
+
},
|
|
192
|
+
sv: {
|
|
193
|
+
required: "Obligatoriskt",
|
|
194
|
+
minChars: (count) => `Maste innehalla minst ${count} tecken`,
|
|
195
|
+
maxChars: (count) => `Far innehalla hogst ${count} tecken`,
|
|
196
|
+
exactDigits: (count) => `Maste innehalla exakt ${count} siffror`,
|
|
197
|
+
digitsOnly: "Får bara innehålla siffror",
|
|
198
|
+
invalidEmail: "Ogiltig e-postadress",
|
|
199
|
+
invalidFormat: "Ogiltigt format",
|
|
200
|
+
invalidValue: "Ogiltigt varde",
|
|
201
|
+
alphanumericRange: "Maste vara alfanumeriskt, 1-20 tecken",
|
|
202
|
+
},
|
|
203
|
+
is: {
|
|
204
|
+
required: "Skyldureitur",
|
|
205
|
+
minChars: (count) => `Verdur ad innihalda ad minnsta kosti ${count} stafi`,
|
|
206
|
+
maxChars: (count) => `Ma innihalda ad haesta lagi ${count} stafi`,
|
|
207
|
+
exactDigits: (count) => `Verdur ad innihalda natturlega ${count} tolustafi`,
|
|
208
|
+
digitsOnly: "Ma einungis innihalda tolustafi",
|
|
209
|
+
invalidEmail: "Ogiltt netfang",
|
|
210
|
+
invalidFormat: "Ogilt snið",
|
|
211
|
+
invalidValue: "Ogilt gildi",
|
|
212
|
+
alphanumericRange: "Verdur ad vera bokstafa- og tolustafablandad, 1-20 stafir",
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const tooSmallStringRegex = /^Too small: expected string to have >=(\d+) characters$/;
|
|
217
|
+
const tooBigStringRegex = /^Too big: expected string to have <=(\d+) characters$/;
|
|
218
|
+
const invalidPatternRegex = /^Invalid string: must match pattern (\/.*\/)$/;
|
|
219
|
+
const invalidInputRegex = /^Invalid input: expected .*$/;
|
|
220
|
+
|
|
221
|
+
function getDictionary(locale?: string): ValidationDictionary {
|
|
222
|
+
const language = getLocaleLanguage(locale);
|
|
223
|
+
return dictionaries[language] ?? dictionaries.en;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function normalizePattern(pattern: string): string {
|
|
227
|
+
return pattern.replaceAll("\\\\", "\\");
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export function getValidationLocale(explicitLocale?: string): string {
|
|
231
|
+
if (explicitLocale?.trim()) return explicitLocale;
|
|
232
|
+
|
|
233
|
+
if (typeof document !== "undefined") {
|
|
234
|
+
const htmlLang = document.documentElement.lang?.trim();
|
|
235
|
+
if (htmlLang) return htmlLang;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (typeof navigator !== "undefined" && navigator.language) {
|
|
239
|
+
return navigator.language;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return "en";
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export function translateZodValidationMessage(message?: string, locale?: string): string | undefined {
|
|
246
|
+
if (!message) return message;
|
|
247
|
+
|
|
248
|
+
const dict = getDictionary(locale);
|
|
249
|
+
|
|
250
|
+
if (message === "Invalid email address") {
|
|
251
|
+
return dict.invalidEmail;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (message === "Must be alphanumeric, 1-20 characters") {
|
|
255
|
+
return dict.alphanumericRange;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const tooSmallMatch = message.match(tooSmallStringRegex);
|
|
259
|
+
if (tooSmallMatch) {
|
|
260
|
+
const count = Number.parseInt(tooSmallMatch[1] || "0", 10);
|
|
261
|
+
return count <= 1 ? dict.required : dict.minChars(count);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const tooBigMatch = message.match(tooBigStringRegex);
|
|
265
|
+
if (tooBigMatch) {
|
|
266
|
+
const count = Number.parseInt(tooBigMatch[1] || "0", 10);
|
|
267
|
+
return dict.maxChars(count);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const invalidPatternMatch = message.match(invalidPatternRegex);
|
|
271
|
+
if (invalidPatternMatch) {
|
|
272
|
+
const pattern = normalizePattern(invalidPatternMatch[1] || "");
|
|
273
|
+
|
|
274
|
+
if (pattern === "/^\\d+$/") {
|
|
275
|
+
return dict.digitsOnly;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const exactDigitsMatch = pattern.match(/^\/\^\\d\{(\d+)\}\$\/$/);
|
|
279
|
+
if (exactDigitsMatch) {
|
|
280
|
+
return dict.exactDigits(Number.parseInt(exactDigitsMatch[1] || "0", 10));
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return dict.invalidFormat;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (invalidInputRegex.test(message)) {
|
|
287
|
+
return dict.invalidValue;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return message;
|
|
291
|
+
}
|
|
@@ -3,8 +3,8 @@ import type { ReactNode } from "react";
|
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { useCookies } from "react-cookie";
|
|
5
5
|
import { ACTIVE_ENTITY_COOKIE, ACTIVE_ENVIRONMENT_COOKIE } from "@/ui/components/entities/keys";
|
|
6
|
-
|
|
7
|
-
import {
|
|
6
|
+
import { useSpaceInvoicesRuntime } from "@/ui/providers/space-invoices-provider";
|
|
7
|
+
import { entities as entitiesApi } from "../../../js-sdk/src/sdk/entities";
|
|
8
8
|
|
|
9
9
|
import { EntitiesContext, type Entity, type EntityEnvironment } from "./entities-context";
|
|
10
10
|
|
|
@@ -29,7 +29,7 @@ type EntitiesProviderProps = {
|
|
|
29
29
|
/** When provided, determines environment from URL instead of cookie. true = sandbox, false = live. */
|
|
30
30
|
isSandbox?: boolean;
|
|
31
31
|
/** Called when urlEntityId is not found in any environment, allowing parent to try other accounts */
|
|
32
|
-
onEntityNotFound?: (entityId: string) => boolean |
|
|
32
|
+
onEntityNotFound?: (entityId: string) => boolean | undefined | Promise<boolean | undefined>;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
export function EntitiesProvider({
|
|
@@ -41,7 +41,7 @@ export function EntitiesProvider({
|
|
|
41
41
|
isSandbox,
|
|
42
42
|
onEntityNotFound,
|
|
43
43
|
}: EntitiesProviderProps) {
|
|
44
|
-
const {
|
|
44
|
+
const { hasAccessToken, isResolvingAccessToken } = useSpaceInvoicesRuntime();
|
|
45
45
|
const [cookies, setCookie, removeCookie] = useCookies([ACTIVE_ENTITY_COOKIE, ACTIVE_ENVIRONMENT_COOKIE]);
|
|
46
46
|
const isInitialMount = useRef(true);
|
|
47
47
|
const initialEnvironmentFromCookie = cookies[ACTIVE_ENVIRONMENT_COOKIE] as EntityEnvironment | undefined;
|
|
@@ -91,13 +91,10 @@ export function EntitiesProvider({
|
|
|
91
91
|
} = useQuery({
|
|
92
92
|
queryKey: [...ENTITIES_QUERY_KEY, environment],
|
|
93
93
|
queryFn: async () => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
// Pass environment to filter entities for user tokens
|
|
97
|
-
const response = await sdk.entities.list({ limit: 100, environment });
|
|
94
|
+
const response = await entitiesApi.list({ limit: 100, environment });
|
|
98
95
|
return response.data;
|
|
99
96
|
},
|
|
100
|
-
enabled:
|
|
97
|
+
enabled: hasAccessToken && !isResolvingAccessToken,
|
|
101
98
|
staleTime: 1000 * 60 * 5,
|
|
102
99
|
gcTime: 1000 * 60 * 60,
|
|
103
100
|
retry: 2,
|
|
@@ -119,7 +116,28 @@ export function EntitiesProvider({
|
|
|
119
116
|
const refetchKey = `${urlEntityId}:${environment}`;
|
|
120
117
|
if (emptyUrlEntityRefetchKeyRef.current !== refetchKey) {
|
|
121
118
|
emptyUrlEntityRefetchKeyRef.current = refetchKey;
|
|
122
|
-
void refetch()
|
|
119
|
+
void refetch().then((result) => {
|
|
120
|
+
if ((result.data?.length ?? 0) > 0 || hasCalledNoEntities.current) return;
|
|
121
|
+
if (resolvingUrlEntityRef.current === urlEntityId) return;
|
|
122
|
+
resolvingUrlEntityRef.current = urlEntityId;
|
|
123
|
+
|
|
124
|
+
if (!onEntityNotFound) {
|
|
125
|
+
hasCalledNoEntities.current = true;
|
|
126
|
+
onNoEntities?.();
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
void Promise.resolve(onEntityNotFound(urlEntityId))
|
|
131
|
+
.then((resolved) => {
|
|
132
|
+
if (resolved) return;
|
|
133
|
+
hasCalledNoEntities.current = true;
|
|
134
|
+
onNoEntities?.();
|
|
135
|
+
})
|
|
136
|
+
.catch(() => {
|
|
137
|
+
hasCalledNoEntities.current = true;
|
|
138
|
+
onNoEntities?.();
|
|
139
|
+
});
|
|
140
|
+
});
|
|
123
141
|
return;
|
|
124
142
|
}
|
|
125
143
|
|
|
@@ -153,10 +171,10 @@ export function EntitiesProvider({
|
|
|
153
171
|
}
|
|
154
172
|
|
|
155
173
|
// Try the other environment before calling onNoEntities
|
|
156
|
-
if (!hasTriedFallback.current &&
|
|
174
|
+
if (!hasTriedFallback.current && hasAccessToken) {
|
|
157
175
|
hasTriedFallback.current = true;
|
|
158
176
|
const altEnv = environment === "live" ? "sandbox" : "live";
|
|
159
|
-
|
|
177
|
+
entitiesApi
|
|
160
178
|
.list({ limit: 1, environment: altEnv })
|
|
161
179
|
.then((res) => {
|
|
162
180
|
if (res.data.length > 0) {
|
|
@@ -184,7 +202,7 @@ export function EntitiesProvider({
|
|
|
184
202
|
onEntityNotFound,
|
|
185
203
|
onNoEntities,
|
|
186
204
|
refetch,
|
|
187
|
-
|
|
205
|
+
hasAccessToken,
|
|
188
206
|
environment,
|
|
189
207
|
isSandbox,
|
|
190
208
|
urlEntityId,
|
|
@@ -358,7 +376,7 @@ export function EntitiesProvider({
|
|
|
358
376
|
);
|
|
359
377
|
|
|
360
378
|
// Show loading state only if entities are still loading
|
|
361
|
-
if (isLoading) {
|
|
379
|
+
if (isResolvingAccessToken || isLoading) {
|
|
362
380
|
return <LoadingFallback />;
|
|
363
381
|
}
|
|
364
382
|
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import SDK from "@spaceinvoices/js-sdk";
|
|
1
|
+
import type SDK from "@spaceinvoices/js-sdk";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
4
|
-
|
|
5
4
|
import { AUTH_COOKIES } from "@/ui/lib/auth";
|
|
6
5
|
import { flushCookies, getCookie } from "@/ui/lib/browser-cookies";
|
|
6
|
+
import {
|
|
7
|
+
SpaceInvoicesProvider,
|
|
8
|
+
useAccessToken as useRuntimeAccessToken,
|
|
9
|
+
useSpaceInvoicesRuntime,
|
|
10
|
+
} from "@/ui/providers/space-invoices-provider";
|
|
7
11
|
|
|
8
12
|
/**
|
|
9
13
|
* SDK context type definition
|
|
@@ -38,6 +42,8 @@ type SDKProviderProps = {
|
|
|
38
42
|
fallbackUnauthorized?: ReactNode;
|
|
39
43
|
};
|
|
40
44
|
|
|
45
|
+
type LegacySDKContextBridgeProps = SDKProviderProps;
|
|
46
|
+
|
|
41
47
|
/**
|
|
42
48
|
* SDK Provider component
|
|
43
49
|
* Responsible for initializing the SDK and providing it to the application
|
|
@@ -76,7 +82,8 @@ export function SDKProvider({
|
|
|
76
82
|
}
|
|
77
83
|
|
|
78
84
|
const basePath = import.meta.env?.VITE_API_URL || import.meta.env?.BUN_PUBLIC_API_URL || undefined;
|
|
79
|
-
const
|
|
85
|
+
const { default: SDKConstructor } = await import("@spaceinvoices/js-sdk");
|
|
86
|
+
const newSDK = new SDKConstructor({
|
|
80
87
|
accessToken: token,
|
|
81
88
|
...(basePath && { basePath }),
|
|
82
89
|
onUnauthorized: (response: Response) => {
|
|
@@ -110,6 +117,7 @@ export function SDKProvider({
|
|
|
110
117
|
isLoading,
|
|
111
118
|
error,
|
|
112
119
|
reinitialize: initializeSDK,
|
|
120
|
+
accessToken: getCookie(AUTH_COOKIES.TOKEN) ?? null,
|
|
113
121
|
}),
|
|
114
122
|
[sdk, isInitialized, isLoading, error, initializeSDK],
|
|
115
123
|
);
|
|
@@ -128,6 +136,104 @@ export function SDKProvider({
|
|
|
128
136
|
return <>{fallbackUnauthorized}</>;
|
|
129
137
|
}
|
|
130
138
|
|
|
139
|
+
return (
|
|
140
|
+
<SpaceInvoicesProvider
|
|
141
|
+
accessToken={value.accessToken ?? ""}
|
|
142
|
+
basePath={import.meta.env?.VITE_API_URL || import.meta.env?.BUN_PUBLIC_API_URL || undefined}
|
|
143
|
+
onUnauthorized={(response) => {
|
|
144
|
+
flushCookies();
|
|
145
|
+
onUnauthorized?.(response);
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
<SDKContext.Provider value={value}>{children}</SDKContext.Provider>
|
|
149
|
+
</SpaceInvoicesProvider>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function LegacySDKContextBridge({
|
|
154
|
+
children,
|
|
155
|
+
onUnauthorized,
|
|
156
|
+
fallbackLoading = (
|
|
157
|
+
<div className="fixed inset-0 flex items-center justify-center bg-background/50">
|
|
158
|
+
<div className="h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" />
|
|
159
|
+
</div>
|
|
160
|
+
),
|
|
161
|
+
fallbackError = (error) => <div className="p-4 text-red-500">Error initializing SDK: {error.message}</div>,
|
|
162
|
+
fallbackUnauthorized = <div className="p-4 text-amber-500">No SDK available. Please log in first.</div>,
|
|
163
|
+
}: LegacySDKContextBridgeProps) {
|
|
164
|
+
const runtime = useSpaceInvoicesRuntime();
|
|
165
|
+
const [sdk, setSdk] = useState<SDK | null>(null);
|
|
166
|
+
const [error, setError] = useState<Error | null>(null);
|
|
167
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
168
|
+
|
|
169
|
+
const initializeSDK = useCallback(async () => {
|
|
170
|
+
if (runtime.isResolvingAccessToken) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
setIsLoading(true);
|
|
175
|
+
setError(null);
|
|
176
|
+
|
|
177
|
+
try {
|
|
178
|
+
if (!runtime.accessToken) {
|
|
179
|
+
setSdk(null);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const { default: SDKConstructor } = await import("@spaceinvoices/js-sdk");
|
|
184
|
+
const newSDK = new SDKConstructor({
|
|
185
|
+
accessToken: runtime.accessToken,
|
|
186
|
+
...(runtime.basePath && { basePath: runtime.basePath }),
|
|
187
|
+
...(runtime.clientName && { clientName: runtime.clientName }),
|
|
188
|
+
...(onUnauthorized && { onUnauthorized }),
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
setSdk(newSDK);
|
|
192
|
+
} catch (cause) {
|
|
193
|
+
setSdk(null);
|
|
194
|
+
setError(cause instanceof Error ? cause : new Error("Failed to initialize SDK"));
|
|
195
|
+
} finally {
|
|
196
|
+
setIsLoading(false);
|
|
197
|
+
}
|
|
198
|
+
}, [onUnauthorized, runtime.accessToken, runtime.basePath, runtime.clientName, runtime.isResolvingAccessToken]);
|
|
199
|
+
|
|
200
|
+
useEffect(() => {
|
|
201
|
+
void initializeSDK();
|
|
202
|
+
}, [initializeSDK]);
|
|
203
|
+
|
|
204
|
+
const combinedError = runtime.error ?? error;
|
|
205
|
+
const value = useMemo(
|
|
206
|
+
() => ({
|
|
207
|
+
sdk: sdk as SDK,
|
|
208
|
+
isInitialized: Boolean(sdk) && runtime.hasAccessToken,
|
|
209
|
+
isLoading: runtime.isResolvingAccessToken || isLoading,
|
|
210
|
+
error: combinedError,
|
|
211
|
+
reinitialize: initializeSDK,
|
|
212
|
+
accessToken: runtime.accessToken,
|
|
213
|
+
}),
|
|
214
|
+
[
|
|
215
|
+
sdk,
|
|
216
|
+
runtime.hasAccessToken,
|
|
217
|
+
runtime.isResolvingAccessToken,
|
|
218
|
+
isLoading,
|
|
219
|
+
combinedError,
|
|
220
|
+
initializeSDK,
|
|
221
|
+
runtime.accessToken,
|
|
222
|
+
],
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
if (runtime.isResolvingAccessToken || isLoading) {
|
|
226
|
+
return <>{fallbackLoading}</>;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (combinedError) {
|
|
230
|
+
return <>{fallbackError(combinedError)}</>;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (!sdk || !runtime.hasAccessToken) {
|
|
234
|
+
return <>{fallbackUnauthorized}</>;
|
|
235
|
+
}
|
|
236
|
+
|
|
131
237
|
return <SDKContext.Provider value={value}>{children}</SDKContext.Provider>;
|
|
132
238
|
}
|
|
133
239
|
|
|
@@ -159,13 +265,7 @@ export function useSDKOptional() {
|
|
|
159
265
|
* Checks context.accessToken first (set by embed mode), then falls back to cookies
|
|
160
266
|
*/
|
|
161
267
|
export function useAccessToken(): string | null {
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
// Embed mode passes token explicitly via context
|
|
166
|
-
if (context.accessToken) return context.accessToken;
|
|
167
|
-
|
|
168
|
-
// Normal mode: read from auth cookie
|
|
169
|
-
const token = getCookie(AUTH_COOKIES.TOKEN);
|
|
170
|
-
return token ?? null;
|
|
268
|
+
const runtimeToken = useRuntimeAccessToken();
|
|
269
|
+
if (runtimeToken) return runtimeToken;
|
|
270
|
+
return getCookie(AUTH_COOKIES.TOKEN) ?? null;
|
|
171
271
|
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
import { createContext, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { setAccountId } from "../../../js-sdk/src/mutator/custom-fetch";
|
|
6
|
+
import { initSDK } from "../../../js-sdk/src/sdk/init";
|
|
7
|
+
import type { SDKConfig } from "../../../js-sdk/src/sdk/types";
|
|
8
|
+
|
|
9
|
+
export type SpaceInvoicesRuntimeContextType = {
|
|
10
|
+
accessToken: string | null;
|
|
11
|
+
accountId: string | null;
|
|
12
|
+
basePath?: string;
|
|
13
|
+
clientName?: string;
|
|
14
|
+
hasAccessToken: boolean;
|
|
15
|
+
isResolvingAccessToken: boolean;
|
|
16
|
+
error: Error | null;
|
|
17
|
+
getAccessToken: () => Promise<string>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const SpaceInvoicesRuntimeContext = createContext<SpaceInvoicesRuntimeContextType | undefined>(undefined);
|
|
21
|
+
|
|
22
|
+
SpaceInvoicesRuntimeContext.displayName = "SpaceInvoicesRuntimeContext";
|
|
23
|
+
|
|
24
|
+
export type SpaceInvoicesProviderProps = {
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
accessToken: SDKConfig["accessToken"];
|
|
27
|
+
accountId?: string | null;
|
|
28
|
+
basePath?: string;
|
|
29
|
+
clientName?: string;
|
|
30
|
+
onUnauthorized?: SDKConfig["onUnauthorized"];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
async function resolveAccessToken(accessToken: SDKConfig["accessToken"]): Promise<string> {
|
|
34
|
+
const resolved = typeof accessToken === "function" ? await accessToken() : accessToken;
|
|
35
|
+
return resolved ?? "";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function SpaceInvoicesProvider({
|
|
39
|
+
children,
|
|
40
|
+
accessToken,
|
|
41
|
+
accountId = null,
|
|
42
|
+
basePath,
|
|
43
|
+
clientName,
|
|
44
|
+
onUnauthorized,
|
|
45
|
+
}: SpaceInvoicesProviderProps) {
|
|
46
|
+
const [resolvedAccessToken, setResolvedAccessToken] = useState<string | null>(null);
|
|
47
|
+
const [error, setError] = useState<Error | null>(null);
|
|
48
|
+
const [isResolvingAccessToken, setIsResolvingAccessToken] = useState(true);
|
|
49
|
+
const onUnauthorizedRef = useRef(onUnauthorized);
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
onUnauthorizedRef.current = onUnauthorized;
|
|
53
|
+
}, [onUnauthorized]);
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
let cancelled = false;
|
|
57
|
+
|
|
58
|
+
setIsResolvingAccessToken(true);
|
|
59
|
+
setError(null);
|
|
60
|
+
|
|
61
|
+
initSDK({
|
|
62
|
+
accessToken,
|
|
63
|
+
...(basePath && { basePath }),
|
|
64
|
+
...(clientName && { clientName }),
|
|
65
|
+
...(onUnauthorizedRef.current && {
|
|
66
|
+
onUnauthorized: (response) => onUnauthorizedRef.current?.(response),
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
void resolveAccessToken(accessToken)
|
|
71
|
+
.then((token) => {
|
|
72
|
+
if (cancelled) return;
|
|
73
|
+
setResolvedAccessToken(token || null);
|
|
74
|
+
})
|
|
75
|
+
.catch((cause) => {
|
|
76
|
+
if (cancelled) return;
|
|
77
|
+
setResolvedAccessToken(null);
|
|
78
|
+
setError(cause instanceof Error ? cause : new Error("Failed to resolve Space Invoices access token"));
|
|
79
|
+
})
|
|
80
|
+
.finally(() => {
|
|
81
|
+
if (!cancelled) {
|
|
82
|
+
setIsResolvingAccessToken(false);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
return () => {
|
|
87
|
+
cancelled = true;
|
|
88
|
+
};
|
|
89
|
+
}, [accessToken, basePath, clientName]);
|
|
90
|
+
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
setAccountId(accountId);
|
|
93
|
+
}, [accountId]);
|
|
94
|
+
|
|
95
|
+
const value = useMemo<SpaceInvoicesRuntimeContextType>(
|
|
96
|
+
() => ({
|
|
97
|
+
accessToken: resolvedAccessToken,
|
|
98
|
+
accountId,
|
|
99
|
+
basePath,
|
|
100
|
+
clientName,
|
|
101
|
+
hasAccessToken: Boolean(resolvedAccessToken),
|
|
102
|
+
isResolvingAccessToken,
|
|
103
|
+
error,
|
|
104
|
+
getAccessToken: () => resolveAccessToken(accessToken),
|
|
105
|
+
}),
|
|
106
|
+
[resolvedAccessToken, accountId, basePath, clientName, isResolvingAccessToken, error, accessToken],
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
return <SpaceInvoicesRuntimeContext.Provider value={value}>{children}</SpaceInvoicesRuntimeContext.Provider>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function useSpaceInvoicesRuntime() {
|
|
113
|
+
const context = useContext(SpaceInvoicesRuntimeContext);
|
|
114
|
+
|
|
115
|
+
if (!context) {
|
|
116
|
+
throw new Error("useSpaceInvoicesRuntime must be used within a SpaceInvoicesProvider");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return context;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function useSpaceInvoicesRuntimeOptional() {
|
|
123
|
+
return useContext(SpaceInvoicesRuntimeContext) ?? null;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function useAccessToken() {
|
|
127
|
+
const context = useSpaceInvoicesRuntimeOptional();
|
|
128
|
+
return context?.accessToken ?? null;
|
|
129
|
+
}
|