@spaceinvoices/react-ui 0.4.8 → 0.4.10
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/src/common/autocomplete.tsx +69 -6
- package/src/components/advance-invoices/create/create-advance-invoice-form.tsx +124 -285
- package/src/components/advance-invoices/list/list-table.tsx +10 -3
- package/src/components/advance-invoices/list/locales/de.ts +2 -0
- package/src/components/advance-invoices/list/locales/en.ts +1 -0
- package/src/components/advance-invoices/list/locales/es.ts +1 -0
- package/src/components/advance-invoices/list/locales/fr.ts +1 -0
- package/src/components/advance-invoices/list/locales/hr.ts +1 -0
- package/src/components/advance-invoices/list/locales/it.ts +1 -0
- package/src/components/advance-invoices/list/locales/nl.ts +1 -0
- package/src/components/advance-invoices/list/locales/pl.ts +1 -0
- package/src/components/advance-invoices/list/locales/pt.ts +1 -0
- package/src/components/advance-invoices/list/locales/sl.ts +1 -0
- package/src/components/advance-invoices/list/use-advance-invoice-download.ts +1 -12
- package/src/components/credit-notes/create/create-credit-note-form.tsx +116 -238
- package/src/components/credit-notes/list/list-table.tsx +6 -3
- package/src/components/credit-notes/list/use-credit-note-download.ts +1 -12
- package/src/components/customers/customer-autocomplete.tsx +64 -11
- package/src/components/customers/customer-list-table/customer-list-table.tsx +3 -2
- package/src/components/dashboard/collection-rate-card/collection-rate-card.tsx +9 -1
- package/src/components/dashboard/collection-rate-card/locales/bg.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/cs.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/et.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/fi.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/is.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/nb.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/sk.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/sv.ts +3 -0
- package/src/components/dashboard/invoice-status-chart/invoice-status-chart.tsx +10 -2
- package/src/components/dashboard/invoice-status-chart/locales/bg.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/cs.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/de.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/es.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/et.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/fi.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/fr.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/hr.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/is.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/it.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/nb.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/nl.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/pl.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/pt.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/sk.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/sl.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/sv.ts +10 -0
- package/src/components/dashboard/payment-methods-chart/locales/bg.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/cs.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/et.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/fi.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/is.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/nb.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/sk.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/sv.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/payment-methods-chart.tsx +9 -1
- package/src/components/dashboard/payment-trend-chart/locales/bg.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/cs.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/de.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/es.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/et.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/fi.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/fr.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/hr.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/is.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/it.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/nb.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/nl.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/pl.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/pt.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/sk.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/sl.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/sv.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/payment-trend-chart.tsx +15 -8
- package/src/components/dashboard/revenue-trend-chart/locales/bg.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/cs.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/de.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/es.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/et.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/fi.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/fr.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/hr.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/is.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/it.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/nb.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/nl.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/pl.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/pt.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/sk.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/sl.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/sv.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/revenue-trend-chart.tsx +15 -8
- package/src/components/dashboard/tax-collected-card/locales.ts +110 -0
- package/src/components/dashboard/tax-collected-card/tax-collected-card.tsx +8 -2
- package/src/components/dashboard/tax-collected-card/use-tax-collected.ts +4 -4
- package/src/components/dashboard/top-customers-chart/locales/bg.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/cs.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/de.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/es.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/et.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/fi.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/fr.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/hr.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/is.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/it.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/nb.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/nl.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/pl.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/pt.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/sk.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/sl.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/sv.ts +7 -0
- package/src/components/dashboard/top-customers-chart/top-customers-chart.tsx +23 -12
- package/src/components/delivery-notes/create/create-delivery-note-form.tsx +33 -20
- package/src/components/delivery-notes/list/list-table.tsx +22 -13
- package/src/components/delivery-notes/list/locales/de.ts +2 -0
- package/src/components/delivery-notes/list/locales/en.ts +1 -0
- package/src/components/delivery-notes/list/locales/es.ts +1 -0
- package/src/components/delivery-notes/list/locales/fr.ts +1 -0
- package/src/components/delivery-notes/list/locales/hr.ts +1 -0
- package/src/components/delivery-notes/list/locales/it.ts +1 -0
- package/src/components/delivery-notes/list/locales/nl.ts +1 -0
- package/src/components/delivery-notes/list/locales/pl.ts +1 -0
- package/src/components/delivery-notes/list/locales/pt.ts +1 -0
- package/src/components/delivery-notes/list/locales/sl.ts +1 -0
- package/src/components/delivery-notes/list/use-delivery-note-download.ts +1 -12
- package/src/components/documents/create/document-add-item-form.tsx +28 -16
- package/src/components/documents/create/document-add-item-tax-rate-field.tsx +12 -2
- package/src/components/documents/create/document-items-section.tsx +70 -39
- package/src/components/documents/create/document-recipient-section.tsx +10 -1
- package/src/components/documents/create/live-preview.tsx +113 -15
- package/src/components/documents/create/prepare-document-submission.ts +35 -16
- package/src/components/documents/create/use-document-customer-form.ts +14 -3
- package/src/components/documents/documents.hooks.ts +7 -2
- package/src/components/documents/shared/document-preview-display.tsx +136 -67
- package/src/components/documents/shared/scaled-document-preview.tsx +45 -5
- package/src/components/documents/view/document-actions-bar.tsx +284 -182
- package/src/components/documents/view/document-activities-list.tsx +3 -0
- package/src/components/documents/view/document-payments-list.tsx +3 -0
- package/src/components/documents/view/locales/de.ts +8 -0
- package/src/components/documents/view/locales/es.ts +8 -0
- package/src/components/documents/view/locales/fr.ts +8 -0
- package/src/components/documents/view/locales/hr.ts +8 -0
- package/src/components/documents/view/locales/it.ts +8 -0
- package/src/components/documents/view/locales/nl.ts +8 -0
- package/src/components/documents/view/locales/pl.ts +8 -0
- package/src/components/documents/view/locales/pt.ts +8 -0
- package/src/components/documents/view/locales/sl.ts +8 -0
- package/src/components/documents/view/use-document-download.ts +14 -25
- package/src/components/entities/create-entity-form.tsx +101 -16
- package/src/components/entities/fina-settings-form/fina-operator-required-dialog.tsx +3 -3
- package/src/components/entities/fina-settings-form/fina-settings-form.tsx +78 -124
- package/src/components/entities/fina-settings-form/sections/certificate-settings-section.tsx +8 -1
- package/src/components/entities/fina-settings-form/sections/premises-management-section.tsx +14 -2
- package/src/components/entities/fina-settings-form/sections/register-premise-dialog.tsx +7 -2
- package/src/components/entities/furs-settings-form/furs-settings-form.tsx +56 -130
- package/src/components/entities/furs-settings-form/sections/certificate-settings-section.tsx +8 -1
- package/src/components/entities/furs-settings-form/sections/enable-fiscalization-section.tsx +1 -0
- package/src/components/entities/furs-settings-form/sections/general-settings-section.tsx +15 -2
- package/src/components/entities/furs-settings-form/sections/premises-management-section.tsx +20 -3
- package/src/components/entities/furs-settings-form/sections/register-premise-dialog.tsx +38 -12
- package/src/components/entities/settings/eslog-settings-form.tsx +13 -1
- package/src/components/entities/settings/pdf-template-selector/demo-invoice-data.ts +3 -22
- package/src/components/entities/shared/fiscalization-step-flow.ts +77 -0
- package/src/components/entities/shared/fiscalization-step-tabs.tsx +71 -0
- package/src/components/estimates/create/create-estimate-form.tsx +34 -21
- package/src/components/estimates/list/list-table.tsx +23 -14
- package/src/components/estimates/list/locales/de.ts +2 -0
- package/src/components/estimates/list/locales/en.ts +1 -0
- package/src/components/estimates/list/locales/es.ts +1 -0
- package/src/components/estimates/list/locales/fr.ts +1 -0
- package/src/components/estimates/list/locales/hr.ts +1 -0
- package/src/components/estimates/list/locales/it.ts +1 -0
- package/src/components/estimates/list/locales/nl.ts +1 -0
- package/src/components/estimates/list/locales/pl.ts +1 -0
- package/src/components/estimates/list/locales/pt.ts +1 -0
- package/src/components/estimates/list/locales/sl.ts +1 -0
- package/src/components/estimates/list/use-estimate-download.ts +1 -12
- package/src/components/export/document-export-form.tsx +33 -7
- package/src/components/export/sales-per-item-export-form.tsx +23 -7
- package/src/components/invoices/create/create-invoice-form.tsx +295 -329
- package/src/components/invoices/create/prepare-invoice-submission.ts +0 -8
- package/src/components/invoices/list/list-table.tsx +7 -4
- package/src/components/invoices/list/use-invoice-download.ts +1 -11
- package/src/components/invoices/send-email-dialog/locales/de.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/es.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/fr.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/hr.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/it.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/nl.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/pl.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/pt.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/sl.ts +2 -0
- package/src/components/invoices/send-email-dialog/send-email-dialog.tsx +77 -8
- package/src/components/invoices/view/eslog-info-display.tsx +17 -1
- package/src/components/invoices/view/fiscalization-status-card.tsx +7 -3
- package/src/components/items/item-combobox.tsx +26 -6
- package/src/components/items/item-list-table/item-list-table.tsx +5 -2
- package/src/components/payments/list/list-table.tsx +14 -4
- package/src/components/recurring-invoices/list/list-table.tsx +7 -4
- package/src/components/request-logs/locales.ts +412 -0
- package/src/components/request-logs/request-log-detail.tsx +37 -21
- package/src/components/request-logs/request-log-list-table.tsx +57 -11
- package/src/components/table/data-table.tsx +5 -2
- package/src/components/table/date-cell.tsx +3 -1
- package/src/components/table/filter-bar.tsx +14 -2
- package/src/components/table/hooks/use-table-query.ts +1 -1
- package/src/components/table/locales.ts +1116 -0
- package/src/components/table/search-input.tsx +12 -3
- package/src/components/table/selection-toolbar.tsx +23 -6
- package/src/components/table/table-empty-state.tsx +43 -3
- package/src/components/table/table-no-results.tsx +3 -3
- package/src/components/table/table-pagination.tsx +4 -3
- package/src/components/table/types.ts +1 -0
- package/src/components/tax-reports/index.ts +1 -0
- package/src/components/tax-reports/kir-export-form.tsx +46 -8
- package/src/components/tax-reports/slovenia-tax-profile-step.tsx +191 -0
- package/src/components/tax-reports/slovenia-yearly-export-form.tsx +509 -0
- package/src/components/tax-reports/slovenia-yearly-review-step.tsx +253 -0
- package/src/components/tax-reports/slovenia-yearly-summary.tsx +19 -0
- package/src/components/taxes/tax-list-table/tax-list-table.tsx +3 -2
- package/src/components/ui/sticky-form-footer.tsx +7 -1
- package/src/components/webhook-logs/index.ts +6 -0
- package/src/components/webhook-logs/locales.ts +392 -0
- package/src/components/webhook-logs/webhook-delivery-detail.tsx +255 -0
- package/src/components/webhook-logs/webhook-delivery-list-table.tsx +278 -0
- package/src/components/wl-subscription/index.ts +1 -0
- package/src/components/wl-subscription/locked-feature.tsx +1 -0
- package/src/components/wl-subscription/paywall.tsx +193 -0
- package/src/components/wl-subscription/upgrade-modal.tsx +93 -29
- package/src/generate-schemas.ts +10 -5
- package/src/generated/schemas/customer.ts +2 -0
- package/src/generated/schemas/entity.ts +34 -0
- package/src/generated/schemas/me.ts +20 -1
- package/src/generated/schemas/renderadvanceinvoicepreview_body.ts +40 -34
- package/src/generated/schemas/rendercreditnotepreview_body.ts +42 -36
- package/src/generated/schemas/renderdeliverynotepreview_body.ts +23 -13
- package/src/generated/schemas/renderestimatepreview_body.ts +23 -13
- package/src/generated/schemas/renderinvoicepreview_body.ts +40 -34
- package/src/generated/schemas/sendemail_body.ts +44 -0
- package/src/generated/schemas/startpdfexport_body.ts +91 -1
- package/src/generated/schemas/webhook.ts +10 -0
- package/src/hooks/use-duplicate-document.ts +51 -13
- package/src/hooks/use-eslog-validation.ts +59 -0
- package/src/hooks/use-premise-selection.ts +186 -0
- package/src/lib/browser-cookies.ts +4 -4
- package/src/lib/date-fns-locale.ts +48 -0
- package/src/lib/fiscalization-options.ts +81 -0
- package/src/lib/locale.ts +38 -0
- package/src/lib/template-variables.tsx +1 -1
- package/src/lib/translation.ts +14 -3
- package/src/providers/entities-context.tsx +1 -0
- package/src/providers/entities-provider.tsx +102 -3
- package/src/providers/form-footer-context.tsx +37 -4
- package/src/providers/sdk-provider.tsx +7 -2
- package/src/providers/white-label-provider.tsx +4 -1
- package/src/providers/wl-subscription-provider.tsx +90 -3
|
@@ -54,14 +54,6 @@ export function prepareInvoiceSubmission(values: CreateInvoiceSchema, options: P
|
|
|
54
54
|
isDraft: options.isDraft,
|
|
55
55
|
}) as CreateInvoiceRequest;
|
|
56
56
|
|
|
57
|
-
// Add service date fields if provided
|
|
58
|
-
if ((values as any).date_service) {
|
|
59
|
-
(payload as any).date_service = new Date((values as any).date_service);
|
|
60
|
-
}
|
|
61
|
-
if ((values as any).date_service_to) {
|
|
62
|
-
(payload as any).date_service_to = new Date((values as any).date_service_to);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
57
|
// Add FURS data if provided
|
|
66
58
|
if (options.furs) {
|
|
67
59
|
if (options.furs.skip) {
|
|
@@ -4,6 +4,7 @@ import { useCallback, useMemo, useState } from "react";
|
|
|
4
4
|
import { DataTable } from "@/ui/components/table/data-table";
|
|
5
5
|
import { FormattedDate } from "@/ui/components/table/date-cell";
|
|
6
6
|
import { useTableFetch } from "@/ui/components/table/hooks/use-table-fetch";
|
|
7
|
+
import { withTableTranslations } from "@/ui/components/table/locales";
|
|
7
8
|
import { SelectionToolbar } from "@/ui/components/table/selection-toolbar";
|
|
8
9
|
import type {
|
|
9
10
|
Column,
|
|
@@ -31,7 +32,7 @@ import pl from "./locales/pl";
|
|
|
31
32
|
import pt from "./locales/pt";
|
|
32
33
|
import sl from "./locales/sl";
|
|
33
34
|
|
|
34
|
-
const translations = {
|
|
35
|
+
const translations = withTableTranslations({
|
|
35
36
|
en,
|
|
36
37
|
sl,
|
|
37
38
|
de,
|
|
@@ -42,12 +43,13 @@ const translations = {
|
|
|
42
43
|
nl,
|
|
43
44
|
pl,
|
|
44
45
|
hr,
|
|
45
|
-
} as const;
|
|
46
|
+
} as const);
|
|
46
47
|
|
|
47
48
|
type InvoiceListTableProps = {
|
|
48
49
|
t?: (key: string) => string;
|
|
49
50
|
namespace?: string;
|
|
50
51
|
locale?: string;
|
|
52
|
+
translationLocale?: string;
|
|
51
53
|
entityId?: string;
|
|
52
54
|
onView?: (invoice: Invoice) => void;
|
|
53
55
|
onAddPayment?: (invoice: Invoice) => void;
|
|
@@ -85,6 +87,7 @@ export default function InvoiceListTable({
|
|
|
85
87
|
}: InvoiceListTableProps) {
|
|
86
88
|
const t = createTranslation({
|
|
87
89
|
translations,
|
|
90
|
+
locale: i18nProps.translationLocale ?? i18nProps.locale,
|
|
88
91
|
...i18nProps,
|
|
89
92
|
});
|
|
90
93
|
|
|
@@ -210,12 +213,12 @@ export default function InvoiceListTable({
|
|
|
210
213
|
{
|
|
211
214
|
id: "date",
|
|
212
215
|
header: t("Date"),
|
|
213
|
-
cell: (invoice) => <FormattedDate date={invoice.date} />,
|
|
216
|
+
cell: (invoice) => <FormattedDate date={invoice.date} locale={i18nProps.locale} />,
|
|
214
217
|
},
|
|
215
218
|
{
|
|
216
219
|
id: "date_due",
|
|
217
220
|
header: t("Date Due"),
|
|
218
|
-
cell: (invoice) => <FormattedDate date={invoice.date_due} />,
|
|
221
|
+
cell: (invoice) => <FormattedDate date={invoice.date_due} locale={i18nProps.locale} />,
|
|
219
222
|
},
|
|
220
223
|
{
|
|
221
224
|
id: "total",
|
|
@@ -33,18 +33,8 @@ export function useInvoiceDownload({
|
|
|
33
33
|
onDownloadStart?.();
|
|
34
34
|
|
|
35
35
|
try {
|
|
36
|
-
// SDK signature: renderPdf(id, params?, SDKMethodOptions?)
|
|
37
|
-
// entity_id goes in SDKMethodOptions (last arg), not params
|
|
38
|
-
const blob = await sdk.invoices.renderPdf(invoice.id, {}, { entity_id: activeEntity.id });
|
|
39
|
-
const downloadUrl = window.URL.createObjectURL(blob);
|
|
40
|
-
const link = document.createElement("a");
|
|
41
|
-
link.href = downloadUrl;
|
|
42
36
|
const fileName = `${t("Invoice")} ${invoice.number}.pdf`;
|
|
43
|
-
|
|
44
|
-
document.body.appendChild(link);
|
|
45
|
-
link.click();
|
|
46
|
-
document.body.removeChild(link);
|
|
47
|
-
window.URL.revokeObjectURL(downloadUrl);
|
|
37
|
+
await sdk.invoices.downloadPdf(invoice.id, fileName, {}, { entity_id: activeEntity.id });
|
|
48
38
|
|
|
49
39
|
onDownloadSuccess?.(fileName);
|
|
50
40
|
} catch (error) {
|
|
@@ -15,4 +15,6 @@ export default {
|
|
|
15
15
|
"Failed to send email": "E-Mail konnte nicht gesendet werden",
|
|
16
16
|
"Sandbox email warning":
|
|
17
17
|
"Im Sandbox-Modus können E-Mails nur an verifizierte Teammitglieder dieses Kontos gesendet werden.",
|
|
18
|
+
"PDF Language": "PDF-Sprache",
|
|
19
|
+
Default: "Standard",
|
|
18
20
|
} as const;
|
|
@@ -15,4 +15,6 @@ export default {
|
|
|
15
15
|
"Failed to send email": "Error al enviar el correo",
|
|
16
16
|
"Sandbox email warning":
|
|
17
17
|
"En modo sandbox solo se pueden enviar correos a los miembros verificados del equipo de esta cuenta.",
|
|
18
|
+
"PDF Language": "Idioma del PDF",
|
|
19
|
+
Default: "Predeterminado",
|
|
18
20
|
} as const;
|
|
@@ -15,4 +15,6 @@ export default {
|
|
|
15
15
|
"Failed to send email": "Échec de l'envoi de l'e-mail",
|
|
16
16
|
"Sandbox email warning":
|
|
17
17
|
"En mode sandbox, les e-mails ne peuvent être envoyés qu'aux membres vérifiés de l'équipe de ce compte.",
|
|
18
|
+
"PDF Language": "Langue du PDF",
|
|
19
|
+
Default: "Par défaut",
|
|
18
20
|
} as const;
|
|
@@ -14,4 +14,6 @@ export default {
|
|
|
14
14
|
"Invoice sent to": "Račun poslan na",
|
|
15
15
|
"Failed to send email": "Slanje e-maila nije uspjelo",
|
|
16
16
|
"Sandbox email warning": "U sandbox načinu e-mailovi se mogu slati samo verificiranim članovima tima ovog računa.",
|
|
17
|
+
"PDF Language": "Jezik PDF-a",
|
|
18
|
+
Default: "Zadano",
|
|
17
19
|
} as const;
|
|
@@ -15,4 +15,6 @@ export default {
|
|
|
15
15
|
"Failed to send email": "Invio dell'e-mail non riuscito",
|
|
16
16
|
"Sandbox email warning":
|
|
17
17
|
"In modalità sandbox è possibile inviare e-mail solo ai membri del team verificati di questo account.",
|
|
18
|
+
"PDF Language": "Lingua del PDF",
|
|
19
|
+
Default: "Predefinito",
|
|
18
20
|
} as const;
|
|
@@ -15,4 +15,6 @@ export default {
|
|
|
15
15
|
"Failed to send email": "E-mail verzenden mislukt",
|
|
16
16
|
"Sandbox email warning":
|
|
17
17
|
"In sandbox-modus kunnen e-mails alleen worden verzonden naar geverifieerde teamleden van dit account.",
|
|
18
|
+
"PDF Language": "PDF-taal",
|
|
19
|
+
Default: "Standaard",
|
|
18
20
|
} as const;
|
|
@@ -15,4 +15,6 @@ export default {
|
|
|
15
15
|
"Failed to send email": "Nie udało się wysłać e-maila",
|
|
16
16
|
"Sandbox email warning":
|
|
17
17
|
"W trybie sandbox e-maile można wysyłać tylko do zweryfikowanych członków zespołu tego konta.",
|
|
18
|
+
"PDF Language": "Język PDF",
|
|
19
|
+
Default: "Domyślnie",
|
|
18
20
|
} as const;
|
|
@@ -15,4 +15,6 @@ export default {
|
|
|
15
15
|
"Failed to send email": "Falha ao enviar o e-mail",
|
|
16
16
|
"Sandbox email warning":
|
|
17
17
|
"No modo sandbox, os e-mails só podem ser enviados para membros verificados da equipa desta conta.",
|
|
18
|
+
"PDF Language": "Idioma do PDF",
|
|
19
|
+
Default: "Padrão",
|
|
18
20
|
} as const;
|
|
@@ -14,4 +14,6 @@ export default {
|
|
|
14
14
|
"Invoice sent to": "Račun poslan na",
|
|
15
15
|
"Failed to send email": "Pošiljanje e-pošte ni uspelo",
|
|
16
16
|
"Sandbox email warning": "V testnem načinu lahko pošiljate e-pošto samo verificiranim članom ekipe tega računa.",
|
|
17
|
+
"PDF Language": "Jezik PDF-ja",
|
|
18
|
+
Default: "Privzeto",
|
|
17
19
|
} as const;
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
FormMessage,
|
|
27
27
|
} from "@/ui/components/ui/form";
|
|
28
28
|
import { Input } from "@/ui/components/ui/input";
|
|
29
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/ui/components/ui/select";
|
|
29
30
|
import { Spinner } from "@/ui/components/ui/spinner";
|
|
30
31
|
import { type SendEmailSchema, sendEmailSchema } from "@/ui/generated/schemas";
|
|
31
32
|
import type { ComponentTranslationProps } from "@/ui/lib/translation";
|
|
@@ -44,6 +45,29 @@ import sl from "./locales/sl";
|
|
|
44
45
|
|
|
45
46
|
const translations = { de, sl, it, fr, es, pt, nl, pl, hr } as const;
|
|
46
47
|
|
|
48
|
+
const LOCALE_OPTIONS = [
|
|
49
|
+
{ value: "en-US", label: "English (US)" },
|
|
50
|
+
{ value: "de-DE", label: "Deutsch" },
|
|
51
|
+
{ value: "it-IT", label: "Italiano" },
|
|
52
|
+
{ value: "fr-FR", label: "Français" },
|
|
53
|
+
{ value: "es-ES", label: "Español" },
|
|
54
|
+
{ value: "sl-SI", label: "Slovenščina" },
|
|
55
|
+
{ value: "pt-PT", label: "Português" },
|
|
56
|
+
{ value: "nl-NL", label: "Nederlands" },
|
|
57
|
+
{ value: "pl-PL", label: "Polski" },
|
|
58
|
+
{ value: "hr-HR", label: "Hrvatski" },
|
|
59
|
+
{ value: "sv-SE", label: "Svenska" },
|
|
60
|
+
{ value: "fi-FI", label: "Suomi" },
|
|
61
|
+
{ value: "et-EE", label: "Eesti" },
|
|
62
|
+
{ value: "bg-BG", label: "Български" },
|
|
63
|
+
{ value: "cs-CZ", label: "Čeština" },
|
|
64
|
+
{ value: "sk-SK", label: "Slovenčina" },
|
|
65
|
+
{ value: "nb-NO", label: "Norsk bokmål" },
|
|
66
|
+
{ value: "is-IS", label: "Íslenska" },
|
|
67
|
+
] as const;
|
|
68
|
+
|
|
69
|
+
const DEFAULT_LANGUAGE_VALUE = "__default__";
|
|
70
|
+
|
|
47
71
|
type SendEmailDialogProps = {
|
|
48
72
|
invoice: Invoice;
|
|
49
73
|
defaultEmail?: string;
|
|
@@ -87,12 +111,14 @@ export function SendEmailDialog({
|
|
|
87
111
|
// biome-ignore lint/suspicious/noEmptyBlockStatements: noop fallback for controlled mode
|
|
88
112
|
const setOpen = isControlled ? onOpenChange || (() => {}) : setInternalOpen;
|
|
89
113
|
const [isLoading, setIsLoading] = useState(false);
|
|
114
|
+
const [language, setLanguage] = useState<string>("");
|
|
90
115
|
const { sdk } = useSDK();
|
|
91
116
|
const { activeEntity } = useEntities();
|
|
92
117
|
|
|
93
118
|
// Get entity email defaults if not provided
|
|
94
119
|
const entitySettings = (activeEntity?.settings as Record<string, any>) || {};
|
|
95
120
|
const emailDefaults = entitySettings.email_defaults || {};
|
|
121
|
+
const entityLocale = (activeEntity as any)?.locale || "en-US";
|
|
96
122
|
|
|
97
123
|
const finalSubject = defaultSubject || emailDefaults.invoice_subject || `Invoice #${invoice.number}`;
|
|
98
124
|
const finalBody =
|
|
@@ -107,18 +133,26 @@ export function SendEmailDialog({
|
|
|
107
133
|
attach_pdf: false,
|
|
108
134
|
},
|
|
109
135
|
});
|
|
136
|
+
const { control, handleSubmit, reset, setValue } = form;
|
|
137
|
+
const handleLanguageChange = (value: string | null) => {
|
|
138
|
+
setLanguage(value ?? DEFAULT_LANGUAGE_VALUE);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const entityLocaleLabel = LOCALE_OPTIONS.find((option) => option.value === entityLocale)?.label ?? entityLocale;
|
|
142
|
+
const defaultLanguageLabel = `${t("Default")} (${entityLocaleLabel})`;
|
|
110
143
|
|
|
111
144
|
// Reset form and fetch customer email when dialog opens
|
|
112
145
|
useEffect(() => {
|
|
113
146
|
if (!open) return;
|
|
114
147
|
|
|
115
148
|
// Reset form to defaults when dialog opens
|
|
116
|
-
|
|
149
|
+
reset({
|
|
117
150
|
to: defaultEmail,
|
|
118
151
|
subject: finalSubject,
|
|
119
152
|
body_text: finalBody,
|
|
120
153
|
attach_pdf: false,
|
|
121
154
|
});
|
|
155
|
+
setLanguage(DEFAULT_LANGUAGE_VALUE);
|
|
122
156
|
|
|
123
157
|
// Fetch customer email from linked customer if not in invoice snapshot
|
|
124
158
|
const fetchCustomerEmail = async () => {
|
|
@@ -135,7 +169,7 @@ export function SendEmailDialog({
|
|
|
135
169
|
|
|
136
170
|
const customer = response.data[0];
|
|
137
171
|
if (customer?.email) {
|
|
138
|
-
|
|
172
|
+
setValue("to", customer.email);
|
|
139
173
|
}
|
|
140
174
|
} catch {
|
|
141
175
|
// Silently fail - customer might not exist or not have email
|
|
@@ -143,7 +177,18 @@ export function SendEmailDialog({
|
|
|
143
177
|
};
|
|
144
178
|
|
|
145
179
|
fetchCustomerEmail();
|
|
146
|
-
}, [
|
|
180
|
+
}, [
|
|
181
|
+
open,
|
|
182
|
+
defaultEmail,
|
|
183
|
+
invoice.customer_id,
|
|
184
|
+
sdk,
|
|
185
|
+
activeEntity?.id,
|
|
186
|
+
reset,
|
|
187
|
+
setValue,
|
|
188
|
+
finalSubject,
|
|
189
|
+
finalBody,
|
|
190
|
+
entityLocale,
|
|
191
|
+
]);
|
|
147
192
|
|
|
148
193
|
const onSubmit = async (values: SendEmailSchema) => {
|
|
149
194
|
setIsLoading(true);
|
|
@@ -153,6 +198,9 @@ export function SendEmailDialog({
|
|
|
153
198
|
// Ensure we have an active entity
|
|
154
199
|
if (!activeEntity?.id) throw new Error("Entity context required");
|
|
155
200
|
|
|
201
|
+
const localeOverride =
|
|
202
|
+
language && language !== DEFAULT_LANGUAGE_VALUE && language !== entityLocale ? language : undefined;
|
|
203
|
+
|
|
156
204
|
// Call the email API endpoint using SDK
|
|
157
205
|
await (sdk.email as any).send(
|
|
158
206
|
{
|
|
@@ -160,6 +208,8 @@ export function SendEmailDialog({
|
|
|
160
208
|
subject: values.subject,
|
|
161
209
|
body_text: values.body_text,
|
|
162
210
|
document_id: invoice.id,
|
|
211
|
+
locale: localeOverride,
|
|
212
|
+
language: localeOverride,
|
|
163
213
|
},
|
|
164
214
|
{ entity_id: activeEntity.id },
|
|
165
215
|
);
|
|
@@ -169,7 +219,7 @@ export function SendEmailDialog({
|
|
|
169
219
|
});
|
|
170
220
|
|
|
171
221
|
setOpen(false);
|
|
172
|
-
|
|
222
|
+
reset();
|
|
173
223
|
onSuccess?.();
|
|
174
224
|
} catch (error) {
|
|
175
225
|
const errorMessage = error instanceof Error ? error.message : t("Failed to send email");
|
|
@@ -213,9 +263,9 @@ export function SendEmailDialog({
|
|
|
213
263
|
)}
|
|
214
264
|
|
|
215
265
|
<Form {...form}>
|
|
216
|
-
<form onSubmit={
|
|
266
|
+
<form onSubmit={handleSubmit(onSubmit)} className="space-y-4">
|
|
217
267
|
<FormField
|
|
218
|
-
control={
|
|
268
|
+
control={control}
|
|
219
269
|
name="to"
|
|
220
270
|
render={({ field }) => (
|
|
221
271
|
<FormItem>
|
|
@@ -228,8 +278,27 @@ export function SendEmailDialog({
|
|
|
228
278
|
)}
|
|
229
279
|
/>
|
|
230
280
|
|
|
281
|
+
<div className="space-y-2">
|
|
282
|
+
<label htmlFor="pdf-language" className="font-medium text-sm leading-none">
|
|
283
|
+
{t("PDF Language")}
|
|
284
|
+
</label>
|
|
285
|
+
<Select value={language} onValueChange={handleLanguageChange}>
|
|
286
|
+
<SelectTrigger id="pdf-language">
|
|
287
|
+
<SelectValue />
|
|
288
|
+
</SelectTrigger>
|
|
289
|
+
<SelectContent>
|
|
290
|
+
<SelectItem value={DEFAULT_LANGUAGE_VALUE}>{defaultLanguageLabel}</SelectItem>
|
|
291
|
+
{LOCALE_OPTIONS.map((opt) => (
|
|
292
|
+
<SelectItem key={opt.value} value={opt.value}>
|
|
293
|
+
{opt.label}
|
|
294
|
+
</SelectItem>
|
|
295
|
+
))}
|
|
296
|
+
</SelectContent>
|
|
297
|
+
</Select>
|
|
298
|
+
</div>
|
|
299
|
+
|
|
231
300
|
<FormField
|
|
232
|
-
control={
|
|
301
|
+
control={control}
|
|
233
302
|
name="subject"
|
|
234
303
|
render={({ field }) => (
|
|
235
304
|
<FormItem>
|
|
@@ -252,7 +321,7 @@ export function SendEmailDialog({
|
|
|
252
321
|
/>
|
|
253
322
|
|
|
254
323
|
<FormField
|
|
255
|
-
control={
|
|
324
|
+
control={control}
|
|
256
325
|
name="body_text"
|
|
257
326
|
render={({ field }) => (
|
|
258
327
|
<FormItem>
|
|
@@ -7,6 +7,22 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/ui/
|
|
|
7
7
|
import type { ComponentTranslationProps } from "@/ui/lib/translation";
|
|
8
8
|
import { createTranslation } from "@/ui/lib/translation";
|
|
9
9
|
|
|
10
|
+
const translations = {
|
|
11
|
+
en: {
|
|
12
|
+
Valid: "Valid",
|
|
13
|
+
Invalid: "Invalid",
|
|
14
|
+
"Not validated": "Not validated",
|
|
15
|
+
"e-SLOG 2.0": "e-SLOG 2.0",
|
|
16
|
+
"Slovenian electronic invoice format (EN 16931)": "Slovenian electronic invoice format (EN 16931)",
|
|
17
|
+
"Validation Errors": "Validation Errors",
|
|
18
|
+
"Downloading...": "Downloading...",
|
|
19
|
+
"Download e-SLOG XML": "Download e-SLOG XML",
|
|
20
|
+
"This document has not been validated for e-SLOG. Enable validation in entity settings or on the document to validate.":
|
|
21
|
+
"This document has not been validated for e-SLOG. Enable validation in entity settings or on the document to validate.",
|
|
22
|
+
"Validated at": "Validated at",
|
|
23
|
+
},
|
|
24
|
+
} as const;
|
|
25
|
+
|
|
10
26
|
// Type for eslog data
|
|
11
27
|
interface EslogData {
|
|
12
28
|
validation_enabled?: boolean | null;
|
|
@@ -46,7 +62,7 @@ export function EslogInfoDisplay({
|
|
|
46
62
|
t: translateFn,
|
|
47
63
|
namespace,
|
|
48
64
|
locale,
|
|
49
|
-
translations
|
|
65
|
+
translations,
|
|
50
66
|
});
|
|
51
67
|
|
|
52
68
|
// Cast eslog to the proper type
|
|
@@ -58,7 +58,11 @@ export function FiscalizationStatusCard({
|
|
|
58
58
|
switch (fiscalizationData.status) {
|
|
59
59
|
case "success":
|
|
60
60
|
return (
|
|
61
|
-
<Badge
|
|
61
|
+
<Badge
|
|
62
|
+
className="bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100"
|
|
63
|
+
data-testid={`${fiscalizationType}-fiscalization-status-badge`}
|
|
64
|
+
data-status="success"
|
|
65
|
+
>
|
|
62
66
|
<CheckCircle2 className="mr-1 h-3 w-3" />
|
|
63
67
|
{t("Fiscalized")}
|
|
64
68
|
</Badge>
|
|
@@ -120,7 +124,7 @@ export function FiscalizationStatusCard({
|
|
|
120
124
|
|
|
121
125
|
if (variant === "inline") {
|
|
122
126
|
return (
|
|
123
|
-
<div className="space-y-3">
|
|
127
|
+
<div className="space-y-3" data-testid={`${fiscalizationType}-fiscalization-status-card`}>
|
|
124
128
|
<div className="flex items-center justify-between font-medium text-sm">
|
|
125
129
|
<span>{t("Fiscalization")}</span>
|
|
126
130
|
{getStatusBadge()}
|
|
@@ -131,7 +135,7 @@ export function FiscalizationStatusCard({
|
|
|
131
135
|
}
|
|
132
136
|
|
|
133
137
|
return (
|
|
134
|
-
<Card>
|
|
138
|
+
<Card data-testid={`${fiscalizationType}-fiscalization-status-card`}>
|
|
135
139
|
<CardHeader className="pb-3">
|
|
136
140
|
<CardTitle className="flex items-center justify-between text-lg">
|
|
137
141
|
<span>{t("Fiscalization")}</span>
|
|
@@ -12,9 +12,13 @@ type ItemComboboxProps = {
|
|
|
12
12
|
entityId: string;
|
|
13
13
|
value?: string;
|
|
14
14
|
onSelect?: (item: Item | null, customName?: string) => void;
|
|
15
|
+
onCommitInlineName?: (value: string) => void;
|
|
16
|
+
commitOnBlurMode?: "create" | "update-inline";
|
|
15
17
|
placeholder?: string;
|
|
16
18
|
className?: string;
|
|
17
19
|
disabled?: boolean;
|
|
20
|
+
locale?: string;
|
|
21
|
+
inputTestId?: string;
|
|
18
22
|
};
|
|
19
23
|
|
|
20
24
|
/**
|
|
@@ -25,9 +29,13 @@ export function ItemCombobox({
|
|
|
25
29
|
entityId,
|
|
26
30
|
value,
|
|
27
31
|
onSelect,
|
|
32
|
+
onCommitInlineName,
|
|
33
|
+
commitOnBlurMode = "create",
|
|
28
34
|
placeholder = "Search or enter item name...",
|
|
29
35
|
className,
|
|
30
36
|
disabled,
|
|
37
|
+
locale,
|
|
38
|
+
inputTestId,
|
|
31
39
|
}: ItemComboboxProps) {
|
|
32
40
|
const [search, setSearch] = useState("");
|
|
33
41
|
const [displayValue, setDisplayValue] = useState(value || "");
|
|
@@ -53,7 +61,7 @@ export function ItemCombobox({
|
|
|
53
61
|
const formatPrice = (item: Item) => {
|
|
54
62
|
const price = item.gross_price ?? item.price;
|
|
55
63
|
if (price === null || price === undefined) return "";
|
|
56
|
-
return ` - ${
|
|
64
|
+
return ` - ${new Intl.NumberFormat(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(price)}`;
|
|
57
65
|
};
|
|
58
66
|
|
|
59
67
|
const options = items.map((item) => ({
|
|
@@ -113,11 +121,20 @@ export function ItemCombobox({
|
|
|
113
121
|
}
|
|
114
122
|
};
|
|
115
123
|
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
if (!
|
|
119
|
-
|
|
124
|
+
const commitCustomName = (customName: string) => {
|
|
125
|
+
const trimmedName = customName.trim();
|
|
126
|
+
if (!trimmedName) return;
|
|
127
|
+
|
|
128
|
+
if (commitOnBlurMode === "update-inline") {
|
|
129
|
+
onCommitInlineName?.(trimmedName);
|
|
130
|
+
setSearch(trimmedName);
|
|
131
|
+
setDisplayValue(trimmedName);
|
|
132
|
+
return;
|
|
120
133
|
}
|
|
134
|
+
|
|
135
|
+
onSelect?.(null, trimmedName);
|
|
136
|
+
setSearch(trimmedName);
|
|
137
|
+
setDisplayValue(trimmedName);
|
|
121
138
|
};
|
|
122
139
|
|
|
123
140
|
// Sync when value changes externally (e.g., duplication, form reset)
|
|
@@ -136,7 +153,8 @@ export function ItemCombobox({
|
|
|
136
153
|
onSearch={handleSearch}
|
|
137
154
|
value={value}
|
|
138
155
|
onValueChange={handleValueChange}
|
|
139
|
-
|
|
156
|
+
onCommitUnselectedInput={commitCustomName}
|
|
157
|
+
commitUnselectedOnBlur={true}
|
|
140
158
|
options={options}
|
|
141
159
|
placeholder={placeholder}
|
|
142
160
|
className={className}
|
|
@@ -144,6 +162,8 @@ export function ItemCombobox({
|
|
|
144
162
|
loading={isLoading}
|
|
145
163
|
emptyText={debouncedSearch ? "No items found" : "Recent items"}
|
|
146
164
|
displayValue={displayValue}
|
|
165
|
+
inputTestId={inputTestId}
|
|
166
|
+
committedDisplayValue={value}
|
|
147
167
|
/>
|
|
148
168
|
);
|
|
149
169
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Item } from "@spaceinvoices/js-sdk";
|
|
2
2
|
|
|
3
|
+
import { withTableTranslations } from "../../table/locales";
|
|
3
4
|
import { createTranslation } from "@/ui/lib/translation";
|
|
4
5
|
import { useSDK } from "@/ui/providers/sdk-provider";
|
|
5
6
|
import { DataTable } from "../../table/data-table";
|
|
@@ -19,7 +20,7 @@ import pl from "./locales/pl";
|
|
|
19
20
|
import pt from "./locales/pt";
|
|
20
21
|
import sl from "./locales/sl";
|
|
21
22
|
|
|
22
|
-
const translations = {
|
|
23
|
+
const translations = withTableTranslations({
|
|
23
24
|
en,
|
|
24
25
|
sl,
|
|
25
26
|
de,
|
|
@@ -30,12 +31,13 @@ const translations = {
|
|
|
30
31
|
nl,
|
|
31
32
|
pl,
|
|
32
33
|
hr,
|
|
33
|
-
} as const;
|
|
34
|
+
} as const);
|
|
34
35
|
|
|
35
36
|
type ItemListTableProps = {
|
|
36
37
|
t?: (key: string) => string;
|
|
37
38
|
namespace?: string;
|
|
38
39
|
locale?: string;
|
|
40
|
+
translationLocale?: string;
|
|
39
41
|
entityId?: string;
|
|
40
42
|
onView?: (item: Item) => void;
|
|
41
43
|
} & ListTableProps<Item>;
|
|
@@ -51,6 +53,7 @@ export default function ItemListTable({
|
|
|
51
53
|
}: ItemListTableProps) {
|
|
52
54
|
const t = createTranslation({
|
|
53
55
|
translations,
|
|
56
|
+
locale: i18nProps.translationLocale ?? i18nProps.locale,
|
|
54
57
|
...i18nProps,
|
|
55
58
|
});
|
|
56
59
|
const { sdk } = useSDK();
|
|
@@ -4,6 +4,7 @@ import { useMemo } from "react";
|
|
|
4
4
|
import { DataTable } from "@/ui/components/table/data-table";
|
|
5
5
|
import { FormattedDate } from "@/ui/components/table/date-cell";
|
|
6
6
|
import { useTableFetch } from "@/ui/components/table/hooks/use-table-fetch";
|
|
7
|
+
import { withTableTranslations } from "@/ui/components/table/locales";
|
|
7
8
|
import type { Column, ListTableProps, TableQueryParams, TableQueryResponse } from "@/ui/components/table/types";
|
|
8
9
|
import { Button } from "@/ui/components/ui/button";
|
|
9
10
|
import { Popover, PopoverContent, PopoverTrigger } from "@/ui/components/ui/popover";
|
|
@@ -22,7 +23,7 @@ import pl from "./locales/pl";
|
|
|
22
23
|
import pt from "./locales/pt";
|
|
23
24
|
import sl from "./locales/sl";
|
|
24
25
|
|
|
25
|
-
const translations = {
|
|
26
|
+
const translations = withTableTranslations({
|
|
26
27
|
en,
|
|
27
28
|
sl,
|
|
28
29
|
de,
|
|
@@ -33,7 +34,7 @@ const translations = {
|
|
|
33
34
|
nl,
|
|
34
35
|
pl,
|
|
35
36
|
hr,
|
|
36
|
-
} as const;
|
|
37
|
+
} as const);
|
|
37
38
|
|
|
38
39
|
// Extended payment type that includes Invoice relation from API
|
|
39
40
|
type PaymentWithInvoice = Payment & {
|
|
@@ -44,6 +45,7 @@ type PaymentListTableProps = {
|
|
|
44
45
|
t?: (key: string) => string;
|
|
45
46
|
namespace?: string;
|
|
46
47
|
locale?: string;
|
|
48
|
+
translationLocale?: string;
|
|
47
49
|
entityId?: string;
|
|
48
50
|
onViewInvoice?: (invoiceId: string) => void;
|
|
49
51
|
onEditPayment?: (payment: Payment) => void;
|
|
@@ -63,6 +65,7 @@ export default function PaymentListTable({
|
|
|
63
65
|
}: PaymentListTableProps) {
|
|
64
66
|
const t = createTranslation({
|
|
65
67
|
translations,
|
|
68
|
+
locale: i18nProps.translationLocale ?? i18nProps.locale,
|
|
66
69
|
...i18nProps,
|
|
67
70
|
});
|
|
68
71
|
|
|
@@ -99,13 +102,20 @@ export default function PaymentListTable({
|
|
|
99
102
|
{
|
|
100
103
|
id: "date",
|
|
101
104
|
header: t("Date"),
|
|
102
|
-
cell: (payment) => <FormattedDate date={payment.date} />,
|
|
105
|
+
cell: (payment) => <FormattedDate date={payment.date} locale={i18nProps.locale} />,
|
|
103
106
|
},
|
|
104
107
|
{
|
|
105
108
|
id: "amount",
|
|
106
109
|
header: t("Amount"),
|
|
107
110
|
align: "right",
|
|
108
|
-
cell: (payment) =>
|
|
111
|
+
cell: (payment) => (
|
|
112
|
+
<span className="font-medium">
|
|
113
|
+
{new Intl.NumberFormat(i18nProps.locale, {
|
|
114
|
+
minimumFractionDigits: 2,
|
|
115
|
+
maximumFractionDigits: 2,
|
|
116
|
+
}).format(payment.amount)}
|
|
117
|
+
</span>
|
|
118
|
+
),
|
|
109
119
|
},
|
|
110
120
|
{
|
|
111
121
|
id: "type",
|
|
@@ -3,6 +3,7 @@ import { useMemo } from "react";
|
|
|
3
3
|
import { DataTable } from "@/ui/components/table/data-table";
|
|
4
4
|
import { FormattedDate } from "@/ui/components/table/date-cell";
|
|
5
5
|
import { useTableFetch } from "@/ui/components/table/hooks/use-table-fetch";
|
|
6
|
+
import { withTableTranslations } from "@/ui/components/table/locales";
|
|
6
7
|
import type { Column, ListTableProps, TableQueryParams, TableQueryResponse } from "@/ui/components/table/types";
|
|
7
8
|
import { Badge } from "@/ui/components/ui/badge";
|
|
8
9
|
import { createTranslation } from "@/ui/lib/translation";
|
|
@@ -20,7 +21,7 @@ import pl from "./locales/pl";
|
|
|
20
21
|
import pt from "./locales/pt";
|
|
21
22
|
import sl from "./locales/sl";
|
|
22
23
|
|
|
23
|
-
const translations = {
|
|
24
|
+
const translations = withTableTranslations({
|
|
24
25
|
en,
|
|
25
26
|
sl,
|
|
26
27
|
de,
|
|
@@ -31,7 +32,7 @@ const translations = {
|
|
|
31
32
|
nl,
|
|
32
33
|
pl,
|
|
33
34
|
hr,
|
|
34
|
-
} as const;
|
|
35
|
+
} as const);
|
|
35
36
|
|
|
36
37
|
function statusVariant(status: string): "default" | "secondary" | "outline" {
|
|
37
38
|
switch (status) {
|
|
@@ -48,6 +49,7 @@ type RecurringInvoiceListTableProps = {
|
|
|
48
49
|
t?: (key: string) => string;
|
|
49
50
|
namespace?: string;
|
|
50
51
|
locale?: string;
|
|
52
|
+
translationLocale?: string;
|
|
51
53
|
entityId?: string;
|
|
52
54
|
onViewSourceInvoice?: (documentId: string) => void;
|
|
53
55
|
onDeleteSuccess?: () => void;
|
|
@@ -65,6 +67,7 @@ export default function RecurringInvoiceListTable({
|
|
|
65
67
|
}: RecurringInvoiceListTableProps) {
|
|
66
68
|
const t = createTranslation({
|
|
67
69
|
translations,
|
|
70
|
+
locale: i18nProps.translationLocale ?? i18nProps.locale,
|
|
68
71
|
...i18nProps,
|
|
69
72
|
});
|
|
70
73
|
|
|
@@ -120,7 +123,7 @@ export default function RecurringInvoiceListTable({
|
|
|
120
123
|
header: t("Next Run"),
|
|
121
124
|
cell: (ri) =>
|
|
122
125
|
ri.next_run_date ? (
|
|
123
|
-
<FormattedDate date={ri.next_run_date} />
|
|
126
|
+
<FormattedDate date={ri.next_run_date} locale={i18nProps.locale} />
|
|
124
127
|
) : (
|
|
125
128
|
<span className="text-muted-foreground">-</span>
|
|
126
129
|
),
|
|
@@ -134,7 +137,7 @@ export default function RecurringInvoiceListTable({
|
|
|
134
137
|
{
|
|
135
138
|
id: "created_at",
|
|
136
139
|
header: t("Created"),
|
|
137
|
-
cell: (ri) => <FormattedDate date={ri.created_at} />,
|
|
140
|
+
cell: (ri) => <FormattedDate date={ri.created_at} locale={i18nProps.locale} />,
|
|
138
141
|
},
|
|
139
142
|
{
|
|
140
143
|
id: "actions",
|