@spaceinvoices/react-ui 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +340 -0
- package/cli/dist/index.js +922 -0
- package/package.json +87 -0
- package/registry.json +600 -0
- package/spaceinvoices.schema.json +47 -0
- package/src/app.tsx +25 -0
- package/src/common/autocomplete.tsx +135 -0
- package/src/components/activities/activity-timeline.tsx +160 -0
- package/src/components/activities/index.ts +1 -0
- package/src/components/activities/locales/de.ts +30 -0
- package/src/components/activities/locales/sl.ts +30 -0
- package/src/components/advance-invoices/advance-invoices.hooks.ts +75 -0
- package/src/components/advance-invoices/create/create-advance-invoice-form.tsx +702 -0
- package/src/components/advance-invoices/create/locales/de.ts +29 -0
- package/src/components/advance-invoices/create/locales/sl.ts +25 -0
- package/src/components/advance-invoices/create/prepare-advance-invoice-submission.ts +74 -0
- package/src/components/advance-invoices/index.ts +5 -0
- package/src/components/advance-invoices/list/index.ts +3 -0
- package/src/components/advance-invoices/list/list-row-actions.tsx +119 -0
- package/src/components/advance-invoices/list/list-table.tsx +178 -0
- package/src/components/advance-invoices/list/locales/de.ts +32 -0
- package/src/components/advance-invoices/list/locales/sl.ts +32 -0
- package/src/components/advance-invoices/list/use-advance-invoice-download.ts +63 -0
- package/src/components/button-loader.tsx +11 -0
- package/src/components/combobox.tsx +96 -0
- package/src/components/company-registry/company-registry-autocomplete.tsx +151 -0
- package/src/components/company-registry/company-registry.hooks.ts +67 -0
- package/src/components/company-registry/index.ts +7 -0
- package/src/components/credit-notes/create/create-credit-note-form.tsx +332 -0
- package/src/components/credit-notes/create/index.ts +1 -0
- package/src/components/credit-notes/create/locales/de.ts +69 -0
- package/src/components/credit-notes/create/locales/sl.ts +67 -0
- package/src/components/credit-notes/credit-notes.hooks.ts +22 -0
- package/src/components/credit-notes/index.ts +10 -0
- package/src/components/credit-notes/list/index.ts +3 -0
- package/src/components/credit-notes/list/list-row-actions.tsx +116 -0
- package/src/components/credit-notes/list/list-table.tsx +183 -0
- package/src/components/credit-notes/list/locales/de.ts +33 -0
- package/src/components/credit-notes/list/locales/sl.ts +33 -0
- package/src/components/credit-notes/list/use-credit-note-download.ts +65 -0
- package/src/components/customers/create-customer-form/create-customer-form.tsx +134 -0
- package/src/components/customers/create-customer-form/locales/de.ts +20 -0
- package/src/components/customers/create-customer-form/locales/sl.ts +20 -0
- package/src/components/customers/customer-autocomplete.tsx +173 -0
- package/src/components/customers/customer-combobox.tsx +130 -0
- package/src/components/customers/customer-list-table/customer-list-row-actions.tsx +48 -0
- package/src/components/customers/customer-list-table/customer-list-table.tsx +124 -0
- package/src/components/customers/customer-list-table/index.ts +2 -0
- package/src/components/customers/customer-list-table/locales/de.ts +16 -0
- package/src/components/customers/customer-list-table/locales/sl.ts +16 -0
- package/src/components/customers/customers.hooks.test.ts +348 -0
- package/src/components/customers/customers.hooks.ts +57 -0
- package/src/components/customers/index.ts +5 -0
- package/src/components/dashboard/chart-empty-state.tsx +29 -0
- package/src/components/dashboard/collection-rate-card/collection-rate-card.tsx +80 -0
- package/src/components/dashboard/collection-rate-card/index.ts +4 -0
- package/src/components/dashboard/collection-rate-card/locales/sl.ts +3 -0
- package/src/components/dashboard/collection-rate-card/use-collection-rate.ts +74 -0
- package/src/components/dashboard/index.ts +54 -0
- package/src/components/dashboard/invoice-status-chart/index.ts +4 -0
- package/src/components/dashboard/invoice-status-chart/invoice-status-chart.tsx +130 -0
- package/src/components/dashboard/invoice-status-chart/locales/sl.ts +9 -0
- package/src/components/dashboard/invoice-status-chart/use-invoice-status.ts +105 -0
- package/src/components/dashboard/loading-card.tsx +19 -0
- package/src/components/dashboard/payment-methods-chart/index.ts +4 -0
- package/src/components/dashboard/payment-methods-chart/locales/sl.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/payment-methods-chart.tsx +152 -0
- package/src/components/dashboard/payment-methods-chart/use-payment-methods.ts +50 -0
- package/src/components/dashboard/payment-trend-chart/index.ts +4 -0
- package/src/components/dashboard/payment-trend-chart/locales/sl.ts +5 -0
- package/src/components/dashboard/payment-trend-chart/payment-trend-chart.tsx +137 -0
- package/src/components/dashboard/payment-trend-chart/use-payment-trend.ts +92 -0
- package/src/components/dashboard/revenue-card.tsx +49 -0
- package/src/components/dashboard/revenue-trend-chart/index.ts +4 -0
- package/src/components/dashboard/revenue-trend-chart/locales/sl.ts +5 -0
- package/src/components/dashboard/revenue-trend-chart/revenue-trend-chart.tsx +137 -0
- package/src/components/dashboard/revenue-trend-chart/use-revenue-trend.ts +93 -0
- package/src/components/dashboard/shared/index.ts +5 -0
- package/src/components/dashboard/shared/use-revenue-data.ts +160 -0
- package/src/components/dashboard/shared/use-stats-counts.ts +89 -0
- package/src/components/dashboard/shared/use-stats-query.ts +38 -0
- package/src/components/dashboard/stat-card.tsx +41 -0
- package/src/components/dashboard/tax-collected-card/index.ts +2 -0
- package/src/components/dashboard/tax-collected-card/tax-collected-card.tsx +77 -0
- package/src/components/dashboard/tax-collected-card/use-tax-collected.ts +145 -0
- package/src/components/dashboard/top-customers-chart/index.ts +4 -0
- package/src/components/dashboard/top-customers-chart/locales/sl.ts +5 -0
- package/src/components/dashboard/top-customers-chart/top-customers-chart.tsx +130 -0
- package/src/components/dashboard/top-customers-chart/use-top-customers.ts +72 -0
- package/src/components/documents/create/document-add-item-form.tsx +379 -0
- package/src/components/documents/create/document-add-item-tax-rate-field.tsx +120 -0
- package/src/components/documents/create/document-details-section.tsx +597 -0
- package/src/components/documents/create/document-items-section.tsx +133 -0
- package/src/components/documents/create/document-recipient-section.tsx +101 -0
- package/src/components/documents/create/form-types.ts +36 -0
- package/src/components/documents/create/index.ts +9 -0
- package/src/components/documents/create/live-preview.tsx +235 -0
- package/src/components/documents/create/mark-as-paid-section.tsx +82 -0
- package/src/components/documents/create/prepare-document-submission.test.ts +132 -0
- package/src/components/documents/create/prepare-document-submission.ts +187 -0
- package/src/components/documents/create/prepare-preview-data.test.ts +155 -0
- package/src/components/documents/create/prepare-preview-data.ts +16 -0
- package/src/components/documents/create/smart-code-insert-button.tsx +139 -0
- package/src/components/documents/create/use-document-customer-form.ts +161 -0
- package/src/components/documents/document-preview.tsx +13 -0
- package/src/components/documents/documents.hooks.ts +146 -0
- package/src/components/documents/index.ts +23 -0
- package/src/components/documents/shared/document-preview-display.tsx +172 -0
- package/src/components/documents/shared/index.ts +3 -0
- package/src/components/documents/shared/scaled-document-preview.tsx +70 -0
- package/src/components/documents/shared/use-a4-scaling.ts +62 -0
- package/src/components/documents/types.ts +61 -0
- package/src/components/documents/view/document-actions-bar.tsx +328 -0
- package/src/components/documents/view/document-details-card.tsx +179 -0
- package/src/components/documents/view/document-payments-list.tsx +256 -0
- package/src/components/documents/view/index.ts +4 -0
- package/src/components/documents/view/locales/de.ts +85 -0
- package/src/components/documents/view/locales/sl.ts +84 -0
- package/src/components/documents/view/use-document-download.ts +125 -0
- package/src/components/entities/create-entity-form.tsx +105 -0
- package/src/components/entities/entities.hooks.ts +50 -0
- package/src/components/entities/entity-settings-form/email-template-variables-info.tsx +103 -0
- package/src/components/entities/entity-settings-form/entity-settings-form.tsx +1326 -0
- package/src/components/entities/entity-settings-form/image-upload-with-crop.tsx +222 -0
- package/src/components/entities/entity-settings-form/index.ts +2 -0
- package/src/components/entities/entity-settings-form/input-with-preview.tsx +190 -0
- package/src/components/entities/entity-settings-form/locales/de.ts +192 -0
- package/src/components/entities/entity-settings-form/locales/sl.ts +188 -0
- package/src/components/entities/furs-settings-form/furs-settings-form.tsx +410 -0
- package/src/components/entities/furs-settings-form/furs-settings.hooks.ts +320 -0
- package/src/components/entities/furs-settings-form/index.ts +3 -0
- package/src/components/entities/furs-settings-form/locales/de.ts +233 -0
- package/src/components/entities/furs-settings-form/locales/en.ts +194 -0
- package/src/components/entities/furs-settings-form/locales/sl.ts +196 -0
- package/src/components/entities/furs-settings-form/sections/certificate-settings-section.tsx +242 -0
- package/src/components/entities/furs-settings-form/sections/enable-fiscalization-section.tsx +139 -0
- package/src/components/entities/furs-settings-form/sections/general-settings-section.tsx +252 -0
- package/src/components/entities/furs-settings-form/sections/premises-management-section.tsx +370 -0
- package/src/components/entities/furs-settings-form/sections/register-premise-dialog.tsx +420 -0
- package/src/components/entities/keys.ts +2 -0
- package/src/components/entities/settings/branding-settings-form.tsx +274 -0
- package/src/components/entities/settings/company-settings-form.tsx +256 -0
- package/src/components/entities/settings/defaults-settings-form.tsx +501 -0
- package/src/components/entities/settings/email-settings-form.tsx +288 -0
- package/src/components/entities/settings/eslog-settings-form.tsx +113 -0
- package/src/components/entities/settings/index.ts +8 -0
- package/src/components/entities/settings/number-format-settings-form.tsx +244 -0
- package/src/components/entities/settings/pdf-template-selector/demo-invoice-data.ts +164 -0
- package/src/components/entities/settings/pdf-template-selector/index.ts +2 -0
- package/src/components/entities/settings/pdf-template-selector/locales/de.ts +18 -0
- package/src/components/entities/settings/pdf-template-selector/locales/sl.ts +18 -0
- package/src/components/entities/settings/pdf-template-selector/pdf-template-cards.tsx +49 -0
- package/src/components/entities/settings/settings-footer.tsx +16 -0
- package/src/components/entities/settings/tax-rules-settings-form.tsx +346 -0
- package/src/components/estimates/create/create-estimate-form.tsx +384 -0
- package/src/components/estimates/create/locales/de.ts +64 -0
- package/src/components/estimates/create/locales/sl.ts +63 -0
- package/src/components/estimates/create/prepare-estimate-submission.ts +39 -0
- package/src/components/estimates/create/use-estimate-customer-form.ts +5 -0
- package/src/components/estimates/estimates.hooks.ts +15 -0
- package/src/components/estimates/index.ts +6 -0
- package/src/components/estimates/list/index.ts +3 -0
- package/src/components/estimates/list/list-row-actions.tsx +103 -0
- package/src/components/estimates/list/list-table.tsx +171 -0
- package/src/components/estimates/list/locales/de.ts +26 -0
- package/src/components/estimates/list/locales/sl.ts +26 -0
- package/src/components/estimates/list/use-estimate-download.ts +63 -0
- package/src/components/export/document-export-form.tsx +288 -0
- package/src/components/export/index.ts +2 -0
- package/src/components/form/form-input.tsx +89 -0
- package/src/components/form/index.ts +1 -0
- package/src/components/invoices/create/create-invoice-form.tsx +852 -0
- package/src/components/invoices/create/eslog-validation.test.ts +242 -0
- package/src/components/invoices/create/eslog-validation.ts +208 -0
- package/src/components/invoices/create/locales/de.ts +118 -0
- package/src/components/invoices/create/locales/sl.ts +114 -0
- package/src/components/invoices/create/prepare-invoice-submission.test.ts +777 -0
- package/src/components/invoices/create/prepare-invoice-submission.ts +79 -0
- package/src/components/invoices/create/use-invoice-customer-form.ts +5 -0
- package/src/components/invoices/index.ts +9 -0
- package/src/components/invoices/invoices-furs.hooks.ts +28 -0
- package/src/components/invoices/invoices.hooks.ts +110 -0
- package/src/components/invoices/list/index.ts +3 -0
- package/src/components/invoices/list/list-row-actions.tsx +132 -0
- package/src/components/invoices/list/list-table.tsx +165 -0
- package/src/components/invoices/list/locales/de.ts +33 -0
- package/src/components/invoices/list/locales/sl.ts +33 -0
- package/src/components/invoices/list/use-invoice-download.ts +62 -0
- package/src/components/invoices/send-email-dialog/index.ts +1 -0
- package/src/components/invoices/send-email-dialog/locales/de.ts +18 -0
- package/src/components/invoices/send-email-dialog/locales/sl.ts +17 -0
- package/src/components/invoices/send-email-dialog/send-email-dialog.tsx +289 -0
- package/src/components/invoices/send-email-dialog.tsx +2 -0
- package/src/components/invoices/shared/index.ts +2 -0
- package/src/components/invoices/shared/scaled-document-preview.tsx +32 -0
- package/src/components/invoices/shared/use-a4-scaling.tsx +39 -0
- package/src/components/invoices/view/eslog-info-display.tsx +160 -0
- package/src/components/invoices/view/furs-info-display.tsx +213 -0
- package/src/components/items/create-item-form/create-item-form.tsx +155 -0
- package/src/components/items/create-item-form/locales/de.ts +14 -0
- package/src/components/items/create-item-form/locales/en.ts +9 -0
- package/src/components/items/create-item-form/locales/sl.ts +14 -0
- package/src/components/items/item-combobox.tsx +147 -0
- package/src/components/items/item-list-table/item-list-header.tsx +33 -0
- package/src/components/items/item-list-table/item-list-row-actions.tsx +48 -0
- package/src/components/items/item-list-table/item-list-row.tsx +32 -0
- package/src/components/items/item-list-table/item-list-table.tsx +76 -0
- package/src/components/items/item-list-table/locales/de.ts +10 -0
- package/src/components/items/item-list-table/locales/en.ts +10 -0
- package/src/components/items/item-list-table/locales/sl.ts +10 -0
- package/src/components/items/items.hooks.ts +63 -0
- package/src/components/loading-spinner.tsx +24 -0
- package/src/components/payments/create-payment-form/create-payment-form.tsx +222 -0
- package/src/components/payments/create-payment-form/locales/de.ts +20 -0
- package/src/components/payments/create-payment-form/locales/sl.ts +20 -0
- package/src/components/payments/edit-payment-form/edit-payment-form.tsx +230 -0
- package/src/components/payments/edit-payment-form/index.ts +1 -0
- package/src/components/payments/edit-payment-form/locales/de.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/sl.ts +20 -0
- package/src/components/payments/index.ts +4 -0
- package/src/components/payments/list/index.ts +2 -0
- package/src/components/payments/list/list-row-actions.tsx +98 -0
- package/src/components/payments/list/list-table.tsx +186 -0
- package/src/components/payments/list/locales/de.ts +19 -0
- package/src/components/payments/list/locales/sl.ts +19 -0
- package/src/components/payments/payments.hooks.ts +15 -0
- package/src/components/request-logs/index.ts +3 -0
- package/src/components/request-logs/request-log-detail.tsx +242 -0
- package/src/components/request-logs/request-log-list-table.tsx +266 -0
- package/src/components/request-logs/request-logs-page.tsx +10 -0
- package/src/components/table/README.md +410 -0
- package/src/components/table/data-table.tsx +251 -0
- package/src/components/table/date-cell.tsx +35 -0
- package/src/components/table/filter-bar.tsx +114 -0
- package/src/components/table/filter-panel.tsx +407 -0
- package/src/components/table/hooks/use-table-fetch.ts +17 -0
- package/src/components/table/hooks/use-table-query.ts +36 -0
- package/src/components/table/hooks/use-table-state.ts +293 -0
- package/src/components/table/index.ts +35 -0
- package/src/components/table/search-input.tsx +85 -0
- package/src/components/table/sortable-header.tsx +56 -0
- package/src/components/table/table-empty-state.tsx +40 -0
- package/src/components/table/table-no-results.tsx +41 -0
- package/src/components/table/table-pagination.tsx +42 -0
- package/src/components/table/table-skeleton.tsx +54 -0
- package/src/components/table/types.ts +136 -0
- package/src/components/tax-reports/index.ts +1 -0
- package/src/components/tax-reports/kir-export-form.tsx +172 -0
- package/src/components/taxes/create-tax-form/create-tax-form.tsx +112 -0
- package/src/components/taxes/create-tax-form/locales/de.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/en.ts +7 -0
- package/src/components/taxes/create-tax-form/locales/sl.ts +8 -0
- package/src/components/taxes/tax-list-table/locales/de.ts +11 -0
- package/src/components/taxes/tax-list-table/locales/en.ts +10 -0
- package/src/components/taxes/tax-list-table/locales/sl.ts +11 -0
- package/src/components/taxes/tax-list-table/tax-list-header.tsx +29 -0
- package/src/components/taxes/tax-list-table/tax-list-row-actions.tsx +43 -0
- package/src/components/taxes/tax-list-table/tax-list-row.tsx +46 -0
- package/src/components/taxes/tax-list-table/tax-list-table.tsx +59 -0
- package/src/components/taxes/taxes.hooks.ts +35 -0
- package/src/components/ui/alert-dialog.tsx +61 -0
- package/src/components/ui/alert.tsx +72 -0
- package/src/components/ui/badge.tsx +48 -0
- package/src/components/ui/breadcrumb.tsx +132 -0
- package/src/components/ui/button.tsx +61 -0
- package/src/components/ui/calendar.tsx +213 -0
- package/src/components/ui/card.tsx +94 -0
- package/src/components/ui/chart.tsx +380 -0
- package/src/components/ui/checkbox.tsx +27 -0
- package/src/components/ui/collapsible.tsx +56 -0
- package/src/components/ui/command.tsx +187 -0
- package/src/components/ui/dialog.tsx +187 -0
- package/src/components/ui/drawer.tsx +123 -0
- package/src/components/ui/dropdown-menu.tsx +291 -0
- package/src/components/ui/form.tsx +166 -0
- package/src/components/ui/input-group.tsx +149 -0
- package/src/components/ui/input.tsx +20 -0
- package/src/components/ui/label.tsx +18 -0
- package/src/components/ui/loading-spinner.tsx +16 -0
- package/src/components/ui/popover.tsx +108 -0
- package/src/components/ui/radio-group.tsx +37 -0
- package/src/components/ui/select.tsx +200 -0
- package/src/components/ui/separator.tsx +23 -0
- package/src/components/ui/sheet.tsx +145 -0
- package/src/components/ui/sidebar.tsx +771 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/sonner.tsx +60 -0
- package/src/components/ui/spinner.tsx +10 -0
- package/src/components/ui/sticky-form-footer.tsx +55 -0
- package/src/components/ui/switch.tsx +30 -0
- package/src/components/ui/table.tsx +101 -0
- package/src/components/ui/tabs.tsx +80 -0
- package/src/components/ui/textarea.tsx +18 -0
- package/src/components/ui/tooltip.tsx +89 -0
- package/src/components/wl-subscription/index.ts +2 -0
- package/src/components/wl-subscription/locked-feature.tsx +173 -0
- package/src/components/wl-subscription/upgrade-modal.tsx +209 -0
- package/src/frontend.tsx +28 -0
- package/src/generate-schemas.ts +265 -0
- package/src/generated/schemas/advanceinvoice.ts +177 -0
- package/src/generated/schemas/creditnote.ts +187 -0
- package/src/generated/schemas/customer.ts +29 -0
- package/src/generated/schemas/entity.ts +252 -0
- package/src/generated/schemas/estimate.ts +159 -0
- package/src/generated/schemas/furssettings.ts +25 -0
- package/src/generated/schemas/index.ts +24 -0
- package/src/generated/schemas/invoice.ts +167 -0
- package/src/generated/schemas/item.ts +38 -0
- package/src/generated/schemas/payment.ts +44 -0
- package/src/generated/schemas/previewadvanceinvoice_body.ts +354 -0
- package/src/generated/schemas/previewestimate_body.ts +309 -0
- package/src/generated/schemas/registerfursmovablepremise_body.ts +22 -0
- package/src/generated/schemas/registerfursrealestatepremise_body.ts +32 -0
- package/src/generated/schemas/renderdocument_body.ts +594 -0
- package/src/generated/schemas/sendemail_body.ts +26 -0
- package/src/generated/schemas/startpdfexport_body.ts +20 -0
- package/src/generated/schemas/tax.ts +48 -0
- package/src/generated/schemas/uploadfile_body.ts +23 -0
- package/src/generated/schemas/uploadfurscertificate_body.ts +20 -0
- package/src/generated/schemas/userfurssettings.ts +19 -0
- package/src/hooks/create-resource-hooks.test.ts +483 -0
- package/src/hooks/create-resource-hooks.ts +300 -0
- package/src/hooks/use-debounce.ts +12 -0
- package/src/hooks/use-duplicate-document.ts +185 -0
- package/src/hooks/use-media-query.tsx +19 -0
- package/src/hooks/use-mobile.ts +39 -0
- package/src/hooks/use-next-document-number.ts +57 -0
- package/src/hooks/use-resource-mutation.ts +118 -0
- package/src/hooks/use-vies-check.ts +130 -0
- package/src/index.css +11 -0
- package/src/index.html +13 -0
- package/src/index.tsx +12 -0
- package/src/lib/auth.ts +4 -0
- package/src/lib/browser-cookies.ts +70 -0
- package/src/lib/constants.ts +287 -0
- package/src/lib/cookies.ts +36 -0
- package/src/lib/schemas/advance-invoice.ts +43 -0
- package/src/lib/schemas/credit-note.ts +32 -0
- package/src/lib/schemas/estimate.ts +31 -0
- package/src/lib/schemas/index.ts +18 -0
- package/src/lib/schemas/invoice.ts +43 -0
- package/src/lib/schemas/shared.ts +79 -0
- package/src/lib/translation.ts +38 -0
- package/src/lib/utils.ts +6 -0
- package/src/providers/entities-context.tsx +41 -0
- package/src/providers/entities-provider.tsx +201 -0
- package/src/providers/form-footer-context.tsx +72 -0
- package/src/providers/sdk-provider.tsx +164 -0
- package/src/providers/white-label-provider.tsx +91 -0
- package/src/providers/wl-subscription-provider.tsx +277 -0
- package/src/utils/string-helpers.ts +111 -0
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import type { Item } from "@spaceinvoices/js-sdk";
|
|
2
|
+
import { ChevronDown, ChevronUp, DollarSign, Minus, Percent, Plus, PlusIcon, Trash2 } from "lucide-react";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import type { Control, UseFormReturn } from "react-hook-form";
|
|
5
|
+
import { useWatch } from "react-hook-form";
|
|
6
|
+
|
|
7
|
+
import { ItemCombobox } from "@/ui/components/items/item-combobox";
|
|
8
|
+
import { Button } from "@/ui/components/ui/button";
|
|
9
|
+
import {
|
|
10
|
+
DropdownMenu,
|
|
11
|
+
DropdownMenuContent,
|
|
12
|
+
DropdownMenuItem,
|
|
13
|
+
DropdownMenuRadioGroup,
|
|
14
|
+
DropdownMenuRadioItem,
|
|
15
|
+
DropdownMenuTrigger,
|
|
16
|
+
} from "@/ui/components/ui/dropdown-menu";
|
|
17
|
+
import { FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/ui/components/ui/form";
|
|
18
|
+
import { Input } from "@/ui/components/ui/input";
|
|
19
|
+
import { Textarea } from "@/ui/components/ui/textarea";
|
|
20
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "@/ui/components/ui/tooltip";
|
|
21
|
+
|
|
22
|
+
import DocumentAddItemTaxRateField from "./document-add-item-tax-rate-field";
|
|
23
|
+
|
|
24
|
+
type DocumentAddItemFormProps = {
|
|
25
|
+
index: number;
|
|
26
|
+
control: Control<any>;
|
|
27
|
+
entityId: string;
|
|
28
|
+
currencyCode?: string;
|
|
29
|
+
onRemove: () => void;
|
|
30
|
+
onMoveUp: () => void;
|
|
31
|
+
onMoveDown: () => void;
|
|
32
|
+
onAddNewTax?: () => void;
|
|
33
|
+
showRemove: boolean;
|
|
34
|
+
showMoveUp: boolean;
|
|
35
|
+
showMoveDown: boolean;
|
|
36
|
+
form: UseFormReturn<any>;
|
|
37
|
+
t: (key: string) => string;
|
|
38
|
+
/** When true, tax controls are disabled (e.g., for VIES reverse charge) */
|
|
39
|
+
taxesDisabled?: boolean;
|
|
40
|
+
/** Message to show when taxes are disabled */
|
|
41
|
+
taxesDisabledMessage?: string;
|
|
42
|
+
/** Maximum number of taxes per item, derived from country rules. Defaults to 1. */
|
|
43
|
+
maxTaxesPerItem?: number;
|
|
44
|
+
/** Initial gross price mode (from duplicated document) */
|
|
45
|
+
initialIsGrossPrice?: boolean;
|
|
46
|
+
/** Called when price mode changes - used to collect state at submit */
|
|
47
|
+
onPriceModeChange?: (isGross: boolean) => void;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default function DocumentAddItemForm({
|
|
51
|
+
index,
|
|
52
|
+
control,
|
|
53
|
+
entityId,
|
|
54
|
+
currencyCode,
|
|
55
|
+
onRemove,
|
|
56
|
+
onMoveUp,
|
|
57
|
+
onMoveDown,
|
|
58
|
+
onAddNewTax,
|
|
59
|
+
showRemove,
|
|
60
|
+
showMoveUp,
|
|
61
|
+
showMoveDown,
|
|
62
|
+
form,
|
|
63
|
+
t,
|
|
64
|
+
taxesDisabled,
|
|
65
|
+
taxesDisabledMessage,
|
|
66
|
+
maxTaxesPerItem = 1,
|
|
67
|
+
initialIsGrossPrice = false,
|
|
68
|
+
onPriceModeChange,
|
|
69
|
+
}: DocumentAddItemFormProps) {
|
|
70
|
+
const taxes = useWatch({
|
|
71
|
+
control,
|
|
72
|
+
name: `items.${index}.taxes`,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Component-local state for gross/net price mode (not in form schema)
|
|
76
|
+
const [isGrossPrice, setIsGrossPrice] = useState(initialIsGrossPrice);
|
|
77
|
+
|
|
78
|
+
const setPriceMode = (mode: string) => {
|
|
79
|
+
const isGross = mode === "gross";
|
|
80
|
+
setIsGrossPrice(isGross);
|
|
81
|
+
onPriceModeChange?.(isGross);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const addTax = () => {
|
|
85
|
+
const currentTaxes = taxes || [];
|
|
86
|
+
if (currentTaxes.length >= maxTaxesPerItem) return;
|
|
87
|
+
|
|
88
|
+
form.setValue(`items.${index}.taxes`, [
|
|
89
|
+
...currentTaxes,
|
|
90
|
+
{
|
|
91
|
+
rate: 22,
|
|
92
|
+
},
|
|
93
|
+
]);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const removeTax = (taxIndex: number) => {
|
|
97
|
+
const currentTaxes = taxes || [];
|
|
98
|
+
form.setValue(
|
|
99
|
+
`items.${index}.taxes`,
|
|
100
|
+
currentTaxes.filter((_: any, i: number) => i !== taxIndex),
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Handle item selection from combobox
|
|
105
|
+
const handleItemSelect = (item: Item | null, customName?: string) => {
|
|
106
|
+
if (item) {
|
|
107
|
+
// Selected a saved item - set item_id and prefill fields for visual feedback
|
|
108
|
+
form.setValue(`items.${index}.item_id`, item.id);
|
|
109
|
+
form.setValue(`items.${index}.name`, item.name);
|
|
110
|
+
|
|
111
|
+
// Prefill price (use gross_price if available, otherwise price)
|
|
112
|
+
if (item.gross_price !== null && item.gross_price !== undefined) {
|
|
113
|
+
form.setValue(`items.${index}.price`, item.gross_price);
|
|
114
|
+
setIsGrossPrice(true);
|
|
115
|
+
onPriceModeChange?.(true);
|
|
116
|
+
} else if (item.price !== null && item.price !== undefined) {
|
|
117
|
+
form.setValue(`items.${index}.price`, item.price);
|
|
118
|
+
setIsGrossPrice(false);
|
|
119
|
+
onPriceModeChange?.(false);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Prefill description
|
|
123
|
+
if (item.description) {
|
|
124
|
+
form.setValue(`items.${index}.description`, item.description);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Prefill taxes from item's tax_ids (or clear if item has no taxes)
|
|
128
|
+
if (item.tax_ids && item.tax_ids.length > 0) {
|
|
129
|
+
form.setValue(
|
|
130
|
+
`items.${index}.taxes`,
|
|
131
|
+
item.tax_ids.map((tax_id) => ({ tax_id })),
|
|
132
|
+
);
|
|
133
|
+
} else {
|
|
134
|
+
form.setValue(`items.${index}.taxes`, []);
|
|
135
|
+
}
|
|
136
|
+
} else if (customName) {
|
|
137
|
+
// Custom name entered - clear item_id, just use the name
|
|
138
|
+
form.setValue(`items.${index}.item_id`, undefined);
|
|
139
|
+
form.setValue(`items.${index}.name`, customName);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<div className="space-y-4 rounded-lg border p-4">
|
|
145
|
+
{/* Header row with name and remove button */}
|
|
146
|
+
<div className="flex items-start gap-4">
|
|
147
|
+
<div className="flex-1">
|
|
148
|
+
<FormField
|
|
149
|
+
control={control}
|
|
150
|
+
name={`items.${index}.name`}
|
|
151
|
+
render={({ field }) => (
|
|
152
|
+
<FormItem>
|
|
153
|
+
<FormControl>
|
|
154
|
+
<ItemCombobox
|
|
155
|
+
entityId={entityId}
|
|
156
|
+
value={field.value}
|
|
157
|
+
onSelect={handleItemSelect}
|
|
158
|
+
placeholder={t("Search or enter item name...")}
|
|
159
|
+
/>
|
|
160
|
+
</FormControl>
|
|
161
|
+
<FormMessage />
|
|
162
|
+
</FormItem>
|
|
163
|
+
)}
|
|
164
|
+
/>
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
{showRemove && (
|
|
168
|
+
<Button type="button" variant="ghost" size="icon" onClick={onRemove}>
|
|
169
|
+
<Trash2 className="h-4 w-4" />
|
|
170
|
+
</Button>
|
|
171
|
+
)}
|
|
172
|
+
</div>
|
|
173
|
+
|
|
174
|
+
{/* Middle row with unit, quantity, price, discount */}
|
|
175
|
+
<div className="grid w-full grid-cols-12 gap-4">
|
|
176
|
+
<FormField
|
|
177
|
+
control={control}
|
|
178
|
+
name={`items.${index}.quantity`}
|
|
179
|
+
render={({ field }) => (
|
|
180
|
+
<FormItem className="col-span-2">
|
|
181
|
+
<FormLabel>
|
|
182
|
+
{t("Quantity")} <span className="text-red-500">*</span>
|
|
183
|
+
</FormLabel>
|
|
184
|
+
<FormControl>
|
|
185
|
+
<Input type="number" {...field} onChange={(e) => field.onChange(Number(e.target.value))} />
|
|
186
|
+
</FormControl>
|
|
187
|
+
<FormMessage />
|
|
188
|
+
</FormItem>
|
|
189
|
+
)}
|
|
190
|
+
/>
|
|
191
|
+
|
|
192
|
+
<FormField
|
|
193
|
+
control={control}
|
|
194
|
+
name={`items.${index}.price`}
|
|
195
|
+
render={({ field }) => (
|
|
196
|
+
<FormItem className="col-span-3">
|
|
197
|
+
<FormLabel>
|
|
198
|
+
{isGrossPrice ? t("Gross price") : t("Price")} <span className="text-red-500">*</span>
|
|
199
|
+
</FormLabel>
|
|
200
|
+
<div className="flex">
|
|
201
|
+
<FormControl>
|
|
202
|
+
<Input
|
|
203
|
+
type="number"
|
|
204
|
+
className="rounded-r-none"
|
|
205
|
+
{...field}
|
|
206
|
+
value={field.value ?? ""}
|
|
207
|
+
onChange={(e) => field.onChange(e.target.value === "" ? undefined : Number(e.target.value))}
|
|
208
|
+
/>
|
|
209
|
+
</FormControl>
|
|
210
|
+
<DropdownMenu>
|
|
211
|
+
<Tooltip>
|
|
212
|
+
<TooltipTrigger asChild>
|
|
213
|
+
<DropdownMenuTrigger asChild>
|
|
214
|
+
<Button type="button" variant="outline" size="icon" className="rounded-l-none border-l-0">
|
|
215
|
+
{isGrossPrice ? <Minus className="h-4 w-4" /> : <Plus className="h-4 w-4" />}
|
|
216
|
+
</Button>
|
|
217
|
+
</DropdownMenuTrigger>
|
|
218
|
+
</TooltipTrigger>
|
|
219
|
+
<TooltipContent side="top">
|
|
220
|
+
{isGrossPrice ? t("Gross price (tax included)") : t("Net price (before tax)")}
|
|
221
|
+
</TooltipContent>
|
|
222
|
+
</Tooltip>
|
|
223
|
+
<DropdownMenuContent align="end">
|
|
224
|
+
<DropdownMenuRadioGroup value={isGrossPrice ? "gross" : "net"} onValueChange={setPriceMode}>
|
|
225
|
+
<DropdownMenuRadioItem value="net">{t("Net price")}</DropdownMenuRadioItem>
|
|
226
|
+
<DropdownMenuRadioItem value="gross">{t("Gross price")}</DropdownMenuRadioItem>
|
|
227
|
+
</DropdownMenuRadioGroup>
|
|
228
|
+
</DropdownMenuContent>
|
|
229
|
+
</DropdownMenu>
|
|
230
|
+
</div>
|
|
231
|
+
<FormMessage />
|
|
232
|
+
</FormItem>
|
|
233
|
+
)}
|
|
234
|
+
/>
|
|
235
|
+
|
|
236
|
+
<FormField
|
|
237
|
+
control={control}
|
|
238
|
+
name={`items.${index}.unit`}
|
|
239
|
+
render={({ field }) => (
|
|
240
|
+
<FormItem className="col-span-2">
|
|
241
|
+
<FormLabel>{t("Unit")}</FormLabel>
|
|
242
|
+
<FormControl>
|
|
243
|
+
<Input {...field} />
|
|
244
|
+
</FormControl>
|
|
245
|
+
<FormMessage />
|
|
246
|
+
</FormItem>
|
|
247
|
+
)}
|
|
248
|
+
/>
|
|
249
|
+
|
|
250
|
+
<FormField
|
|
251
|
+
control={control}
|
|
252
|
+
name={`items.${index}.discounts`}
|
|
253
|
+
render={({ field }) => {
|
|
254
|
+
const discount = field.value?.[0] || { value: 0, type: "percent" };
|
|
255
|
+
const isPercent = discount.type !== "amount";
|
|
256
|
+
|
|
257
|
+
const setDiscount = (value: number | undefined, type: "percent" | "amount") => {
|
|
258
|
+
field.onChange(value !== undefined ? [{ value, type }] : []);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
const _toggleType = () => {
|
|
262
|
+
setDiscount(discount.value, isPercent ? "amount" : "percent");
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
return (
|
|
266
|
+
<FormItem className="col-span-2">
|
|
267
|
+
<FormLabel>{t("Discount")}</FormLabel>
|
|
268
|
+
<div className="flex">
|
|
269
|
+
<FormControl>
|
|
270
|
+
<Input
|
|
271
|
+
type="number"
|
|
272
|
+
placeholder="0"
|
|
273
|
+
className="rounded-r-none"
|
|
274
|
+
value={discount.value || ""}
|
|
275
|
+
onChange={(e) =>
|
|
276
|
+
setDiscount(e.target.value ? Number(e.target.value) : undefined, discount.type || "percent")
|
|
277
|
+
}
|
|
278
|
+
/>
|
|
279
|
+
</FormControl>
|
|
280
|
+
<DropdownMenu>
|
|
281
|
+
<Tooltip>
|
|
282
|
+
<TooltipTrigger asChild>
|
|
283
|
+
<DropdownMenuTrigger asChild>
|
|
284
|
+
<Button type="button" variant="outline" size="icon" className="rounded-l-none border-l-0">
|
|
285
|
+
{isPercent ? <Percent className="h-4 w-4" /> : <DollarSign className="h-4 w-4" />}
|
|
286
|
+
</Button>
|
|
287
|
+
</DropdownMenuTrigger>
|
|
288
|
+
</TooltipTrigger>
|
|
289
|
+
<TooltipContent side="top">
|
|
290
|
+
{isPercent ? t("Percentage discount") : t("Fixed amount discount")}
|
|
291
|
+
</TooltipContent>
|
|
292
|
+
</Tooltip>
|
|
293
|
+
<DropdownMenuContent align="end">
|
|
294
|
+
<DropdownMenuItem onClick={() => setDiscount(discount.value, "percent")}>
|
|
295
|
+
<Percent className="mr-2 h-4 w-4" />
|
|
296
|
+
{t("Percentage")}
|
|
297
|
+
</DropdownMenuItem>
|
|
298
|
+
<DropdownMenuItem onClick={() => setDiscount(discount.value, "amount")}>
|
|
299
|
+
<DollarSign className="mr-2 h-4 w-4" />
|
|
300
|
+
{t("Fixed amount")}
|
|
301
|
+
</DropdownMenuItem>
|
|
302
|
+
</DropdownMenuContent>
|
|
303
|
+
</DropdownMenu>
|
|
304
|
+
</div>
|
|
305
|
+
<FormMessage />
|
|
306
|
+
</FormItem>
|
|
307
|
+
);
|
|
308
|
+
}}
|
|
309
|
+
/>
|
|
310
|
+
|
|
311
|
+
<div className="col-span-3 space-y-2">
|
|
312
|
+
<FormLabel>{t("Tax")}</FormLabel>
|
|
313
|
+
{taxesDisabled ? (
|
|
314
|
+
<div className="rounded-md border border-muted-foreground/50 border-dashed bg-muted/50 p-2 text-muted-foreground text-sm">
|
|
315
|
+
{taxesDisabledMessage || t("Taxes disabled")}
|
|
316
|
+
</div>
|
|
317
|
+
) : (
|
|
318
|
+
<>
|
|
319
|
+
{taxes?.map((_tax: any, taxIndex: number) => (
|
|
320
|
+
<DocumentAddItemTaxRateField
|
|
321
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: index is stable
|
|
322
|
+
key={taxIndex}
|
|
323
|
+
index={index}
|
|
324
|
+
taxIndex={taxIndex}
|
|
325
|
+
control={control}
|
|
326
|
+
entityId={entityId}
|
|
327
|
+
onRemove={() => removeTax(taxIndex)}
|
|
328
|
+
onAddNewTax={onAddNewTax}
|
|
329
|
+
showLabel={false}
|
|
330
|
+
t={t}
|
|
331
|
+
/>
|
|
332
|
+
))}
|
|
333
|
+
|
|
334
|
+
{(!taxes || taxes.length < maxTaxesPerItem) && (
|
|
335
|
+
<Button type="button" variant="outline" size="sm" className="cursor-pointer" onClick={addTax}>
|
|
336
|
+
<PlusIcon className="h-4 w-4" />
|
|
337
|
+
{t("Add tax")}
|
|
338
|
+
</Button>
|
|
339
|
+
)}
|
|
340
|
+
</>
|
|
341
|
+
)}
|
|
342
|
+
</div>
|
|
343
|
+
</div>
|
|
344
|
+
|
|
345
|
+
{/* Bottom row with description and move buttons */}
|
|
346
|
+
<div className="flex gap-4">
|
|
347
|
+
<div className="flex-1">
|
|
348
|
+
<FormField
|
|
349
|
+
control={control}
|
|
350
|
+
name={`items.${index}.description`}
|
|
351
|
+
render={({ field }) => (
|
|
352
|
+
<FormItem>
|
|
353
|
+
<FormControl>
|
|
354
|
+
<Textarea placeholder={t("Description")} {...field} />
|
|
355
|
+
</FormControl>
|
|
356
|
+
<FormMessage />
|
|
357
|
+
</FormItem>
|
|
358
|
+
)}
|
|
359
|
+
/>
|
|
360
|
+
</div>
|
|
361
|
+
|
|
362
|
+
{(showMoveUp || showMoveDown) && (
|
|
363
|
+
<div className="flex flex-col gap-2">
|
|
364
|
+
{showMoveUp && (
|
|
365
|
+
<Button type="button" variant="ghost" size="icon" onClick={onMoveUp} className="mt-auto">
|
|
366
|
+
<ChevronUp className="h-4 w-4" />
|
|
367
|
+
</Button>
|
|
368
|
+
)}
|
|
369
|
+
{showMoveDown && (
|
|
370
|
+
<Button type="button" variant="ghost" size="icon" onClick={onMoveDown} className="mt-auto">
|
|
371
|
+
<ChevronDown className="h-4 w-4" />
|
|
372
|
+
</Button>
|
|
373
|
+
)}
|
|
374
|
+
</div>
|
|
375
|
+
)}
|
|
376
|
+
</div>
|
|
377
|
+
</div>
|
|
378
|
+
);
|
|
379
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { Tax } from "@spaceinvoices/js-sdk";
|
|
2
|
+
import { Plus, Trash2 } from "lucide-react";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import type { Control } from "react-hook-form";
|
|
5
|
+
import { useFormContext, useWatch } from "react-hook-form";
|
|
6
|
+
import { Button } from "@/ui/components/ui/button";
|
|
7
|
+
import { FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/ui/components/ui/form";
|
|
8
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/ui/components/ui/select";
|
|
9
|
+
import type { ComponentTranslationProps } from "@/ui/lib/translation";
|
|
10
|
+
import { useListTaxes } from "../../taxes/taxes.hooks";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Get the current active rate from a tax (most recent rate by valid_from)
|
|
14
|
+
*/
|
|
15
|
+
function getCurrentRate(tax: Tax): number {
|
|
16
|
+
if (!tax.tax_rates || tax.tax_rates.length === 0) {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
// Sort by valid_from descending and get the first (most recent)
|
|
20
|
+
const sorted = [...tax.tax_rates].sort((a, b) => {
|
|
21
|
+
const dateA = a.valid_from ? new Date(a.valid_from).getTime() : 0;
|
|
22
|
+
const dateB = b.valid_from ? new Date(b.valid_from).getTime() : 0;
|
|
23
|
+
return dateB - dateA;
|
|
24
|
+
});
|
|
25
|
+
return sorted[0].rate;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type DocumentAddItemTaxRateFieldProps = {
|
|
29
|
+
index: number;
|
|
30
|
+
taxIndex: number;
|
|
31
|
+
control: Control<any>;
|
|
32
|
+
entityId: string;
|
|
33
|
+
onRemove: () => void;
|
|
34
|
+
onAddNewTax?: () => void;
|
|
35
|
+
showLabel?: boolean;
|
|
36
|
+
} & ComponentTranslationProps;
|
|
37
|
+
|
|
38
|
+
export default function DocumentAddItemTaxRateField({
|
|
39
|
+
index,
|
|
40
|
+
taxIndex,
|
|
41
|
+
control,
|
|
42
|
+
entityId,
|
|
43
|
+
onRemove,
|
|
44
|
+
onAddNewTax,
|
|
45
|
+
showLabel = true,
|
|
46
|
+
t,
|
|
47
|
+
}: DocumentAddItemTaxRateFieldProps) {
|
|
48
|
+
const translate = t || ((key: string) => key);
|
|
49
|
+
const { setValue } = useFormContext();
|
|
50
|
+
|
|
51
|
+
// Fetch available taxes
|
|
52
|
+
const { data: taxesResponse } = useListTaxes(entityId);
|
|
53
|
+
const taxes = taxesResponse?.data || [];
|
|
54
|
+
|
|
55
|
+
// Watch current selection
|
|
56
|
+
const selectedTaxId = useWatch({
|
|
57
|
+
control,
|
|
58
|
+
name: `items.${index}.taxes.${taxIndex}.tax_id`,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Auto-select default tax (or first tax) when taxes are loaded and no selection exists
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (taxes.length > 0 && !selectedTaxId) {
|
|
64
|
+
// Prefer the default tax, fallback to first tax
|
|
65
|
+
const defaultTax = taxes.find((tax) => tax.is_default) || taxes[0];
|
|
66
|
+
setValue(`items.${index}.taxes.${taxIndex}.tax_id`, defaultTax.id);
|
|
67
|
+
}
|
|
68
|
+
}, [taxes, selectedTaxId, setValue, index, taxIndex]);
|
|
69
|
+
|
|
70
|
+
// Handle tax selection - only store tax_id, API resolves rate
|
|
71
|
+
const handleSelect = (value: string) => {
|
|
72
|
+
if (value === "__create__") {
|
|
73
|
+
onAddNewTax?.();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
setValue(`items.${index}.taxes.${taxIndex}.tax_id`, value);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// Get display label for selected tax
|
|
81
|
+
const selectedTax = taxes.find((t) => t.id === selectedTaxId);
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<FormField
|
|
85
|
+
control={control}
|
|
86
|
+
name={`items.${index}.taxes.${taxIndex}.tax_id`}
|
|
87
|
+
render={({ field }) => (
|
|
88
|
+
<FormItem>
|
|
89
|
+
{showLabel && <FormLabel>{translate("Tax")}</FormLabel>}
|
|
90
|
+
<div className="flex items-center gap-1">
|
|
91
|
+
<FormControl className="min-w-0 flex-1">
|
|
92
|
+
<Select value={field.value ?? ""} onValueChange={handleSelect}>
|
|
93
|
+
<SelectTrigger size="sm" className="w-full">
|
|
94
|
+
<SelectValue placeholder="Tax">{selectedTax ? `${getCurrentRate(selectedTax)}%` : null}</SelectValue>
|
|
95
|
+
</SelectTrigger>
|
|
96
|
+
<SelectContent>
|
|
97
|
+
{taxes.map((tax) => (
|
|
98
|
+
<SelectItem key={tax.id} value={tax.id}>
|
|
99
|
+
{tax.name} {getCurrentRate(tax)}%
|
|
100
|
+
</SelectItem>
|
|
101
|
+
))}
|
|
102
|
+
{onAddNewTax && (
|
|
103
|
+
<SelectItem value="__create__">
|
|
104
|
+
<Plus className="size-4" />
|
|
105
|
+
{translate("Add...")}
|
|
106
|
+
</SelectItem>
|
|
107
|
+
)}
|
|
108
|
+
</SelectContent>
|
|
109
|
+
</Select>
|
|
110
|
+
</FormControl>
|
|
111
|
+
<Button type="button" variant="ghost" size="icon" onClick={onRemove} className="h-9 w-9 shrink-0">
|
|
112
|
+
<Trash2 className="h-4 w-4" />
|
|
113
|
+
</Button>
|
|
114
|
+
</div>
|
|
115
|
+
<FormMessage />
|
|
116
|
+
</FormItem>
|
|
117
|
+
)}
|
|
118
|
+
/>
|
|
119
|
+
);
|
|
120
|
+
}
|