@spaceinvoices/react-ui 0.1.1 → 0.3.0
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 +1 -1
- package/registry.json +287 -122
- package/src/components/activities/activity-timeline.tsx +8 -1
- package/src/components/activities/locales/es.ts +30 -0
- package/src/components/activities/locales/fr.ts +30 -0
- package/src/components/activities/locales/hr.ts +30 -0
- package/src/components/activities/locales/it.ts +30 -0
- package/src/components/activities/locales/nl.ts +30 -0
- package/src/components/activities/locales/pl.ts +30 -0
- package/src/components/activities/locales/pt.ts +30 -0
- package/src/components/advance-invoices/create/create-advance-invoice-form.tsx +21 -7
- package/src/components/advance-invoices/create/locales/es.ts +29 -0
- package/src/components/advance-invoices/create/locales/fr.ts +28 -0
- package/src/components/advance-invoices/create/locales/hr.ts +27 -0
- package/src/components/advance-invoices/create/locales/it.ts +29 -0
- package/src/components/advance-invoices/create/locales/nl.ts +28 -0
- package/src/components/advance-invoices/create/locales/pl.ts +28 -0
- package/src/components/advance-invoices/create/locales/pt.ts +29 -0
- package/src/components/advance-invoices/create/prepare-advance-invoice-submission.ts +3 -3
- package/src/components/advance-invoices/list/list-table.tsx +20 -3
- package/src/components/advance-invoices/list/locales/de.ts +9 -0
- package/src/components/advance-invoices/list/locales/en.ts +8 -0
- package/src/components/advance-invoices/list/locales/es.ts +41 -0
- package/src/components/advance-invoices/list/locales/fr.ts +41 -0
- package/src/components/advance-invoices/list/locales/hr.ts +41 -0
- package/src/components/advance-invoices/list/locales/it.ts +41 -0
- package/src/components/advance-invoices/list/locales/nl.ts +41 -0
- package/src/components/advance-invoices/list/locales/pl.ts +41 -0
- package/src/components/advance-invoices/list/locales/pt.ts +41 -0
- package/src/components/advance-invoices/list/locales/sl.ts +9 -0
- package/src/components/credit-notes/create/create-credit-note-form.tsx +19 -5
- package/src/components/credit-notes/create/locales/es.ts +68 -0
- package/src/components/credit-notes/create/locales/fr.ts +69 -0
- package/src/components/credit-notes/create/locales/hr.ts +68 -0
- package/src/components/credit-notes/create/locales/it.ts +68 -0
- package/src/components/credit-notes/create/locales/nl.ts +69 -0
- package/src/components/credit-notes/create/locales/pl.ts +68 -0
- package/src/components/credit-notes/create/locales/pt.ts +68 -0
- package/src/components/credit-notes/list/list-table.tsx +25 -8
- package/src/components/credit-notes/list/locales/de.ts +10 -2
- package/src/components/credit-notes/list/locales/en.ts +8 -0
- package/src/components/credit-notes/list/locales/es.ts +41 -0
- package/src/components/credit-notes/list/locales/fr.ts +41 -0
- package/src/components/credit-notes/list/locales/hr.ts +41 -0
- package/src/components/credit-notes/list/locales/it.ts +41 -0
- package/src/components/credit-notes/list/locales/nl.ts +41 -0
- package/src/components/credit-notes/list/locales/pl.ts +41 -0
- package/src/components/credit-notes/list/locales/pt.ts +41 -0
- package/src/components/credit-notes/list/locales/sl.ts +10 -2
- package/src/components/customers/create-customer-form/create-customer-form.tsx +21 -3
- package/src/components/customers/create-customer-form/locales/de.ts +1 -0
- package/src/components/customers/create-customer-form/locales/es.ts +21 -0
- package/src/components/customers/create-customer-form/locales/fr.ts +21 -0
- package/src/components/customers/create-customer-form/locales/hr.ts +21 -0
- package/src/components/customers/create-customer-form/locales/it.ts +21 -0
- package/src/components/customers/create-customer-form/locales/nl.ts +21 -0
- package/src/components/customers/create-customer-form/locales/pl.ts +21 -0
- package/src/components/customers/create-customer-form/locales/pt.ts +21 -0
- package/src/components/customers/create-customer-form/locales/sl.ts +1 -0
- package/src/components/customers/customer-list-table/customer-list-row-actions.tsx +72 -16
- package/src/components/customers/customer-list-table/customer-list-table.tsx +35 -2
- package/src/components/customers/customer-list-table/locales/de.ts +9 -0
- package/src/components/customers/customer-list-table/locales/en.ts +10 -0
- package/src/components/customers/customer-list-table/locales/es.ts +25 -0
- package/src/components/customers/customer-list-table/locales/fr.ts +25 -0
- package/src/components/customers/customer-list-table/locales/hr.ts +25 -0
- package/src/components/customers/customer-list-table/locales/it.ts +25 -0
- package/src/components/customers/customer-list-table/locales/nl.ts +25 -0
- package/src/components/customers/customer-list-table/locales/pl.ts +25 -0
- package/src/components/customers/customer-list-table/locales/pt.ts +25 -0
- package/src/components/customers/customer-list-table/locales/sl.ts +9 -0
- package/src/components/customers/customers.hooks.test.ts +8 -8
- package/src/components/customers/customers.hooks.ts +6 -1
- package/src/components/customers/edit-customer-form/edit-customer-form.tsx +143 -0
- package/src/components/customers/edit-customer-form/locales/de.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/es.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/fr.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/hr.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/it.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/nl.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/pl.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/pt.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/sl.ts +13 -0
- package/src/components/customers/index.ts +1 -0
- package/src/components/dashboard/collection-rate-card/collection-rate-card.tsx +9 -1
- package/src/components/dashboard/collection-rate-card/locales/de.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/es.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/fr.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/hr.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/it.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/nl.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/pl.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/pt.ts +3 -0
- package/src/components/dashboard/invoice-status-chart/invoice-status-chart.tsx +9 -1
- package/src/components/dashboard/invoice-status-chart/locales/de.ts +9 -0
- package/src/components/dashboard/invoice-status-chart/locales/es.ts +9 -0
- package/src/components/dashboard/invoice-status-chart/locales/fr.ts +9 -0
- package/src/components/dashboard/invoice-status-chart/locales/hr.ts +9 -0
- package/src/components/dashboard/invoice-status-chart/locales/it.ts +9 -0
- package/src/components/dashboard/invoice-status-chart/locales/nl.ts +9 -0
- package/src/components/dashboard/invoice-status-chart/locales/pl.ts +9 -0
- package/src/components/dashboard/invoice-status-chart/locales/pt.ts +9 -0
- package/src/components/dashboard/payment-methods-chart/locales/de.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/es.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/fr.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/hr.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/it.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/nl.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/pl.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/pt.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/payment-methods-chart.tsx +9 -1
- package/src/components/dashboard/payment-trend-chart/locales/de.ts +5 -0
- package/src/components/dashboard/payment-trend-chart/locales/es.ts +5 -0
- package/src/components/dashboard/payment-trend-chart/locales/fr.ts +5 -0
- package/src/components/dashboard/payment-trend-chart/locales/hr.ts +5 -0
- package/src/components/dashboard/payment-trend-chart/locales/it.ts +5 -0
- package/src/components/dashboard/payment-trend-chart/locales/nl.ts +5 -0
- package/src/components/dashboard/payment-trend-chart/locales/pl.ts +5 -0
- package/src/components/dashboard/payment-trend-chart/locales/pt.ts +5 -0
- package/src/components/dashboard/payment-trend-chart/payment-trend-chart.tsx +10 -2
- package/src/components/dashboard/revenue-trend-chart/locales/de.ts +5 -0
- package/src/components/dashboard/revenue-trend-chart/locales/es.ts +5 -0
- package/src/components/dashboard/revenue-trend-chart/locales/fr.ts +5 -0
- package/src/components/dashboard/revenue-trend-chart/locales/hr.ts +5 -0
- package/src/components/dashboard/revenue-trend-chart/locales/it.ts +5 -0
- package/src/components/dashboard/revenue-trend-chart/locales/nl.ts +5 -0
- package/src/components/dashboard/revenue-trend-chart/locales/pl.ts +5 -0
- package/src/components/dashboard/revenue-trend-chart/locales/pt.ts +5 -0
- package/src/components/dashboard/revenue-trend-chart/revenue-trend-chart.tsx +10 -2
- package/src/components/dashboard/top-customers-chart/locales/de.ts +5 -0
- package/src/components/dashboard/top-customers-chart/locales/es.ts +5 -0
- package/src/components/dashboard/top-customers-chart/locales/fr.ts +5 -0
- package/src/components/dashboard/top-customers-chart/locales/hr.ts +5 -0
- package/src/components/dashboard/top-customers-chart/locales/it.ts +5 -0
- package/src/components/dashboard/top-customers-chart/locales/nl.ts +5 -0
- package/src/components/dashboard/top-customers-chart/locales/pl.ts +5 -0
- package/src/components/dashboard/top-customers-chart/locales/pt.ts +5 -0
- package/src/components/dashboard/top-customers-chart/top-customers-chart.tsx +10 -2
- package/src/components/documents/create/document-add-item-form.tsx +1 -1
- package/src/components/documents/create/form-types.ts +1 -5
- package/src/components/documents/create/mark-as-paid-section.tsx +60 -23
- package/src/components/documents/create/prepare-document-submission.test.ts +2 -2
- package/src/components/documents/create/prepare-document-submission.ts +12 -7
- package/src/components/documents/create/prepare-preview-data.test.ts +1 -1
- package/src/components/documents/view/document-actions-bar.tsx +8 -1
- package/src/components/documents/view/document-details-card.tsx +8 -1
- package/src/components/documents/view/document-payments-list.tsx +8 -1
- package/src/components/documents/view/locales/es.ts +83 -0
- package/src/components/documents/view/locales/fr.ts +83 -0
- package/src/components/documents/view/locales/hr.ts +83 -0
- package/src/components/documents/view/locales/it.ts +83 -0
- package/src/components/documents/view/locales/nl.ts +84 -0
- package/src/components/documents/view/locales/pl.ts +83 -0
- package/src/components/documents/view/locales/pt.ts +83 -0
- package/src/components/entities/create-entity-form.tsx +12 -2
- package/src/components/entities/entity-settings-form/entity-settings-form.tsx +18 -0
- package/src/components/entities/entity-settings-form/locales/de.ts +3 -1
- package/src/components/entities/entity-settings-form/locales/es.ts +197 -0
- package/src/components/entities/entity-settings-form/locales/fr.ts +196 -0
- package/src/components/entities/entity-settings-form/locales/hr.ts +189 -0
- package/src/components/entities/entity-settings-form/locales/it.ts +195 -0
- package/src/components/entities/entity-settings-form/locales/nl.ts +192 -0
- package/src/components/entities/entity-settings-form/locales/pl.ts +193 -0
- package/src/components/entities/entity-settings-form/locales/pt.ts +194 -0
- package/src/components/entities/entity-settings-form/locales/sl.ts +2 -0
- package/src/components/entities/fina-settings-form/fina-settings-form.tsx +461 -0
- package/src/components/entities/fina-settings-form/fina-settings.hooks.ts +215 -0
- package/src/components/entities/fina-settings-form/index.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/de.ts +145 -0
- package/src/components/entities/fina-settings-form/locales/en.ts +142 -0
- package/src/components/entities/fina-settings-form/locales/es.ts +143 -0
- package/src/components/entities/fina-settings-form/locales/fr.ts +142 -0
- package/src/components/entities/fina-settings-form/locales/hr.ts +144 -0
- package/src/components/entities/fina-settings-form/locales/it.ts +144 -0
- package/src/components/entities/fina-settings-form/locales/nl.ts +144 -0
- package/src/components/entities/fina-settings-form/locales/pl.ts +142 -0
- package/src/components/entities/fina-settings-form/locales/pt.ts +144 -0
- package/src/components/entities/fina-settings-form/locales/sl.ts +144 -0
- package/src/components/entities/fina-settings-form/sections/certificate-settings-section.tsx +233 -0
- package/src/components/entities/fina-settings-form/sections/premises-management-section.tsx +363 -0
- package/src/components/entities/fina-settings-form/sections/register-premise-dialog.tsx +395 -0
- package/src/components/entities/furs-settings-form/furs-settings-form.tsx +9 -2
- package/src/components/entities/furs-settings-form/furs-settings.hooks.ts +15 -11
- package/src/components/entities/furs-settings-form/locales/de.ts +52 -88
- package/src/components/entities/furs-settings-form/locales/en.ts +3 -0
- package/src/components/entities/furs-settings-form/locales/es.ts +196 -0
- package/src/components/entities/furs-settings-form/locales/fr.ts +196 -0
- package/src/components/entities/furs-settings-form/locales/hr.ts +195 -0
- package/src/components/entities/furs-settings-form/locales/it.ts +196 -0
- package/src/components/entities/furs-settings-form/locales/nl.ts +195 -0
- package/src/components/entities/furs-settings-form/locales/pl.ts +194 -0
- package/src/components/entities/furs-settings-form/locales/pt.ts +195 -0
- package/src/components/entities/furs-settings-form/locales/sl.ts +2 -0
- package/src/components/entities/furs-settings-form/sections/certificate-settings-section.tsx +19 -4
- package/src/components/entities/furs-settings-form/sections/register-premise-dialog.tsx +17 -66
- package/src/components/entities/keys.ts +1 -1
- package/src/components/entities/settings/company-settings-form.tsx +28 -0
- package/src/components/entities/settings/pdf-template-selector/locales/es.ts +18 -0
- package/src/components/entities/settings/pdf-template-selector/locales/fr.ts +18 -0
- package/src/components/entities/settings/pdf-template-selector/locales/hr.ts +18 -0
- package/src/components/entities/settings/pdf-template-selector/locales/it.ts +18 -0
- package/src/components/entities/settings/pdf-template-selector/locales/nl.ts +17 -0
- package/src/components/entities/settings/pdf-template-selector/locales/pl.ts +18 -0
- package/src/components/entities/settings/pdf-template-selector/locales/pt.ts +18 -0
- package/src/components/estimates/create/create-estimate-form.tsx +14 -0
- package/src/components/estimates/create/locales/es.ts +57 -0
- package/src/components/estimates/create/locales/fr.ts +58 -0
- package/src/components/estimates/create/locales/hr.ts +57 -0
- package/src/components/estimates/create/locales/it.ts +57 -0
- package/src/components/estimates/create/locales/nl.ts +58 -0
- package/src/components/estimates/create/locales/pl.ts +57 -0
- package/src/components/estimates/create/locales/pt.ts +58 -0
- package/src/components/estimates/create/prepare-estimate-submission.ts +1 -1
- package/src/components/estimates/list/list-table.tsx +20 -3
- package/src/components/estimates/list/locales/de.ts +9 -0
- package/src/components/estimates/list/locales/en.ts +8 -0
- package/src/components/estimates/list/locales/es.ts +32 -0
- package/src/components/estimates/list/locales/fr.ts +32 -0
- package/src/components/estimates/list/locales/hr.ts +32 -0
- package/src/components/estimates/list/locales/it.ts +32 -0
- package/src/components/estimates/list/locales/nl.ts +32 -0
- package/src/components/estimates/list/locales/pl.ts +32 -0
- package/src/components/estimates/list/locales/pt.ts +32 -0
- package/src/components/estimates/list/locales/sl.ts +9 -0
- package/src/components/export/document-export-form.tsx +0 -2
- package/src/components/invoices/create/create-invoice-form.tsx +24 -10
- package/src/components/invoices/create/eslog-validation.test.ts +2 -0
- package/src/components/invoices/create/locales/es.ts +103 -0
- package/src/components/invoices/create/locales/fr.ts +105 -0
- package/src/components/invoices/create/locales/hr.ts +103 -0
- package/src/components/invoices/create/locales/it.ts +105 -0
- package/src/components/invoices/create/locales/nl.ts +104 -0
- package/src/components/invoices/create/locales/pl.ts +104 -0
- package/src/components/invoices/create/locales/pt.ts +105 -0
- package/src/components/invoices/create/prepare-invoice-submission.test.ts +54 -55
- package/src/components/invoices/create/prepare-invoice-submission.ts +3 -3
- package/src/components/invoices/list/list-table.tsx +20 -3
- package/src/components/invoices/list/locales/de.ts +9 -0
- package/src/components/invoices/list/locales/en.ts +8 -0
- package/src/components/invoices/list/locales/es.ts +42 -0
- package/src/components/invoices/list/locales/fr.ts +42 -0
- package/src/components/invoices/list/locales/hr.ts +42 -0
- package/src/components/invoices/list/locales/it.ts +42 -0
- package/src/components/invoices/list/locales/nl.ts +42 -0
- package/src/components/invoices/list/locales/pl.ts +42 -0
- package/src/components/invoices/list/locales/pt.ts +42 -0
- package/src/components/invoices/list/locales/sl.ts +9 -0
- package/src/components/invoices/send-email-dialog/locales/es.ts +18 -0
- package/src/components/invoices/send-email-dialog/locales/fr.ts +18 -0
- package/src/components/invoices/send-email-dialog/locales/hr.ts +17 -0
- package/src/components/invoices/send-email-dialog/locales/it.ts +18 -0
- package/src/components/invoices/send-email-dialog/locales/nl.ts +18 -0
- package/src/components/invoices/send-email-dialog/locales/pl.ts +18 -0
- package/src/components/invoices/send-email-dialog/locales/pt.ts +18 -0
- package/src/components/invoices/send-email-dialog/send-email-dialog.tsx +20 -12
- package/src/components/invoices/shared/scaled-document-preview.tsx +1 -0
- package/src/components/invoices/view/eslog-info-display.tsx +1 -0
- package/src/components/invoices/view/fina-info-display.tsx +196 -0
- package/src/components/items/create-item-form/create-item-form.tsx +14 -0
- package/src/components/items/create-item-form/locales/en.ts +5 -0
- package/src/components/items/create-item-form/locales/es.ts +14 -0
- package/src/components/items/create-item-form/locales/fr.ts +14 -0
- package/src/components/items/create-item-form/locales/hr.ts +14 -0
- package/src/components/items/create-item-form/locales/it.ts +14 -0
- package/src/components/items/create-item-form/locales/nl.ts +14 -0
- package/src/components/items/create-item-form/locales/pl.ts +14 -0
- package/src/components/items/create-item-form/locales/pt.ts +14 -0
- package/src/components/items/edit-item-form/edit-item-form.tsx +170 -0
- package/src/components/items/edit-item-form/locales/de.ts +12 -0
- package/src/components/items/edit-item-form/locales/es.ts +12 -0
- package/src/components/items/edit-item-form/locales/fr.ts +12 -0
- package/src/components/items/edit-item-form/locales/hr.ts +12 -0
- package/src/components/items/edit-item-form/locales/it.ts +12 -0
- package/src/components/items/edit-item-form/locales/nl.ts +12 -0
- package/src/components/items/edit-item-form/locales/pl.ts +12 -0
- package/src/components/items/edit-item-form/locales/pt.ts +12 -0
- package/src/components/items/edit-item-form/locales/sl.ts +12 -0
- package/src/components/items/item-list-table/item-list-table.tsx +20 -13
- package/src/components/items/item-list-table/locales/de.ts +6 -0
- package/src/components/items/item-list-table/locales/en.ts +5 -0
- package/src/components/items/item-list-table/locales/es.ts +16 -0
- package/src/components/items/item-list-table/locales/fr.ts +16 -0
- package/src/components/items/item-list-table/locales/hr.ts +16 -0
- package/src/components/items/item-list-table/locales/it.ts +16 -0
- package/src/components/items/item-list-table/locales/nl.ts +16 -0
- package/src/components/items/item-list-table/locales/pl.ts +16 -0
- package/src/components/items/item-list-table/locales/pt.ts +16 -0
- package/src/components/items/item-list-table/locales/sl.ts +6 -0
- package/src/components/items/items.hooks.ts +7 -2
- package/src/components/payments/create-payment-form/create-payment-form.tsx +14 -0
- package/src/components/payments/create-payment-form/locales/es.ts +20 -0
- package/src/components/payments/create-payment-form/locales/fr.ts +20 -0
- package/src/components/payments/create-payment-form/locales/hr.ts +20 -0
- package/src/components/payments/create-payment-form/locales/it.ts +20 -0
- package/src/components/payments/create-payment-form/locales/nl.ts +20 -0
- package/src/components/payments/create-payment-form/locales/pl.ts +20 -0
- package/src/components/payments/create-payment-form/locales/pt.ts +20 -0
- package/src/components/payments/edit-payment-form/edit-payment-form.tsx +18 -2
- package/src/components/payments/edit-payment-form/locales/es.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/fr.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/hr.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/it.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/nl.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/pl.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/pt.ts +20 -0
- package/src/components/payments/list/list-row-actions.tsx +14 -0
- package/src/components/payments/list/list-table.tsx +21 -2
- package/src/components/payments/list/locales/de.ts +6 -0
- package/src/components/payments/list/locales/en.ts +7 -0
- package/src/components/payments/list/locales/es.ts +25 -0
- package/src/components/payments/list/locales/fr.ts +25 -0
- package/src/components/payments/list/locales/hr.ts +25 -0
- package/src/components/payments/list/locales/it.ts +25 -0
- package/src/components/payments/list/locales/nl.ts +25 -0
- package/src/components/payments/list/locales/pl.ts +25 -0
- package/src/components/payments/list/locales/pt.ts +25 -0
- package/src/components/payments/list/locales/sl.ts +6 -0
- package/src/components/payments/payments.hooks.ts +7 -2
- package/src/components/request-logs/index.ts +1 -1
- package/src/components/table/data-table.tsx +8 -3
- package/src/components/table/filter-panel.tsx +4 -4
- package/src/components/table/hooks/use-table-query.ts +3 -0
- package/src/components/table/table-empty-state.tsx +11 -4
- package/src/components/table/table-no-results.tsx +6 -4
- package/src/components/table/types.ts +2 -2
- package/src/components/tax-reports/kir-export-form.tsx +0 -1
- package/src/components/taxes/create-tax-form/create-tax-form.tsx +14 -0
- package/src/components/taxes/create-tax-form/locales/en.ts +1 -0
- package/src/components/taxes/create-tax-form/locales/es.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/fr.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/hr.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/it.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/nl.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/pl.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/pt.ts +8 -0
- package/src/components/taxes/edit-tax-form/edit-tax-form.tsx +119 -0
- package/src/components/taxes/edit-tax-form/locales/de.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/es.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/fr.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/hr.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/it.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/nl.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/pl.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/pt.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/sl.ts +6 -0
- package/src/components/taxes/tax-list-table/locales/de.ts +6 -0
- package/src/components/taxes/tax-list-table/locales/en.ts +6 -0
- package/src/components/taxes/tax-list-table/locales/es.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/fr.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/hr.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/it.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/nl.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/pl.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/pt.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/sl.ts +6 -0
- package/src/components/taxes/tax-list-table/tax-list-table.tsx +18 -0
- package/src/components/taxes/taxes.hooks.ts +12 -7
- package/src/components/ui/tooltip.tsx +2 -2
- package/src/components/wl-subscription/locked-feature.tsx +1 -0
- package/src/components/wl-subscription/upgrade-modal.tsx +1 -0
- package/src/generated/schemas/acceptentityinvitation_body.ts +17 -0
- package/src/generated/schemas/addentityuser_body.ts +18 -0
- package/src/generated/schemas/advanceinvoice.ts +184 -12
- package/src/generated/schemas/creditnote.ts +96 -127
- package/src/generated/schemas/customadvanceinvoice.ts +246 -0
- package/src/generated/schemas/customcreditnote.ts +237 -0
- package/src/generated/schemas/customer.ts +26 -0
- package/src/generated/schemas/customestimate.ts +181 -0
- package/src/generated/schemas/custominvoice.ts +237 -0
- package/src/generated/schemas/entity.ts +66 -7
- package/src/generated/schemas/entityuserrole.ts +19 -0
- package/src/generated/schemas/estimate.ts +149 -1
- package/src/generated/schemas/finasettings.ts +25 -0
- package/src/generated/schemas/furssettings.ts +1 -2
- package/src/generated/schemas/index.ts +24 -5
- package/src/generated/schemas/invoice.ts +224 -22
- package/src/generated/schemas/me.ts +22 -0
- package/src/generated/schemas/registerfinamovablepremise_body.ts +26 -0
- package/src/generated/schemas/registerfinarealestatepremise_body.ts +37 -0
- package/src/generated/schemas/renderadvanceinvoicepreview_body.ts +342 -0
- package/src/generated/schemas/rendercreditnotepreview_body.ts +344 -0
- package/src/generated/schemas/renderestimatepreview_body.ts +284 -0
- package/src/generated/schemas/renderinvoicepreview_body.ts +344 -0
- package/src/generated/schemas/senddocument_body.ts +23 -0
- package/src/generated/schemas/sendemail_body.ts +8 -10
- package/src/generated/schemas/stripeappconnect_body.ts +18 -0
- package/src/generated/schemas/stripeappcreateinvoice_body.ts +20 -0
- package/src/generated/schemas/stripeappupdatesettings_body.ts +26 -0
- package/src/generated/schemas/webhook.ts +143 -0
- package/src/hooks/create-resource-hooks.ts +85 -1
- package/src/hooks/use-next-document-number.ts +1 -1
- package/src/hooks/use-resource-mutation.ts +4 -3
- package/src/lib/browser-cookies.ts +12 -1
- package/src/lib/cookies.ts +2 -2
- package/src/lib/translation.ts +1 -1
- package/src/providers/entities-provider.tsx +84 -39
- package/src/providers/sdk-provider.tsx +7 -3
- package/src/providers/white-label-provider.tsx +5 -2
- package/src/providers/wl-subscription-provider.tsx +1 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated using 'bun generate-schemas'.
|
|
3
|
+
* Do not edit this file manually. To update, run the generator again.
|
|
4
|
+
* @generated
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
|
|
9
|
+
// Schemas for stripeappcreateinvoice_body endpoints
|
|
10
|
+
|
|
11
|
+
// Schema for create appcreateinvoice operation
|
|
12
|
+
const createAppCreateInvoiceSchemaDefinition = z.object({
|
|
13
|
+
stripe_object_id: z.string().min(1),
|
|
14
|
+
note: z.string().max(2000).optional(),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// Type for create appcreateinvoice operation
|
|
18
|
+
export type CreateAppCreateInvoiceSchema = z.infer<typeof createAppCreateInvoiceSchemaDefinition>;
|
|
19
|
+
|
|
20
|
+
export const createAppCreateInvoiceSchema = createAppCreateInvoiceSchemaDefinition;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated using 'bun generate-schemas'.
|
|
3
|
+
* Do not edit this file manually. To update, run the generator again.
|
|
4
|
+
* @generated
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
|
|
9
|
+
// Schemas for stripeappupdatesettings_body endpoints
|
|
10
|
+
|
|
11
|
+
// Schema for update appupdatesettings operation
|
|
12
|
+
const updateAppUpdateSettingsSchemaDefinition = z
|
|
13
|
+
.object({
|
|
14
|
+
auto_invoice_enabled: z.boolean(),
|
|
15
|
+
auto_invoice_events: z.array(
|
|
16
|
+
z.enum(["payment_intent.succeeded", "invoice.paid"])
|
|
17
|
+
),
|
|
18
|
+
default_note: z.string().max(500),
|
|
19
|
+
default_tax_rate: z.union([z.number(), z.null()]),
|
|
20
|
+
})
|
|
21
|
+
.partial();
|
|
22
|
+
|
|
23
|
+
// Type for update appupdatesettings operation
|
|
24
|
+
export type UpdateAppUpdateSettingsSchema = z.infer<typeof updateAppUpdateSettingsSchemaDefinition>;
|
|
25
|
+
|
|
26
|
+
export const updateAppUpdateSettingsSchema = updateAppUpdateSettingsSchemaDefinition;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated using 'bun generate-schemas'.
|
|
3
|
+
* Do not edit this file manually. To update, run the generator again.
|
|
4
|
+
* @generated
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
|
|
9
|
+
// Schemas for webhook endpoints
|
|
10
|
+
|
|
11
|
+
// Schema for create webhook operation
|
|
12
|
+
const createWebhookSchemaDefinition = z.object({
|
|
13
|
+
url: z.string().max(2048).url(),
|
|
14
|
+
description: z.string().max(500).optional(),
|
|
15
|
+
events: z
|
|
16
|
+
.array(
|
|
17
|
+
z.enum([
|
|
18
|
+
"invoice.created",
|
|
19
|
+
"invoice.updated",
|
|
20
|
+
"invoice.sent",
|
|
21
|
+
"invoice.paid",
|
|
22
|
+
"invoice.overdue",
|
|
23
|
+
"invoice.cancelled",
|
|
24
|
+
"invoice.deleted",
|
|
25
|
+
"invoice.restored",
|
|
26
|
+
"invoice.voided",
|
|
27
|
+
"invoice.finalized",
|
|
28
|
+
"customer.created",
|
|
29
|
+
"customer.updated",
|
|
30
|
+
"customer.deleted",
|
|
31
|
+
"customer.restored",
|
|
32
|
+
"customer.permanently_deleted",
|
|
33
|
+
"payment.received",
|
|
34
|
+
"payment.failed",
|
|
35
|
+
"payment.deleted",
|
|
36
|
+
"payment.restored",
|
|
37
|
+
"payment.permanently_deleted",
|
|
38
|
+
"estimate.created",
|
|
39
|
+
"estimate.sent",
|
|
40
|
+
"estimate.accepted",
|
|
41
|
+
"estimate.rejected",
|
|
42
|
+
"estimate.deleted",
|
|
43
|
+
"estimate.restored",
|
|
44
|
+
"credit_note.created",
|
|
45
|
+
"credit_note.issued",
|
|
46
|
+
"credit_note.deleted",
|
|
47
|
+
"credit_note.restored",
|
|
48
|
+
"advance_invoice.created",
|
|
49
|
+
"advance_invoice.paid",
|
|
50
|
+
"advance_invoice.applied",
|
|
51
|
+
"advance_invoice.deleted",
|
|
52
|
+
"advance_invoice.restored",
|
|
53
|
+
"item.created",
|
|
54
|
+
"item.deleted",
|
|
55
|
+
"item.restored",
|
|
56
|
+
"item.permanently_deleted",
|
|
57
|
+
"tax.created",
|
|
58
|
+
"tax.updated",
|
|
59
|
+
"tax.deleted",
|
|
60
|
+
"tax.restored",
|
|
61
|
+
"tax.permanently_deleted",
|
|
62
|
+
"stripe_app.connected",
|
|
63
|
+
"stripe_app.disconnected",
|
|
64
|
+
"stripe_app.settings_updated",
|
|
65
|
+
])
|
|
66
|
+
)
|
|
67
|
+
.min(1),
|
|
68
|
+
active: z.boolean().optional().default(true),
|
|
69
|
+
metadata: z.union([z.record(z.string(), z.any()), z.null()]).optional(),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Type for create webhook operation
|
|
73
|
+
export type CreateWebhookSchema = z.infer<typeof createWebhookSchemaDefinition>;
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
// Schema for update webhook operation
|
|
77
|
+
const updateWebhookSchemaDefinition = z
|
|
78
|
+
.object({
|
|
79
|
+
url: z.string().max(2048).url(),
|
|
80
|
+
description: z.union([z.string().max(4000, "Description must not exceed 4000 characters"), z.null()]),
|
|
81
|
+
events: z
|
|
82
|
+
.array(
|
|
83
|
+
z.enum([
|
|
84
|
+
"invoice.created",
|
|
85
|
+
"invoice.updated",
|
|
86
|
+
"invoice.sent",
|
|
87
|
+
"invoice.paid",
|
|
88
|
+
"invoice.overdue",
|
|
89
|
+
"invoice.cancelled",
|
|
90
|
+
"invoice.deleted",
|
|
91
|
+
"invoice.restored",
|
|
92
|
+
"invoice.voided",
|
|
93
|
+
"invoice.finalized",
|
|
94
|
+
"customer.created",
|
|
95
|
+
"customer.updated",
|
|
96
|
+
"customer.deleted",
|
|
97
|
+
"customer.restored",
|
|
98
|
+
"customer.permanently_deleted",
|
|
99
|
+
"payment.received",
|
|
100
|
+
"payment.failed",
|
|
101
|
+
"payment.deleted",
|
|
102
|
+
"payment.restored",
|
|
103
|
+
"payment.permanently_deleted",
|
|
104
|
+
"estimate.created",
|
|
105
|
+
"estimate.sent",
|
|
106
|
+
"estimate.accepted",
|
|
107
|
+
"estimate.rejected",
|
|
108
|
+
"estimate.deleted",
|
|
109
|
+
"estimate.restored",
|
|
110
|
+
"credit_note.created",
|
|
111
|
+
"credit_note.issued",
|
|
112
|
+
"credit_note.deleted",
|
|
113
|
+
"credit_note.restored",
|
|
114
|
+
"advance_invoice.created",
|
|
115
|
+
"advance_invoice.paid",
|
|
116
|
+
"advance_invoice.applied",
|
|
117
|
+
"advance_invoice.deleted",
|
|
118
|
+
"advance_invoice.restored",
|
|
119
|
+
"item.created",
|
|
120
|
+
"item.deleted",
|
|
121
|
+
"item.restored",
|
|
122
|
+
"item.permanently_deleted",
|
|
123
|
+
"tax.created",
|
|
124
|
+
"tax.updated",
|
|
125
|
+
"tax.deleted",
|
|
126
|
+
"tax.restored",
|
|
127
|
+
"tax.permanently_deleted",
|
|
128
|
+
"stripe_app.connected",
|
|
129
|
+
"stripe_app.disconnected",
|
|
130
|
+
"stripe_app.settings_updated",
|
|
131
|
+
])
|
|
132
|
+
)
|
|
133
|
+
.min(1),
|
|
134
|
+
active: z.boolean(),
|
|
135
|
+
metadata: z.union([z.record(z.string(), z.any()), z.null()]),
|
|
136
|
+
})
|
|
137
|
+
.partial();
|
|
138
|
+
|
|
139
|
+
// Type for update webhook operation
|
|
140
|
+
export type UpdateWebhookSchema = z.infer<typeof updateWebhookSchemaDefinition>;
|
|
141
|
+
|
|
142
|
+
export const createWebhookSchema = createWebhookSchemaDefinition;
|
|
143
|
+
export const updateWebhookSchema = updateWebhookSchemaDefinition;
|
|
@@ -65,7 +65,11 @@ export function createResourceHooks<
|
|
|
65
65
|
TResource extends { id: string },
|
|
66
66
|
TCreateData = unknown,
|
|
67
67
|
TUpdateData = Partial<Omit<TResource, "id">>,
|
|
68
|
-
>(
|
|
68
|
+
>(
|
|
69
|
+
resourceName: keyof SDK,
|
|
70
|
+
cacheKey: string,
|
|
71
|
+
options?: { restoreMethodName?: string; permanentDeleteMethodName?: string },
|
|
72
|
+
) {
|
|
69
73
|
/**
|
|
70
74
|
* Hook for creating a new resource
|
|
71
75
|
*/
|
|
@@ -292,9 +296,89 @@ export function createResourceHooks<
|
|
|
292
296
|
});
|
|
293
297
|
}
|
|
294
298
|
|
|
299
|
+
/**
|
|
300
|
+
* Hook for restoring a soft-deleted resource
|
|
301
|
+
*/
|
|
302
|
+
function useRestoreResource<TError = Error>(
|
|
303
|
+
hookOptions: ResourceMutationHookOptions<TResource, TError, { id: string }> = {},
|
|
304
|
+
) {
|
|
305
|
+
const queryClient = useQueryClient();
|
|
306
|
+
const methodName = options?.restoreMethodName;
|
|
307
|
+
if (!methodName) {
|
|
308
|
+
throw new Error(`restoreMethodName not configured for ${String(resourceName)}`);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return useResourceMutation<TResource, TError, { id: string }>({
|
|
312
|
+
resourceName,
|
|
313
|
+
methodName,
|
|
314
|
+
cacheKey,
|
|
315
|
+
entityId: hookOptions.entityId,
|
|
316
|
+
accountId: hookOptions.accountId,
|
|
317
|
+
mutationOptions: {
|
|
318
|
+
onSuccess: (data, variables, context) => {
|
|
319
|
+
invalidateResourceQueries(queryClient, cacheKey, variables.id, {
|
|
320
|
+
entityId: hookOptions.entityId,
|
|
321
|
+
accountId: hookOptions.accountId,
|
|
322
|
+
});
|
|
323
|
+
hookOptions.onSuccess?.(data, variables, context);
|
|
324
|
+
},
|
|
325
|
+
onError: hookOptions.onError,
|
|
326
|
+
...hookOptions.mutationOptions,
|
|
327
|
+
},
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Hook for permanently deleting a soft-deleted resource
|
|
333
|
+
*/
|
|
334
|
+
function usePermanentDeleteResource<TError = Error>(
|
|
335
|
+
hookOptions: ResourceMutationHookOptions<void, TError, { id: string }> = {},
|
|
336
|
+
) {
|
|
337
|
+
const queryClient = useQueryClient();
|
|
338
|
+
const methodName = options?.permanentDeleteMethodName;
|
|
339
|
+
if (!methodName) {
|
|
340
|
+
throw new Error(`permanentDeleteMethodName not configured for ${String(resourceName)}`);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return useResourceMutation<void, TError, { id: string }>({
|
|
344
|
+
resourceName,
|
|
345
|
+
methodName,
|
|
346
|
+
cacheKey,
|
|
347
|
+
entityId: hookOptions.entityId,
|
|
348
|
+
accountId: hookOptions.accountId,
|
|
349
|
+
mutationOptions: {
|
|
350
|
+
onSuccess: (data, variables, context) => {
|
|
351
|
+
invalidateResourceQueries(queryClient, cacheKey, variables.id, {
|
|
352
|
+
entityId: hookOptions.entityId,
|
|
353
|
+
accountId: hookOptions.accountId,
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
const listQueryKey = buildQueryKey(cacheKey, {
|
|
357
|
+
entityId: hookOptions.entityId,
|
|
358
|
+
accountId: hookOptions.accountId,
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
queryClient.setQueriesData({ queryKey: listQueryKey }, (oldData: any) => {
|
|
362
|
+
if (!oldData?.data) return oldData;
|
|
363
|
+
return {
|
|
364
|
+
...oldData,
|
|
365
|
+
data: oldData.data.filter((resource: TResource) => resource.id !== variables.id),
|
|
366
|
+
};
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
hookOptions.onSuccess?.(data, variables, context);
|
|
370
|
+
},
|
|
371
|
+
onError: hookOptions.onError,
|
|
372
|
+
...hookOptions.mutationOptions,
|
|
373
|
+
},
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
295
377
|
return {
|
|
296
378
|
useCreateResource,
|
|
297
379
|
useUpdateResource,
|
|
298
380
|
useDeleteResource,
|
|
381
|
+
useRestoreResource,
|
|
382
|
+
usePermanentDeleteResource,
|
|
299
383
|
};
|
|
300
384
|
}
|
|
@@ -9,7 +9,7 @@ export type DocumentType = "invoice" | "estimate" | "credit_note" | "advance_inv
|
|
|
9
9
|
/** Response type for next document number preview */
|
|
10
10
|
export type NextDocumentNumberResponse = {
|
|
11
11
|
number: string | null;
|
|
12
|
-
furs
|
|
12
|
+
furs?: {
|
|
13
13
|
business_premise_name: string;
|
|
14
14
|
electronic_device_name: string;
|
|
15
15
|
} | null;
|
|
@@ -62,7 +62,8 @@ export function useResourceMutation<TData, TError = Error, TVariables = unknown,
|
|
|
62
62
|
|
|
63
63
|
// SDK API: method(data, options) or method(id, data, options)
|
|
64
64
|
const isUpdateMethod = methodName === "update";
|
|
65
|
-
const
|
|
65
|
+
const isIdOnlyMethod =
|
|
66
|
+
methodName === "delete" || methodName.startsWith("restore") || methodName.startsWith("permanentDelete");
|
|
66
67
|
|
|
67
68
|
if (isUpdateMethod) {
|
|
68
69
|
// Update: method(id, data, options)
|
|
@@ -70,8 +71,8 @@ export function useResourceMutation<TData, TError = Error, TVariables = unknown,
|
|
|
70
71
|
return (await resource[methodName](id, data, options)) as TData;
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
if (
|
|
74
|
-
// Delete: method(id, options)
|
|
74
|
+
if (isIdOnlyMethod) {
|
|
75
|
+
// Delete/Restore/PermanentDelete: method(id, options)
|
|
75
76
|
const { id } = variables as { id: string };
|
|
76
77
|
return (await resource[methodName](id, options)) as TData;
|
|
77
78
|
}
|
|
@@ -49,7 +49,7 @@ export function getCookie(name: string): string | undefined {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
* Removes a cookie by name
|
|
52
|
+
* Removes a cookie by name, clearing both host-only and domain-scoped versions
|
|
53
53
|
*/
|
|
54
54
|
export function deleteCookie(name: string, path = "/") {
|
|
55
55
|
if (typeof window === "undefined") {
|
|
@@ -57,10 +57,21 @@ export function deleteCookie(name: string, path = "/") {
|
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
// Delete host-only cookie (e.g. app.spaceinvoices.com)
|
|
60
61
|
setCookie(name, "", {
|
|
61
62
|
path,
|
|
62
63
|
expires: new Date(0),
|
|
63
64
|
});
|
|
65
|
+
|
|
66
|
+
// Also delete domain cookie (e.g. .spaceinvoices.com) if on spaceinvoices.com
|
|
67
|
+
const hostname = window.location.hostname;
|
|
68
|
+
if (hostname === "spaceinvoices.com" || hostname.endsWith(".spaceinvoices.com")) {
|
|
69
|
+
setCookie(name, "", {
|
|
70
|
+
path,
|
|
71
|
+
expires: new Date(0),
|
|
72
|
+
domain: ".spaceinvoices.com",
|
|
73
|
+
});
|
|
74
|
+
}
|
|
64
75
|
}
|
|
65
76
|
|
|
66
77
|
export function flushCookies() {
|
package/src/lib/cookies.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
export function getCookie(cookiesString: string, name: string) {
|
|
7
7
|
const value = `; ${cookiesString}`;
|
|
8
8
|
const parts = value.split(`; ${name}=`);
|
|
9
|
-
if (parts.length
|
|
10
|
-
return decodeURIComponent(parts
|
|
9
|
+
if (parts.length >= 2) {
|
|
10
|
+
return decodeURIComponent(parts[1]?.split(";").shift() ?? "");
|
|
11
11
|
}
|
|
12
12
|
return undefined;
|
|
13
13
|
}
|
package/src/lib/translation.ts
CHANGED
|
@@ -25,7 +25,7 @@ export function createTranslation({ t, namespace, locale = "en", translations =
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// 2. Look up in local translations for current locale
|
|
28
|
-
if (
|
|
28
|
+
if (translations[locale]) {
|
|
29
29
|
const translation = translations[locale][key];
|
|
30
30
|
if (translation) return translation;
|
|
31
31
|
}
|
|
@@ -23,34 +23,38 @@ type EntitiesProviderProps = {
|
|
|
23
23
|
children: ReactNode;
|
|
24
24
|
initialActiveEntity?: Entity | null;
|
|
25
25
|
onNoEntities?: () => void;
|
|
26
|
+
cookieDomain?: string;
|
|
27
|
+
/** When provided (from URL param), this entity ID is used as the source of truth instead of the cookie */
|
|
28
|
+
urlEntityId?: string;
|
|
26
29
|
};
|
|
27
30
|
|
|
28
|
-
export function EntitiesProvider({
|
|
31
|
+
export function EntitiesProvider({
|
|
32
|
+
children,
|
|
33
|
+
initialActiveEntity,
|
|
34
|
+
onNoEntities,
|
|
35
|
+
cookieDomain,
|
|
36
|
+
urlEntityId,
|
|
37
|
+
}: EntitiesProviderProps) {
|
|
29
38
|
const { sdk, isInitialized } = useSDK();
|
|
30
39
|
const [cookies, setCookie, removeCookie] = useCookies([ACTIVE_ENTITY_COOKIE, ACTIVE_ENVIRONMENT_COOKIE]);
|
|
31
40
|
const isInitialMount = useRef(true);
|
|
32
41
|
const initialEnvironmentFromCookie = cookies[ACTIVE_ENVIRONMENT_COOKIE] as EntityEnvironment | undefined;
|
|
33
|
-
const
|
|
42
|
+
const initialEntityIdFromCookie = cookies[ACTIVE_ENTITY_COOKIE] as string | undefined;
|
|
43
|
+
|
|
44
|
+
// URL entity ID takes precedence over cookie
|
|
45
|
+
const resolvedEntityId = urlEntityId ?? initialEntityIdFromCookie;
|
|
34
46
|
|
|
35
47
|
const resolvedInitialEnvironment: EntityEnvironment =
|
|
36
|
-
initialEnvironmentFromCookie ??
|
|
37
|
-
(initialEntityFromCookie?.environment as EntityEnvironment | undefined) ??
|
|
38
|
-
(initialActiveEntity?.environment as EntityEnvironment | undefined) ??
|
|
39
|
-
"live";
|
|
48
|
+
initialEnvironmentFromCookie ?? (initialActiveEntity?.environment as EntityEnvironment | undefined) ?? "live";
|
|
40
49
|
|
|
41
50
|
const [environment, setEnvironmentState] = useState<EntityEnvironment>(resolvedInitialEnvironment);
|
|
42
51
|
const previousEnvironment = useRef(environment);
|
|
43
52
|
|
|
44
|
-
//
|
|
45
|
-
const
|
|
46
|
-
try {
|
|
47
|
-
if (initialEntityFromCookie && initialEntityFromCookie.environment === resolvedInitialEnvironment) {
|
|
48
|
-
return initialEntityFromCookie;
|
|
49
|
-
}
|
|
50
|
-
} catch (_e) {
|
|
51
|
-
// Ignore cookie parsing errors
|
|
52
|
-
}
|
|
53
|
+
// Store the initial entity ID (from URL or cookie) so we can match it when entities load
|
|
54
|
+
const initialEntityIdRef = useRef(resolvedEntityId);
|
|
53
55
|
|
|
56
|
+
// Initialize active entity from prop if it matches the selected environment
|
|
57
|
+
const [activeEntityState, setActiveEntityState] = useState<Entity | null>(() => {
|
|
54
58
|
if (initialActiveEntity && initialActiveEntity.environment === resolvedInitialEnvironment) {
|
|
55
59
|
return initialActiveEntity;
|
|
56
60
|
}
|
|
@@ -83,14 +87,38 @@ export function EntitiesProvider({ children, initialActiveEntity, onNoEntities }
|
|
|
83
87
|
refetchOnReconnect: true,
|
|
84
88
|
});
|
|
85
89
|
|
|
86
|
-
//
|
|
90
|
+
// When no entities in current environment, check the other before giving up
|
|
87
91
|
const hasCalledNoEntities = useRef(false);
|
|
92
|
+
const hasTriedFallback = useRef(false);
|
|
88
93
|
useEffect(() => {
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
if (isLoading || entities.length > 0 || hasCalledNoEntities.current) return;
|
|
95
|
+
|
|
96
|
+
// Try the other environment before calling onNoEntities
|
|
97
|
+
if (!hasTriedFallback.current && sdk) {
|
|
98
|
+
hasTriedFallback.current = true;
|
|
99
|
+
const altEnv = environment === "live" ? "sandbox" : "live";
|
|
100
|
+
sdk.entities
|
|
101
|
+
.list({ limit: 1, environment: altEnv })
|
|
102
|
+
.then((res) => {
|
|
103
|
+
if (res.data.length > 0) {
|
|
104
|
+
// Other environment has entities — auto-switch
|
|
105
|
+
setEnvironmentState(altEnv as EntityEnvironment);
|
|
106
|
+
} else {
|
|
107
|
+
hasCalledNoEntities.current = true;
|
|
108
|
+
onNoEntities?.();
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
.catch(() => {
|
|
112
|
+
hasCalledNoEntities.current = true;
|
|
113
|
+
onNoEntities?.();
|
|
114
|
+
});
|
|
115
|
+
return;
|
|
92
116
|
}
|
|
93
|
-
|
|
117
|
+
|
|
118
|
+
if (!hasTriedFallback.current) return;
|
|
119
|
+
hasCalledNoEntities.current = true;
|
|
120
|
+
onNoEntities?.();
|
|
121
|
+
}, [isLoading, entities.length, onNoEntities, sdk, environment]);
|
|
94
122
|
|
|
95
123
|
// Memoize entities to prevent unnecessary re-renders
|
|
96
124
|
const memoizedEntities = useMemo(() => entities, [entities]);
|
|
@@ -107,24 +135,39 @@ export function EntitiesProvider({ children, initialActiveEntity, onNoEntities }
|
|
|
107
135
|
const activeEntityRef = useRef(activeEntityState);
|
|
108
136
|
activeEntityRef.current = activeEntityState;
|
|
109
137
|
|
|
138
|
+
// When urlEntityId changes (e.g. entity switcher navigates to new URL), update the ref
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
if (urlEntityId) {
|
|
141
|
+
initialEntityIdRef.current = urlEntityId;
|
|
142
|
+
}
|
|
143
|
+
}, [urlEntityId]);
|
|
144
|
+
|
|
110
145
|
useEffect(() => {
|
|
111
146
|
if (!memoizedEntities.length) return;
|
|
112
147
|
|
|
113
148
|
const currentActive = activeEntityRef.current;
|
|
149
|
+
// When URL entity ID is provided, always try to match it first
|
|
150
|
+
const targetEntityId = urlEntityId ?? currentActive?.id;
|
|
114
151
|
|
|
115
152
|
try {
|
|
116
|
-
if (
|
|
117
|
-
const updatedEntity = memoizedEntities.find((entity) => entity.id ===
|
|
153
|
+
if (targetEntityId) {
|
|
154
|
+
const updatedEntity = memoizedEntities.find((entity) => entity.id === targetEntityId);
|
|
118
155
|
|
|
119
156
|
if (updatedEntity) {
|
|
120
157
|
// Always update with fresh data from the server
|
|
121
158
|
setActiveEntityState(updatedEntity);
|
|
159
|
+
} else if (currentActive) {
|
|
160
|
+
// URL entity not found but we have a current active — keep it or fall back
|
|
161
|
+
const stillExists = memoizedEntities.find((entity) => entity.id === currentActive.id);
|
|
162
|
+
setActiveEntityState(stillExists ?? memoizedEntities[0]);
|
|
122
163
|
} else {
|
|
123
|
-
// If active entity no longer exists, fall back to first entity
|
|
124
164
|
setActiveEntityState(memoizedEntities[0]);
|
|
125
165
|
}
|
|
126
166
|
} else {
|
|
127
|
-
|
|
167
|
+
// No active entity yet — try to match by cookie/URL ID, then fall back to first
|
|
168
|
+
const entityId = initialEntityIdRef.current;
|
|
169
|
+
const matchedEntity = entityId ? memoizedEntities.find((entity) => entity.id === entityId) : undefined;
|
|
170
|
+
setActiveEntityState(matchedEntity ?? memoizedEntities[0]);
|
|
128
171
|
}
|
|
129
172
|
} catch (_e) {
|
|
130
173
|
if (memoizedEntities.length > 0) {
|
|
@@ -135,28 +178,30 @@ export function EntitiesProvider({ children, initialActiveEntity, onNoEntities }
|
|
|
135
178
|
isInitialMount.current = false;
|
|
136
179
|
}
|
|
137
180
|
}
|
|
138
|
-
}, [memoizedEntities]); //
|
|
181
|
+
}, [memoizedEntities, urlEntityId]); // Re-run when URL entity changes
|
|
182
|
+
|
|
183
|
+
const cookieOpts = useMemo(
|
|
184
|
+
() => ({
|
|
185
|
+
path: "/",
|
|
186
|
+
maxAge: 60 * 60 * 24 * 365,
|
|
187
|
+
sameSite: "lax" as const,
|
|
188
|
+
...(cookieDomain && { domain: cookieDomain }),
|
|
189
|
+
}),
|
|
190
|
+
[cookieDomain],
|
|
191
|
+
);
|
|
139
192
|
|
|
140
|
-
// Update cookie when active entity changes
|
|
193
|
+
// Update cookie when active entity changes (store only ID)
|
|
141
194
|
useEffect(() => {
|
|
142
195
|
if (activeEntityState) {
|
|
143
|
-
setCookie(ACTIVE_ENTITY_COOKIE, activeEntityState,
|
|
144
|
-
path: "/",
|
|
145
|
-
maxAge: 60 * 60 * 24 * 365,
|
|
146
|
-
sameSite: "lax",
|
|
147
|
-
});
|
|
196
|
+
setCookie(ACTIVE_ENTITY_COOKIE, activeEntityState.id, cookieOpts);
|
|
148
197
|
} else {
|
|
149
|
-
removeCookie(ACTIVE_ENTITY_COOKIE,
|
|
198
|
+
removeCookie(ACTIVE_ENTITY_COOKIE, cookieOpts);
|
|
150
199
|
}
|
|
151
|
-
}, [activeEntityState, setCookie, removeCookie]);
|
|
200
|
+
}, [activeEntityState, setCookie, removeCookie, cookieOpts]);
|
|
152
201
|
|
|
153
202
|
useEffect(() => {
|
|
154
|
-
setCookie(ACTIVE_ENVIRONMENT_COOKIE, environment,
|
|
155
|
-
|
|
156
|
-
maxAge: 60 * 60 * 24 * 365,
|
|
157
|
-
sameSite: "lax",
|
|
158
|
-
});
|
|
159
|
-
}, [environment, setCookie]);
|
|
203
|
+
setCookie(ACTIVE_ENVIRONMENT_COOKIE, environment, cookieOpts);
|
|
204
|
+
}, [environment, setCookie, cookieOpts]);
|
|
160
205
|
|
|
161
206
|
const refetchEntities = useCallback(async () => {
|
|
162
207
|
await refetch();
|
|
@@ -10,7 +10,7 @@ import { flushCookies, getCookie } from "@/ui/lib/browser-cookies";
|
|
|
10
10
|
* Note: SDK is guaranteed to be non-null when accessing this context
|
|
11
11
|
* The provider blocks rendering until SDK is initialized
|
|
12
12
|
*/
|
|
13
|
-
type SDKContextType = {
|
|
13
|
+
export type SDKContextType = {
|
|
14
14
|
sdk: SDK; // Non-null - guaranteed by provider
|
|
15
15
|
isInitialized: boolean;
|
|
16
16
|
isLoading: boolean;
|
|
@@ -23,7 +23,7 @@ type SDKContextType = {
|
|
|
23
23
|
* Note: These defaults are never actually used because the provider
|
|
24
24
|
* blocks rendering until SDK is initialized
|
|
25
25
|
*/
|
|
26
|
-
const SDKContext = createContext<SDKContextType | undefined>(undefined);
|
|
26
|
+
export const SDKContext = createContext<SDKContextType | undefined>(undefined);
|
|
27
27
|
|
|
28
28
|
// Add a name to help with debugging
|
|
29
29
|
SDKContext.displayName = "SDKContext";
|
|
@@ -43,7 +43,11 @@ type SDKProviderProps = {
|
|
|
43
43
|
export function SDKProvider({
|
|
44
44
|
children,
|
|
45
45
|
onUnauthorized,
|
|
46
|
-
fallbackLoading =
|
|
46
|
+
fallbackLoading = (
|
|
47
|
+
<div className="fixed inset-0 flex items-center justify-center bg-background/50">
|
|
48
|
+
<div className="h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" />
|
|
49
|
+
</div>
|
|
50
|
+
),
|
|
47
51
|
fallbackError = (error) => <div className="p-4 text-red-500">Error initializing SDK: {error.message}</div>,
|
|
48
52
|
fallbackUnauthorized = <div className="p-4 text-amber-500">No SDK available. Please log in first.</div>,
|
|
49
53
|
}: SDKProviderProps) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import { createContext, useContext, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
3
3
|
|
|
4
4
|
export type WhiteLabelConfig = {
|
|
5
5
|
slug: string;
|
|
@@ -62,7 +62,10 @@ export function WhiteLabelProvider({ children, apiBaseUrl = "" }: WhiteLabelProv
|
|
|
62
62
|
fetchConfig();
|
|
63
63
|
}, [apiBaseUrl]);
|
|
64
64
|
|
|
65
|
-
const isFeatureVisible = (
|
|
65
|
+
const isFeatureVisible = useCallback(
|
|
66
|
+
(feature: string) => !config.hiddenFeatures.includes(feature),
|
|
67
|
+
[config.hiddenFeatures],
|
|
68
|
+
);
|
|
66
69
|
|
|
67
70
|
const value = useMemo(
|
|
68
71
|
() => ({
|