@spaceinvoices/react-ui 0.4.1 → 0.4.2
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 +25 -0
- package/src/components/advance-invoices/advance-invoices.hooks.ts +32 -2
- package/src/components/advance-invoices/create/create-advance-invoice-form.tsx +109 -4
- package/src/components/advance-invoices/create/locales/de.ts +2 -0
- package/src/components/advance-invoices/create/locales/es.ts +2 -0
- package/src/components/advance-invoices/create/locales/fr.ts +2 -0
- package/src/components/advance-invoices/create/locales/hr.ts +2 -0
- package/src/components/advance-invoices/create/locales/it.ts +2 -0
- package/src/components/advance-invoices/create/locales/nl.ts +2 -0
- package/src/components/advance-invoices/create/locales/pl.ts +2 -0
- package/src/components/advance-invoices/create/locales/pt.ts +2 -0
- package/src/components/advance-invoices/create/locales/sl.ts +2 -0
- package/src/components/advance-invoices/create/prepare-advance-invoice-submission.ts +17 -0
- package/src/components/advance-invoices/list/list-row-actions.tsx +3 -6
- package/src/components/advance-invoices/list/list-table.tsx +45 -2
- package/src/components/advance-invoices/list/locales/de.ts +3 -0
- package/src/components/advance-invoices/list/locales/en.ts +3 -0
- package/src/components/advance-invoices/list/locales/es.ts +3 -0
- package/src/components/advance-invoices/list/locales/fr.ts +3 -0
- package/src/components/advance-invoices/list/locales/hr.ts +3 -0
- package/src/components/advance-invoices/list/locales/it.ts +3 -0
- package/src/components/advance-invoices/list/locales/nl.ts +3 -0
- package/src/components/advance-invoices/list/locales/pl.ts +3 -0
- package/src/components/advance-invoices/list/locales/pt.ts +3 -0
- package/src/components/advance-invoices/list/locales/sl.ts +3 -0
- package/src/components/credit-notes/create/create-credit-note-form.tsx +177 -6
- package/src/components/credit-notes/create/locales/de.ts +8 -0
- package/src/components/credit-notes/create/locales/es.ts +8 -0
- package/src/components/credit-notes/create/locales/fr.ts +7 -0
- package/src/components/credit-notes/create/locales/hr.ts +7 -0
- package/src/components/credit-notes/create/locales/it.ts +9 -0
- package/src/components/credit-notes/create/locales/nl.ts +7 -0
- package/src/components/credit-notes/create/locales/pl.ts +7 -0
- package/src/components/credit-notes/create/locales/pt.ts +7 -0
- package/src/components/credit-notes/create/locales/sl.ts +7 -0
- package/src/components/credit-notes/credit-notes.hooks.ts +30 -0
- package/src/components/credit-notes/list/list-row-actions.tsx +3 -6
- package/src/components/credit-notes/list/list-table.tsx +45 -2
- package/src/components/credit-notes/list/locales/de.ts +3 -0
- package/src/components/credit-notes/list/locales/en.ts +3 -0
- package/src/components/credit-notes/list/locales/es.ts +3 -0
- package/src/components/credit-notes/list/locales/fr.ts +3 -0
- package/src/components/credit-notes/list/locales/hr.ts +3 -0
- package/src/components/credit-notes/list/locales/it.ts +3 -0
- package/src/components/credit-notes/list/locales/nl.ts +3 -0
- package/src/components/credit-notes/list/locales/pl.ts +3 -0
- package/src/components/credit-notes/list/locales/pt.ts +3 -0
- package/src/components/credit-notes/list/locales/sl.ts +3 -0
- package/src/components/customers/create-customer-form/create-customer-form.tsx +0 -1
- package/src/components/documents/create/document-details-section.tsx +67 -1
- package/src/components/documents/create/mark-as-paid-section.tsx +11 -2
- package/src/components/documents/view/document-actions-bar.tsx +30 -0
- package/src/components/documents/view/locales/de.ts +5 -0
- package/src/components/documents/view/locales/es.ts +5 -0
- package/src/components/documents/view/locales/fr.ts +5 -0
- package/src/components/documents/view/locales/hr.ts +5 -0
- package/src/components/documents/view/locales/it.ts +5 -0
- package/src/components/documents/view/locales/nl.ts +5 -0
- package/src/components/documents/view/locales/pl.ts +5 -0
- package/src/components/documents/view/locales/pt.ts +5 -0
- package/src/components/documents/view/locales/sl.ts +5 -0
- package/src/components/entities/create-entity-form.tsx +1 -1
- package/src/components/entities/entity-settings-form/entity-settings-form.tsx +2 -3
- package/src/components/entities/entity-settings-form/locales/es.ts +2 -0
- package/src/components/entities/entity-settings-form/locales/fr.ts +2 -0
- package/src/components/entities/entity-settings-form/locales/hr.ts +2 -0
- package/src/components/entities/entity-settings-form/locales/it.ts +2 -0
- package/src/components/entities/entity-settings-form/locales/nl.ts +2 -0
- package/src/components/entities/entity-settings-form/locales/pl.ts +2 -0
- package/src/components/entities/entity-settings-form/locales/pt.ts +2 -0
- package/src/components/entities/fina-settings-form/fina-operator-required-dialog.tsx +109 -0
- package/src/components/entities/fina-settings-form/fina-settings-form.tsx +365 -35
- package/src/components/entities/fina-settings-form/fina-settings.hooks.ts +101 -20
- package/src/components/entities/fina-settings-form/index.ts +1 -0
- package/src/components/entities/fina-settings-form/locales/de.ts +54 -34
- package/src/components/entities/fina-settings-form/locales/en.ts +51 -34
- package/src/components/entities/fina-settings-form/locales/es.ts +50 -34
- package/src/components/entities/fina-settings-form/locales/fr.ts +50 -34
- package/src/components/entities/fina-settings-form/locales/hr.ts +50 -34
- package/src/components/entities/fina-settings-form/locales/it.ts +50 -34
- package/src/components/entities/fina-settings-form/locales/nl.ts +50 -34
- package/src/components/entities/fina-settings-form/locales/pl.ts +50 -34
- package/src/components/entities/fina-settings-form/locales/pt.ts +50 -34
- package/src/components/entities/fina-settings-form/locales/sl.ts +50 -34
- package/src/components/entities/fina-settings-form/sections/certificate-settings-section.tsx +18 -0
- package/src/components/entities/fina-settings-form/sections/premises-management-section.tsx +64 -89
- package/src/components/entities/fina-settings-form/sections/register-premise-dialog.tsx +51 -323
- package/src/components/entities/furs-settings-form/furs-operator-required-dialog.tsx +106 -0
- package/src/components/entities/furs-settings-form/furs-settings-form.tsx +24 -10
- package/src/components/entities/furs-settings-form/furs-settings.hooks.ts +5 -9
- package/src/components/entities/furs-settings-form/index.ts +1 -0
- package/src/components/entities/furs-settings-form/locales/de.ts +27 -3
- package/src/components/entities/furs-settings-form/locales/en.ts +17 -3
- package/src/components/entities/furs-settings-form/locales/es.ts +26 -3
- package/src/components/entities/furs-settings-form/locales/fr.ts +26 -3
- package/src/components/entities/furs-settings-form/locales/hr.ts +26 -3
- package/src/components/entities/furs-settings-form/locales/it.ts +26 -3
- package/src/components/entities/furs-settings-form/locales/nl.ts +26 -3
- package/src/components/entities/furs-settings-form/locales/pl.ts +26 -3
- package/src/components/entities/furs-settings-form/locales/pt.ts +26 -3
- package/src/components/entities/furs-settings-form/locales/sl.ts +16 -3
- package/src/components/entities/furs-settings-form/sections/certificate-settings-section.tsx +22 -0
- package/src/components/entities/furs-settings-form/sections/general-settings-section.tsx +15 -2
- package/src/components/entities/furs-settings-form/sections/register-premise-dialog.tsx +14 -2
- package/src/components/entities/settings/tax-rules-settings-form.tsx +4 -4
- package/src/components/estimates/list/list-row-actions.tsx +3 -7
- package/src/components/estimates/list/list-table.tsx +35 -2
- package/src/components/estimates/list/locales/de.ts +3 -0
- package/src/components/estimates/list/locales/en.ts +3 -0
- package/src/components/estimates/list/locales/es.ts +3 -0
- package/src/components/estimates/list/locales/fr.ts +3 -0
- package/src/components/estimates/list/locales/hr.ts +3 -0
- package/src/components/estimates/list/locales/it.ts +3 -0
- package/src/components/estimates/list/locales/nl.ts +3 -0
- package/src/components/estimates/list/locales/pl.ts +3 -0
- package/src/components/estimates/list/locales/pt.ts +3 -0
- package/src/components/estimates/list/locales/sl.ts +3 -0
- package/src/components/export/document-export-form.tsx +34 -34
- package/src/components/invoices/create/create-invoice-form.tsx +107 -5
- package/src/components/invoices/create/prepare-invoice-submission.ts +17 -0
- package/src/components/invoices/invoices.hooks.ts +32 -2
- package/src/components/invoices/list/list-row-actions.tsx +23 -8
- package/src/components/invoices/list/list-table.tsx +53 -2
- package/src/components/invoices/list/locales/de.ts +4 -0
- package/src/components/invoices/list/locales/en.ts +4 -0
- package/src/components/invoices/list/locales/es.ts +4 -0
- package/src/components/invoices/list/locales/fr.ts +4 -0
- package/src/components/invoices/list/locales/hr.ts +4 -0
- package/src/components/invoices/list/locales/it.ts +4 -0
- package/src/components/invoices/list/locales/nl.ts +4 -0
- package/src/components/invoices/list/locales/pl.ts +4 -0
- package/src/components/invoices/list/locales/pt.ts +4 -0
- package/src/components/invoices/list/locales/sl.ts +4 -0
- package/src/components/invoices/view/fiscalization-status-card.tsx +4 -1
- package/src/components/items/item-list-table/item-list-row-actions.tsx +3 -7
- package/src/components/items/item-list-table/item-list-row.tsx +3 -2
- package/src/components/items/item-list-table/item-list-table.tsx +5 -1
- package/src/components/recurring-invoices/create-recurring-invoice-form/create-recurring-invoice-form.tsx +418 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/de.ts +45 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/es.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/fr.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/hr.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/it.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/nl.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/pl.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/pt.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/sl.ts +44 -0
- package/src/components/recurring-invoices/index.ts +3 -0
- package/src/components/recurring-invoices/list/index.ts +2 -0
- package/src/components/recurring-invoices/list/list-row-actions.tsx +139 -0
- package/src/components/recurring-invoices/list/list-table.tsx +179 -0
- package/src/components/recurring-invoices/list/locales/de.ts +27 -0
- package/src/components/recurring-invoices/list/locales/en.ts +5 -0
- package/src/components/recurring-invoices/list/locales/es.ts +27 -0
- package/src/components/recurring-invoices/list/locales/fr.ts +27 -0
- package/src/components/recurring-invoices/list/locales/hr.ts +27 -0
- package/src/components/recurring-invoices/list/locales/it.ts +27 -0
- package/src/components/recurring-invoices/list/locales/nl.ts +27 -0
- package/src/components/recurring-invoices/list/locales/pl.ts +27 -0
- package/src/components/recurring-invoices/list/locales/pt.ts +27 -0
- package/src/components/recurring-invoices/list/locales/sl.ts +27 -0
- package/src/components/recurring-invoices/recurring-invoices.hooks.ts +28 -0
- package/src/components/table/data-table.tsx +122 -5
- package/src/components/table/selection-toolbar.tsx +36 -0
- package/src/components/tax-reports/kir-export-form.tsx +75 -55
- package/src/components/taxes/tax-list-table/tax-list-row-actions.tsx +3 -6
- package/src/components/taxes/tax-list-table/tax-list-row.tsx +3 -2
- package/src/components/taxes/tax-list-table/tax-list-table.tsx +5 -1
- package/src/components/ui/checkbox.tsx +5 -5
- package/src/generate-schemas.ts +45 -18
- package/src/generated/schemas/authorizeshopify_body.ts +22 -0
- package/src/generated/schemas/creditnote.ts +0 -2
- package/src/generated/schemas/entity.ts +1 -1
- package/src/generated/schemas/index.ts +39 -28
- package/src/generated/schemas/order.ts +127 -0
- package/src/generated/schemas/orderintegration.ts +51 -0
- package/src/generated/schemas/payment.ts +2 -0
- package/src/generated/schemas/recurringinvoice.ts +61 -0
- package/src/generated/schemas/renderadvanceinvoicepreview_body.ts +107 -140
- package/src/generated/schemas/rendercreditnotepreview_body.ts +108 -141
- package/src/generated/schemas/renderestimatepreview_body.ts +78 -82
- package/src/generated/schemas/renderinvoicepreview_body.ts +108 -141
- package/src/generated/schemas/webhook.ts +42 -0
- package/src/lib/furs-error-utils.ts +36 -0
- package/src/lib/schemas/advance-invoice.ts +3 -3
- package/src/lib/schemas/credit-note.ts +3 -3
- package/src/lib/schemas/estimate.ts +3 -3
- package/src/lib/schemas/invoice.ts +3 -3
- package/src/providers/white-label-provider.tsx +3 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Building2, Cpu,
|
|
1
|
+
import { Building2, Cpu, Info, MoreVertical, Trash2 } from "lucide-react";
|
|
2
2
|
import { type FC, type ReactNode, useState } from "react";
|
|
3
3
|
import type { FinaSectionType } from "../fina-settings-form";
|
|
4
4
|
|
|
@@ -7,21 +7,6 @@ type FinaBusinessPremise = {
|
|
|
7
7
|
entity_id: string;
|
|
8
8
|
premise_id: string;
|
|
9
9
|
type: string;
|
|
10
|
-
real_estate?: {
|
|
11
|
-
cadastral_municipality?: string;
|
|
12
|
-
land_registry_number?: string;
|
|
13
|
-
building_number?: string;
|
|
14
|
-
sub_building_number?: string;
|
|
15
|
-
street?: string;
|
|
16
|
-
house_number?: string;
|
|
17
|
-
house_number_additional?: string | null;
|
|
18
|
-
settlement?: string;
|
|
19
|
-
city?: string;
|
|
20
|
-
postal_code?: string;
|
|
21
|
-
};
|
|
22
|
-
movable_premise?: {
|
|
23
|
-
type?: string;
|
|
24
|
-
};
|
|
25
10
|
is_active: boolean;
|
|
26
11
|
registered_at: Date | string | null;
|
|
27
12
|
closed_at: Date | string | null;
|
|
@@ -53,7 +38,7 @@ import {
|
|
|
53
38
|
import { Input } from "@/ui/components/ui/input";
|
|
54
39
|
import { Label } from "@/ui/components/ui/label";
|
|
55
40
|
import { cn } from "@/ui/lib/utils";
|
|
56
|
-
import {
|
|
41
|
+
import { useDeleteFinaDevice, useDeleteFinaPremise, useRegisterFinaElectronicDevice } from "../fina-settings.hooks";
|
|
57
42
|
import { RegisterFinaPremiseDialog } from "./register-premise-dialog";
|
|
58
43
|
|
|
59
44
|
interface PremisesManagementSectionProps {
|
|
@@ -76,12 +61,20 @@ export const PremisesManagementSection: FC<PremisesManagementSectionProps> = ({
|
|
|
76
61
|
const wrap = (section: FinaSectionType, content: ReactNode) =>
|
|
77
62
|
wrapSection ? wrapSection(section, content) : content;
|
|
78
63
|
const [registerDialogOpen, setRegisterDialogOpen] = useState(false);
|
|
79
|
-
const [registerType, setRegisterType] = useState<"real-estate" | "movable">("real-estate");
|
|
80
64
|
const [addDeviceDialogOpen, setAddDeviceDialogOpen] = useState(false);
|
|
81
65
|
const [selectedPremiseId, setSelectedPremiseId] = useState<string | null>(null);
|
|
82
66
|
const [deviceId, setDeviceId] = useState("");
|
|
83
67
|
|
|
84
|
-
const { mutate:
|
|
68
|
+
const { mutate: deletePremise } = useDeleteFinaPremise({
|
|
69
|
+
onSuccess: () => {
|
|
70
|
+
onSuccess?.();
|
|
71
|
+
},
|
|
72
|
+
onError: (error) => {
|
|
73
|
+
onError?.(error);
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const { mutate: deleteDevice } = useDeleteFinaDevice({
|
|
85
78
|
onSuccess: () => {
|
|
86
79
|
onSuccess?.();
|
|
87
80
|
},
|
|
@@ -102,18 +95,22 @@ export const PremisesManagementSection: FC<PremisesManagementSectionProps> = ({
|
|
|
102
95
|
},
|
|
103
96
|
});
|
|
104
97
|
|
|
105
|
-
const
|
|
106
|
-
if (confirm(t("Are you sure you want to
|
|
107
|
-
|
|
98
|
+
const handleDeletePremise = (premiseId: string) => {
|
|
99
|
+
if (confirm(t("Are you sure you want to delete this premise? This will also deactivate all its devices."))) {
|
|
100
|
+
deletePremise({
|
|
108
101
|
entityId: entity.id,
|
|
109
102
|
premiseId,
|
|
110
103
|
});
|
|
111
104
|
}
|
|
112
105
|
};
|
|
113
106
|
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
107
|
+
const handleDeleteDevice = (deviceId: string) => {
|
|
108
|
+
if (confirm(t("Are you sure you want to delete this device?"))) {
|
|
109
|
+
deleteDevice({
|
|
110
|
+
entityId: entity.id,
|
|
111
|
+
deviceId,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
117
114
|
};
|
|
118
115
|
|
|
119
116
|
const handleAddDevice = (premiseId: string) => {
|
|
@@ -140,22 +137,24 @@ export const PremisesManagementSection: FC<PremisesManagementSectionProps> = ({
|
|
|
140
137
|
</div>
|
|
141
138
|
<div>
|
|
142
139
|
<h3 className="font-semibold text-lg">{t("Business Premises")}</h3>
|
|
143
|
-
<p className="text-muted-foreground text-sm">{t("
|
|
140
|
+
<p className="text-muted-foreground text-sm">{t("Manage your business premises for FINA")}</p>
|
|
144
141
|
</div>
|
|
145
142
|
</div>
|
|
146
143
|
|
|
147
144
|
<div className="space-y-6">
|
|
148
|
-
{/*
|
|
149
|
-
<
|
|
150
|
-
<
|
|
151
|
-
|
|
152
|
-
{t("
|
|
153
|
-
</
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
145
|
+
{/* Info banner */}
|
|
146
|
+
<Alert>
|
|
147
|
+
<Info className="h-4 w-4" />
|
|
148
|
+
<AlertDescription>
|
|
149
|
+
{t("Register your premises on ePorezna first, then add the premise ID here.")}
|
|
150
|
+
</AlertDescription>
|
|
151
|
+
</Alert>
|
|
152
|
+
|
|
153
|
+
{/* Add Premise Button */}
|
|
154
|
+
<Button onClick={() => setRegisterDialogOpen(true)} variant="default" className="cursor-pointer">
|
|
155
|
+
<Building2 className="mr-2 h-4 w-4" />
|
|
156
|
+
{t("Add Premise")}
|
|
157
|
+
</Button>
|
|
159
158
|
|
|
160
159
|
{/* Premises List */}
|
|
161
160
|
{premises.length === 0 ? (
|
|
@@ -177,10 +176,7 @@ export const PremisesManagementSection: FC<PremisesManagementSectionProps> = ({
|
|
|
177
176
|
<div className="flex items-center gap-2">
|
|
178
177
|
<CardTitle className="text-base">{premise.premise_id}</CardTitle>
|
|
179
178
|
<Badge variant={premise.is_active ? "default" : "secondary"}>
|
|
180
|
-
{premise.is_active ? t("Active") : t("
|
|
181
|
-
</Badge>
|
|
182
|
-
<Badge variant="outline">
|
|
183
|
-
{premise.type === "real_estate" ? t("Real Estate") : t("Movable")}
|
|
179
|
+
{premise.is_active ? t("Active") : t("Inactive")}
|
|
184
180
|
</Badge>
|
|
185
181
|
</div>
|
|
186
182
|
<CardDescription />
|
|
@@ -198,10 +194,11 @@ export const PremisesManagementSection: FC<PremisesManagementSectionProps> = ({
|
|
|
198
194
|
{t("Add Electronic Device")}
|
|
199
195
|
</DropdownMenuItem>
|
|
200
196
|
<DropdownMenuItem
|
|
201
|
-
onClick={() =>
|
|
197
|
+
onClick={() => handleDeletePremise(premise.id)}
|
|
202
198
|
className="cursor-pointer text-destructive"
|
|
203
199
|
>
|
|
204
|
-
|
|
200
|
+
<Trash2 className="mr-2 h-4 w-4" />
|
|
201
|
+
{t("Delete Premise")}
|
|
205
202
|
</DropdownMenuItem>
|
|
206
203
|
</DropdownMenuContent>
|
|
207
204
|
</DropdownMenu>
|
|
@@ -210,53 +207,32 @@ export const PremisesManagementSection: FC<PremisesManagementSectionProps> = ({
|
|
|
210
207
|
</CardHeader>
|
|
211
208
|
<CardContent>
|
|
212
209
|
<div className="space-y-3">
|
|
213
|
-
{/* Real Estate Info */}
|
|
214
|
-
{premise.real_estate && (
|
|
215
|
-
<div className="flex items-start gap-2 text-sm">
|
|
216
|
-
<MapPin className="mt-0.5 h-4 w-4 text-muted-foreground" />
|
|
217
|
-
<div>
|
|
218
|
-
<p className="font-medium">
|
|
219
|
-
{premise.real_estate.street} {premise.real_estate.house_number}
|
|
220
|
-
{premise.real_estate.house_number_additional &&
|
|
221
|
-
` ${premise.real_estate.house_number_additional}`}
|
|
222
|
-
</p>
|
|
223
|
-
<p className="text-muted-foreground">
|
|
224
|
-
{premise.real_estate.postal_code} {premise.real_estate.city}
|
|
225
|
-
</p>
|
|
226
|
-
{premise.real_estate.cadastral_municipality && (
|
|
227
|
-
<p className="text-muted-foreground text-xs">
|
|
228
|
-
{t("Cadastral Municipality")}: {premise.real_estate.cadastral_municipality}
|
|
229
|
-
{premise.real_estate.land_registry_number &&
|
|
230
|
-
` / ${t("Land Registry Number")}: ${premise.real_estate.land_registry_number}`}
|
|
231
|
-
{premise.real_estate.building_number &&
|
|
232
|
-
` / ${t("Building Number")}: ${premise.real_estate.building_number}`}
|
|
233
|
-
</p>
|
|
234
|
-
)}
|
|
235
|
-
</div>
|
|
236
|
-
</div>
|
|
237
|
-
)}
|
|
238
|
-
|
|
239
|
-
{/* Movable Info */}
|
|
240
|
-
{premise.movable_premise && (
|
|
241
|
-
<div className="flex items-start gap-2 text-sm">
|
|
242
|
-
<Truck className="mt-0.5 h-4 w-4 text-muted-foreground" />
|
|
243
|
-
<div>
|
|
244
|
-
<p className="font-medium">
|
|
245
|
-
{premise.movable_premise.type === "vehicle" && t("Vehicle")}
|
|
246
|
-
{premise.movable_premise.type === "market_stall" && t("Market Stall")}
|
|
247
|
-
{premise.movable_premise.type === "other" && t("Other")}
|
|
248
|
-
</p>
|
|
249
|
-
</div>
|
|
250
|
-
</div>
|
|
251
|
-
)}
|
|
252
|
-
|
|
253
210
|
{/* Devices Count or Warning */}
|
|
254
211
|
{premise.Devices && premise.Devices.length > 0 ? (
|
|
255
|
-
<div className="
|
|
256
|
-
<
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
212
|
+
<div className="space-y-1">
|
|
213
|
+
<div className="flex items-center gap-2 text-muted-foreground text-sm">
|
|
214
|
+
<Badge variant="secondary" className="text-xs">
|
|
215
|
+
{premise.Devices.length} {premise.Devices.length === 1 ? t("Device") : t("Devices")}
|
|
216
|
+
</Badge>
|
|
217
|
+
</div>
|
|
218
|
+
<div className="flex flex-wrap gap-2">
|
|
219
|
+
{premise.Devices.map((d) => (
|
|
220
|
+
<div key={d.id} className="flex items-center gap-1 rounded border px-2 py-1 text-xs">
|
|
221
|
+
<Cpu className="h-3 w-3 text-muted-foreground" />
|
|
222
|
+
<span>{d.device_id || "?"}</span>
|
|
223
|
+
{premise.is_active && (
|
|
224
|
+
<button
|
|
225
|
+
type="button"
|
|
226
|
+
onClick={() => handleDeleteDevice(d.id)}
|
|
227
|
+
className="ml-1 cursor-pointer text-muted-foreground hover:text-destructive"
|
|
228
|
+
title={t("Delete Device")}
|
|
229
|
+
>
|
|
230
|
+
<Trash2 className="h-3 w-3" />
|
|
231
|
+
</button>
|
|
232
|
+
)}
|
|
233
|
+
</div>
|
|
234
|
+
))}
|
|
235
|
+
</div>
|
|
260
236
|
</div>
|
|
261
237
|
) : (
|
|
262
238
|
<Alert>
|
|
@@ -300,7 +276,6 @@ export const PremisesManagementSection: FC<PremisesManagementSectionProps> = ({
|
|
|
300
276
|
open={registerDialogOpen}
|
|
301
277
|
onOpenChange={setRegisterDialogOpen}
|
|
302
278
|
entity={entity}
|
|
303
|
-
type={registerType}
|
|
304
279
|
t={t}
|
|
305
280
|
onSuccess={() => {
|
|
306
281
|
setRegisterDialogOpen(false);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
2
2
|
import type { FC } from "react";
|
|
3
|
-
import type { Resolver } from "react-hook-form";
|
|
4
3
|
import { useForm } from "react-hook-form";
|
|
5
4
|
import { z } from "zod";
|
|
6
5
|
import { Button } from "@/ui/components/ui/button";
|
|
@@ -22,41 +21,22 @@ import {
|
|
|
22
21
|
FormMessage,
|
|
23
22
|
} from "@/ui/components/ui/form";
|
|
24
23
|
import { Input } from "@/ui/components/ui/input";
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
land_registry_number: z.string().min(1, "Land registry number is required"),
|
|
34
|
-
building_number: z.string().optional().default(""),
|
|
35
|
-
sub_building_number: z.string().optional().default(""),
|
|
36
|
-
street: z.string().optional().default(""),
|
|
37
|
-
house_number: z.string().optional().default(""),
|
|
38
|
-
house_number_additional: z.string().optional().default(""),
|
|
39
|
-
settlement: z.string().optional().default(""),
|
|
40
|
-
city: z.string().optional().default(""),
|
|
41
|
-
postal_code: z.string().optional().default(""),
|
|
42
|
-
}),
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const movablePremiseSchema = z.object({
|
|
46
|
-
premise_id: z.string().min(1, "Premise ID is required").max(20),
|
|
47
|
-
movable_premise: z.object({
|
|
48
|
-
type: z.enum(["vehicle", "market_stall", "other"]),
|
|
49
|
-
}),
|
|
24
|
+
import { useCreateFinaPremise } from "../fina-settings.hooks";
|
|
25
|
+
|
|
26
|
+
const createPremiseSchema = z.object({
|
|
27
|
+
premise_id: z
|
|
28
|
+
.string()
|
|
29
|
+
.min(1, "Premise ID is required")
|
|
30
|
+
.max(20)
|
|
31
|
+
.regex(/^[0-9a-zA-Z]{1,20}$/, "Must be alphanumeric, 1-20 characters"),
|
|
50
32
|
});
|
|
51
33
|
|
|
52
|
-
type
|
|
53
|
-
type MovablePremiseForm = z.infer<typeof movablePremiseSchema>;
|
|
34
|
+
type CreatePremiseForm = z.infer<typeof createPremiseSchema>;
|
|
54
35
|
|
|
55
36
|
interface RegisterFinaPremiseDialogProps {
|
|
56
37
|
open: boolean;
|
|
57
38
|
onOpenChange: (open: boolean) => void;
|
|
58
39
|
entity: any;
|
|
59
|
-
type: "real-estate" | "movable";
|
|
60
40
|
t: (key: string) => string;
|
|
61
41
|
onSuccess?: () => void;
|
|
62
42
|
onError?: (error: unknown) => void;
|
|
@@ -66,329 +46,77 @@ export const RegisterFinaPremiseDialog: FC<RegisterFinaPremiseDialogProps> = ({
|
|
|
66
46
|
open,
|
|
67
47
|
onOpenChange,
|
|
68
48
|
entity,
|
|
69
|
-
type,
|
|
70
49
|
t,
|
|
71
50
|
onSuccess,
|
|
72
51
|
onError,
|
|
73
52
|
}) => {
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
const realEstateForm = useForm<RealEstatePremiseForm>({
|
|
77
|
-
resolver: zodResolver(realEstatePremiseSchema) as Resolver<RealEstatePremiseForm>,
|
|
78
|
-
defaultValues: {
|
|
79
|
-
premise_id: "",
|
|
80
|
-
real_estate: {
|
|
81
|
-
cadastral_municipality: "",
|
|
82
|
-
land_registry_number: "",
|
|
83
|
-
building_number: "",
|
|
84
|
-
sub_building_number: "",
|
|
85
|
-
street: "",
|
|
86
|
-
house_number: "",
|
|
87
|
-
house_number_additional: "",
|
|
88
|
-
settlement: "",
|
|
89
|
-
city: "",
|
|
90
|
-
postal_code: "",
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
const movableForm = useForm<MovablePremiseForm>({
|
|
96
|
-
resolver: zodResolver(movablePremiseSchema),
|
|
53
|
+
const form = useForm<CreatePremiseForm>({
|
|
54
|
+
resolver: zodResolver(createPremiseSchema),
|
|
97
55
|
defaultValues: {
|
|
98
56
|
premise_id: "",
|
|
99
|
-
movable_premise: {
|
|
100
|
-
type: "vehicle",
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
const { mutate: registerRealEstate, isPending: isRealEstatePending } = useRegisterFinaRealEstatePremise({
|
|
106
|
-
onSuccess: () => {
|
|
107
|
-
realEstateForm.reset();
|
|
108
|
-
onSuccess?.();
|
|
109
57
|
},
|
|
110
|
-
onError,
|
|
111
58
|
});
|
|
112
59
|
|
|
113
|
-
const { mutate:
|
|
60
|
+
const { mutate: createPremise, isPending } = useCreateFinaPremise({
|
|
114
61
|
onSuccess: () => {
|
|
115
|
-
|
|
62
|
+
form.reset();
|
|
116
63
|
onSuccess?.();
|
|
117
64
|
},
|
|
118
65
|
onError,
|
|
119
66
|
});
|
|
120
67
|
|
|
121
|
-
const
|
|
122
|
-
|
|
68
|
+
const handleSubmit = (data: CreatePremiseForm) => {
|
|
69
|
+
createPremise({
|
|
123
70
|
entityId: entity.id,
|
|
124
71
|
data,
|
|
125
72
|
});
|
|
126
73
|
};
|
|
127
74
|
|
|
128
|
-
const handleMovableSubmit = (data: MovablePremiseForm) => {
|
|
129
|
-
registerMovable({
|
|
130
|
-
entityId: entity.id,
|
|
131
|
-
data,
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const isPending = isRealEstatePending || isMovablePending;
|
|
136
|
-
|
|
137
75
|
return (
|
|
138
76
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
139
|
-
<DialogContent className="max-
|
|
77
|
+
<DialogContent className="max-w-md">
|
|
140
78
|
<DialogHeader>
|
|
141
|
-
<DialogTitle>{
|
|
79
|
+
<DialogTitle>{t("Add Business Premise")}</DialogTitle>
|
|
142
80
|
<DialogDescription>
|
|
143
81
|
{t(
|
|
144
|
-
"
|
|
82
|
+
"Enter the premise ID that you registered on ePorezna. After adding, you'll need to register at least one electronic device.",
|
|
145
83
|
)}
|
|
146
84
|
</DialogDescription>
|
|
147
85
|
</DialogHeader>
|
|
148
86
|
|
|
149
|
-
{
|
|
150
|
-
<
|
|
151
|
-
<
|
|
152
|
-
{
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
<
|
|
158
|
-
<
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
{/* Land Registry Number */}
|
|
184
|
-
<FormField
|
|
185
|
-
control={realEstateForm.control as any}
|
|
186
|
-
name="real_estate.land_registry_number"
|
|
187
|
-
render={({ field }) => (
|
|
188
|
-
<FormItem>
|
|
189
|
-
<FormLabel>{t("Land Registry Number")} *</FormLabel>
|
|
190
|
-
<FormControl>
|
|
191
|
-
<Input placeholder="123" {...field} />
|
|
192
|
-
</FormControl>
|
|
193
|
-
<FormMessage />
|
|
194
|
-
</FormItem>
|
|
195
|
-
)}
|
|
196
|
-
/>
|
|
197
|
-
|
|
198
|
-
{/* Building Information */}
|
|
199
|
-
<div className="grid grid-cols-2 gap-4">
|
|
200
|
-
<FormField
|
|
201
|
-
control={realEstateForm.control as any}
|
|
202
|
-
name="real_estate.building_number"
|
|
203
|
-
render={({ field }) => (
|
|
204
|
-
<FormItem>
|
|
205
|
-
<FormLabel>{t("Building Number")}</FormLabel>
|
|
206
|
-
<FormControl>
|
|
207
|
-
<Input placeholder="1" {...field} value={field.value || ""} />
|
|
208
|
-
</FormControl>
|
|
209
|
-
<FormMessage />
|
|
210
|
-
</FormItem>
|
|
211
|
-
)}
|
|
212
|
-
/>
|
|
213
|
-
<FormField
|
|
214
|
-
control={realEstateForm.control as any}
|
|
215
|
-
name="real_estate.sub_building_number"
|
|
216
|
-
render={({ field }) => (
|
|
217
|
-
<FormItem>
|
|
218
|
-
<FormLabel>{t("Sub-Building Number")}</FormLabel>
|
|
219
|
-
<FormControl>
|
|
220
|
-
<Input placeholder="A" {...field} value={field.value || ""} />
|
|
221
|
-
</FormControl>
|
|
222
|
-
<FormMessage />
|
|
223
|
-
</FormItem>
|
|
224
|
-
)}
|
|
225
|
-
/>
|
|
226
|
-
</div>
|
|
227
|
-
|
|
228
|
-
{/* Address */}
|
|
229
|
-
<FormField
|
|
230
|
-
control={realEstateForm.control as any}
|
|
231
|
-
name="real_estate.street"
|
|
232
|
-
render={({ field }) => (
|
|
233
|
-
<FormItem>
|
|
234
|
-
<FormLabel>{t("Street")}</FormLabel>
|
|
235
|
-
<FormControl>
|
|
236
|
-
<Input placeholder="Ilica" {...field} value={field.value || ""} />
|
|
237
|
-
</FormControl>
|
|
238
|
-
<FormMessage />
|
|
239
|
-
</FormItem>
|
|
240
|
-
)}
|
|
241
|
-
/>
|
|
242
|
-
|
|
243
|
-
<div className="grid grid-cols-2 gap-4">
|
|
244
|
-
<FormField
|
|
245
|
-
control={realEstateForm.control as any}
|
|
246
|
-
name="real_estate.house_number"
|
|
247
|
-
render={({ field }) => (
|
|
248
|
-
<FormItem>
|
|
249
|
-
<FormLabel>{t("House Number")}</FormLabel>
|
|
250
|
-
<FormControl>
|
|
251
|
-
<Input placeholder="22" {...field} value={field.value || ""} />
|
|
252
|
-
</FormControl>
|
|
253
|
-
<FormMessage />
|
|
254
|
-
</FormItem>
|
|
255
|
-
)}
|
|
256
|
-
/>
|
|
257
|
-
<FormField
|
|
258
|
-
control={realEstateForm.control as any}
|
|
259
|
-
name="real_estate.house_number_additional"
|
|
260
|
-
render={({ field }) => (
|
|
261
|
-
<FormItem>
|
|
262
|
-
<FormLabel>{t("House Number Additional")}</FormLabel>
|
|
263
|
-
<FormControl>
|
|
264
|
-
<Input placeholder="A" {...field} value={field.value || ""} />
|
|
265
|
-
</FormControl>
|
|
266
|
-
<FormMessage />
|
|
267
|
-
</FormItem>
|
|
268
|
-
)}
|
|
269
|
-
/>
|
|
270
|
-
</div>
|
|
271
|
-
|
|
272
|
-
<FormField
|
|
273
|
-
control={realEstateForm.control as any}
|
|
274
|
-
name="real_estate.settlement"
|
|
275
|
-
render={({ field }) => (
|
|
276
|
-
<FormItem>
|
|
277
|
-
<FormLabel>{t("Settlement")}</FormLabel>
|
|
278
|
-
<FormControl>
|
|
279
|
-
<Input placeholder="" {...field} value={field.value || ""} />
|
|
280
|
-
</FormControl>
|
|
281
|
-
<FormMessage />
|
|
282
|
-
</FormItem>
|
|
283
|
-
)}
|
|
284
|
-
/>
|
|
285
|
-
|
|
286
|
-
<div className="grid grid-cols-2 gap-4">
|
|
287
|
-
<FormField
|
|
288
|
-
control={realEstateForm.control as any}
|
|
289
|
-
name="real_estate.city"
|
|
290
|
-
render={({ field }) => (
|
|
291
|
-
<FormItem>
|
|
292
|
-
<FormLabel>{t("City")}</FormLabel>
|
|
293
|
-
<FormControl>
|
|
294
|
-
<Input placeholder="Zagreb" {...field} value={field.value || ""} />
|
|
295
|
-
</FormControl>
|
|
296
|
-
<FormMessage />
|
|
297
|
-
</FormItem>
|
|
298
|
-
)}
|
|
299
|
-
/>
|
|
300
|
-
<FormField
|
|
301
|
-
control={realEstateForm.control as any}
|
|
302
|
-
name="real_estate.postal_code"
|
|
303
|
-
render={({ field }) => (
|
|
304
|
-
<FormItem>
|
|
305
|
-
<FormLabel>{t("Postal Code")}</FormLabel>
|
|
306
|
-
<FormControl>
|
|
307
|
-
<Input placeholder="10000" {...field} value={field.value || ""} />
|
|
308
|
-
</FormControl>
|
|
309
|
-
<FormMessage />
|
|
310
|
-
</FormItem>
|
|
311
|
-
)}
|
|
312
|
-
/>
|
|
313
|
-
</div>
|
|
314
|
-
|
|
315
|
-
<DialogFooter>
|
|
316
|
-
<Button
|
|
317
|
-
type="button"
|
|
318
|
-
variant="outline"
|
|
319
|
-
onClick={() => onOpenChange(false)}
|
|
320
|
-
disabled={isPending}
|
|
321
|
-
className="cursor-pointer"
|
|
322
|
-
>
|
|
323
|
-
{t("Cancel")}
|
|
324
|
-
</Button>
|
|
325
|
-
<Button type="submit" disabled={isPending} className="cursor-pointer">
|
|
326
|
-
{isPending ? t("Registering...") : t("Register Premise")}
|
|
327
|
-
</Button>
|
|
328
|
-
</DialogFooter>
|
|
329
|
-
</form>
|
|
330
|
-
</Form>
|
|
331
|
-
) : (
|
|
332
|
-
<Form {...movableForm}>
|
|
333
|
-
<form onSubmit={movableForm.handleSubmit(handleMovableSubmit)} className="space-y-4">
|
|
334
|
-
{/* Premise ID */}
|
|
335
|
-
<FormField
|
|
336
|
-
control={movableForm.control}
|
|
337
|
-
name="premise_id"
|
|
338
|
-
render={({ field }) => (
|
|
339
|
-
<FormItem>
|
|
340
|
-
<FormLabel>{t("Premise ID")}</FormLabel>
|
|
341
|
-
<FormControl>
|
|
342
|
-
<Input placeholder="PP1" {...field} />
|
|
343
|
-
</FormControl>
|
|
344
|
-
<FormDescription>{t("Unique identifier for this premise (e.g., PP1, OFFICE1)")}</FormDescription>
|
|
345
|
-
<FormMessage />
|
|
346
|
-
</FormItem>
|
|
347
|
-
)}
|
|
348
|
-
/>
|
|
349
|
-
|
|
350
|
-
{/* Premise Type */}
|
|
351
|
-
<FormField
|
|
352
|
-
control={movableForm.control}
|
|
353
|
-
name="movable_premise.type"
|
|
354
|
-
render={({ field }) => (
|
|
355
|
-
<FormItem>
|
|
356
|
-
<FormLabel>{t("Premise Type")}</FormLabel>
|
|
357
|
-
<Select onValueChange={field.onChange} value={field.value}>
|
|
358
|
-
<FormControl>
|
|
359
|
-
<SelectTrigger>
|
|
360
|
-
<SelectValue placeholder="Select type" />
|
|
361
|
-
</SelectTrigger>
|
|
362
|
-
</FormControl>
|
|
363
|
-
<SelectContent>
|
|
364
|
-
<SelectItem value="vehicle">{t("Vehicle")}</SelectItem>
|
|
365
|
-
<SelectItem value="market_stall">{t("Market Stall")}</SelectItem>
|
|
366
|
-
<SelectItem value="other">{t("Other Movable")}</SelectItem>
|
|
367
|
-
</SelectContent>
|
|
368
|
-
</Select>
|
|
369
|
-
<FormDescription>{t("Type of movable business premise")}</FormDescription>
|
|
370
|
-
<FormMessage />
|
|
371
|
-
</FormItem>
|
|
372
|
-
)}
|
|
373
|
-
/>
|
|
374
|
-
|
|
375
|
-
<DialogFooter>
|
|
376
|
-
<Button
|
|
377
|
-
type="button"
|
|
378
|
-
variant="outline"
|
|
379
|
-
onClick={() => onOpenChange(false)}
|
|
380
|
-
disabled={isPending}
|
|
381
|
-
className="cursor-pointer"
|
|
382
|
-
>
|
|
383
|
-
{t("Cancel")}
|
|
384
|
-
</Button>
|
|
385
|
-
<Button type="submit" disabled={isPending} className="cursor-pointer">
|
|
386
|
-
{isPending ? t("Registering...") : t("Register Premise")}
|
|
387
|
-
</Button>
|
|
388
|
-
</DialogFooter>
|
|
389
|
-
</form>
|
|
390
|
-
</Form>
|
|
391
|
-
)}
|
|
87
|
+
<Form {...form}>
|
|
88
|
+
<form onSubmit={form.handleSubmit(handleSubmit)} className="space-y-4">
|
|
89
|
+
<FormField
|
|
90
|
+
control={form.control}
|
|
91
|
+
name="premise_id"
|
|
92
|
+
render={({ field }) => (
|
|
93
|
+
<FormItem>
|
|
94
|
+
<FormLabel>{t("Premise ID")}</FormLabel>
|
|
95
|
+
<FormControl>
|
|
96
|
+
<Input placeholder="PP1" {...field} />
|
|
97
|
+
</FormControl>
|
|
98
|
+
<FormDescription>{t("Unique identifier for this premise (e.g., PP1, OFFICE1)")}</FormDescription>
|
|
99
|
+
<FormMessage />
|
|
100
|
+
</FormItem>
|
|
101
|
+
)}
|
|
102
|
+
/>
|
|
103
|
+
|
|
104
|
+
<DialogFooter>
|
|
105
|
+
<Button
|
|
106
|
+
type="button"
|
|
107
|
+
variant="outline"
|
|
108
|
+
onClick={() => onOpenChange(false)}
|
|
109
|
+
disabled={isPending}
|
|
110
|
+
className="cursor-pointer"
|
|
111
|
+
>
|
|
112
|
+
{t("Cancel")}
|
|
113
|
+
</Button>
|
|
114
|
+
<Button type="submit" disabled={isPending} className="cursor-pointer">
|
|
115
|
+
{isPending ? t("Adding...") : t("Add Premise")}
|
|
116
|
+
</Button>
|
|
117
|
+
</DialogFooter>
|
|
118
|
+
</form>
|
|
119
|
+
</Form>
|
|
392
120
|
</DialogContent>
|
|
393
121
|
</Dialog>
|
|
394
122
|
);
|