@spaceinvoices/react-ui 0.3.0 → 0.4.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/cli/dist/index.js +1 -1
- package/package.json +1 -1
- package/registry.json +0 -230
- package/src/components/advance-invoices/advance-invoices.hooks.ts +2 -2
- package/src/components/documents/documents.hooks.ts +5 -48
- package/src/components/documents/shared/document-preview-display.tsx +12 -1
- package/src/components/documents/view/document-actions-bar.tsx +20 -12
- package/src/components/documents/view/document-activities-list.tsx +166 -0
- package/src/components/documents/view/document-details-card.tsx +6 -6
- package/src/components/documents/view/index.ts +1 -0
- package/src/components/documents/view/locales/de.ts +32 -0
- package/src/components/documents/view/locales/es.ts +32 -0
- package/src/components/documents/view/locales/fr.ts +32 -0
- package/src/components/documents/view/locales/hr.ts +32 -0
- package/src/components/documents/view/locales/it.ts +32 -0
- package/src/components/documents/view/locales/nl.ts +32 -0
- package/src/components/documents/view/locales/pl.ts +32 -0
- package/src/components/documents/view/locales/pt.ts +32 -0
- package/src/components/documents/view/locales/sl.ts +32 -0
- package/src/components/entities/fina-settings-form/locales/de.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/en.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/es.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/fr.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/hr.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/it.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/nl.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/pl.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/pt.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/sl.ts +3 -0
- package/src/components/entities/furs-settings-form/furs-settings-form.tsx +15 -7
- package/src/components/entities/furs-settings-form/furs-settings.hooks.ts +1 -1
- package/src/components/entities/furs-settings-form/locales/de.ts +2 -0
- package/src/components/entities/furs-settings-form/locales/en.ts +12 -0
- package/src/components/entities/furs-settings-form/locales/es.ts +2 -0
- package/src/components/entities/furs-settings-form/locales/fr.ts +2 -0
- package/src/components/entities/furs-settings-form/locales/hr.ts +2 -0
- package/src/components/entities/furs-settings-form/locales/it.ts +2 -0
- package/src/components/entities/furs-settings-form/locales/nl.ts +2 -0
- package/src/components/entities/furs-settings-form/locales/pl.ts +2 -0
- package/src/components/entities/furs-settings-form/locales/pt.ts +2 -0
- package/src/components/entities/furs-settings-form/locales/sl.ts +14 -0
- package/src/components/entities/furs-settings-form/sections/general-settings-section.tsx +121 -1
- package/src/components/entities/furs-settings-form/sections/premises-management-section.tsx +1 -0
- package/src/components/entities/furs-settings-form/sections/register-premise-dialog.tsx +44 -32
- package/src/components/invoices/index.ts +1 -1
- package/src/components/invoices/send-email-dialog/send-email-dialog.tsx +2 -2
- package/src/components/invoices/view/fiscalization-status-card.tsx +121 -0
- package/src/generate-schemas.ts +13 -1
- package/src/generated/schemas/advanceinvoice.ts +79 -187
- package/src/generated/schemas/creditnote.ts +63 -86
- package/src/generated/schemas/customadvanceinvoice.ts +70 -97
- package/src/generated/schemas/customcreditnote.ts +70 -97
- package/src/generated/schemas/customestimate.ts +68 -97
- package/src/generated/schemas/custominvoice.ts +70 -97
- package/src/generated/schemas/estimate.ts +67 -172
- package/src/generated/schemas/invoice.ts +79 -187
- package/src/generated/schemas/registerfursrealestatepremise_body.ts +11 -7
- package/src/generated/schemas/renderadvanceinvoicepreview_body.ts +61 -157
- package/src/generated/schemas/rendercreditnotepreview_body.ts +61 -157
- package/src/generated/schemas/renderestimatepreview_body.ts +61 -157
- package/src/generated/schemas/renderinvoicepreview_body.ts +61 -157
- package/src/hooks/use-duplicate-document.ts +19 -11
- package/src/providers/entities-provider.tsx +21 -0
- package/src/components/invoices/view/fina-info-display.tsx +0 -196
- package/src/components/invoices/view/furs-info-display.tsx +0 -213
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import type { FursFiscalizationResponse, Invoice } from "@spaceinvoices/js-sdk";
|
|
2
|
-
import { AlertCircle, Check, CheckCircle2, Clock, Copy, XCircle } from "lucide-react";
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import { Alert, AlertDescription, AlertTitle } from "@/ui/components/ui/alert";
|
|
5
|
-
import { Badge } from "@/ui/components/ui/badge";
|
|
6
|
-
import { Button } from "@/ui/components/ui/button";
|
|
7
|
-
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/ui/components/ui/card";
|
|
8
|
-
import type { ComponentTranslationProps } from "@/ui/lib/translation";
|
|
9
|
-
import { createTranslation } from "@/ui/lib/translation";
|
|
10
|
-
import de from "../../entities/furs-settings-form/locales/de";
|
|
11
|
-
import en from "../../entities/furs-settings-form/locales/en";
|
|
12
|
-
import sl from "../../entities/furs-settings-form/locales/sl";
|
|
13
|
-
|
|
14
|
-
const translations = { de, sl, en } as const;
|
|
15
|
-
|
|
16
|
-
// Type alias for easier use
|
|
17
|
-
type FursData = FursFiscalizationResponse;
|
|
18
|
-
|
|
19
|
-
interface FursInfoDisplayProps extends ComponentTranslationProps {
|
|
20
|
-
invoice: Invoice;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* FURS Fiscalization Info Display Component
|
|
25
|
-
*
|
|
26
|
-
* Shows FURS fiscalization status, ZOI, EOR, QR code, and other related data
|
|
27
|
-
*/
|
|
28
|
-
export function FursInfoDisplay({ invoice, t: translateFn, namespace, locale }: FursInfoDisplayProps) {
|
|
29
|
-
const [copiedField, setCopiedField] = useState<string | null>(null);
|
|
30
|
-
|
|
31
|
-
const t = createTranslation({
|
|
32
|
-
t: translateFn,
|
|
33
|
-
namespace,
|
|
34
|
-
locale,
|
|
35
|
-
translations,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// Cast furs to the proper type (SDK has it as object, but it's actually FursData)
|
|
39
|
-
const furs = invoice.furs as FursData | undefined;
|
|
40
|
-
|
|
41
|
-
// If no FURS data, don't render anything
|
|
42
|
-
if (!furs) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const copyToClipboard = async (text: string, fieldName: string) => {
|
|
47
|
-
try {
|
|
48
|
-
await navigator.clipboard.writeText(text);
|
|
49
|
-
setCopiedField(fieldName);
|
|
50
|
-
setTimeout(() => setCopiedField(null), 2000);
|
|
51
|
-
} catch (err) {
|
|
52
|
-
console.error("Failed to copy:", err);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const getStatusBadge = () => {
|
|
57
|
-
switch (furs.status) {
|
|
58
|
-
case "success":
|
|
59
|
-
return (
|
|
60
|
-
<Badge className="bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100">
|
|
61
|
-
<CheckCircle2 className="mr-1 h-3 w-3" />
|
|
62
|
-
{t("Fiscalized")}
|
|
63
|
-
</Badge>
|
|
64
|
-
);
|
|
65
|
-
case "pending":
|
|
66
|
-
return (
|
|
67
|
-
<Badge className="bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-100">
|
|
68
|
-
<Clock className="mr-1 h-3 w-3" />
|
|
69
|
-
{t("Pending")}
|
|
70
|
-
</Badge>
|
|
71
|
-
);
|
|
72
|
-
case "failed":
|
|
73
|
-
return (
|
|
74
|
-
<Badge className="bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-100">
|
|
75
|
-
<XCircle className="mr-1 h-3 w-3" />
|
|
76
|
-
{t("Failed")}
|
|
77
|
-
</Badge>
|
|
78
|
-
);
|
|
79
|
-
default:
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<Card>
|
|
86
|
-
<CardHeader>
|
|
87
|
-
<CardTitle className="flex items-center gap-2">
|
|
88
|
-
{t("FURS Fiscalization")}
|
|
89
|
-
{getStatusBadge()}
|
|
90
|
-
</CardTitle>
|
|
91
|
-
<CardDescription>{t("Slovenian tax authority fiscalization details")}</CardDescription>
|
|
92
|
-
</CardHeader>
|
|
93
|
-
<CardContent className="space-y-4">
|
|
94
|
-
{/* Error Message */}
|
|
95
|
-
{furs.status === "failed" && furs.error && (
|
|
96
|
-
<Alert variant="destructive">
|
|
97
|
-
<AlertCircle className="h-4 w-4" />
|
|
98
|
-
<AlertTitle>{t("Fiscalization Error")}</AlertTitle>
|
|
99
|
-
<AlertDescription>{furs.error}</AlertDescription>
|
|
100
|
-
</Alert>
|
|
101
|
-
)}
|
|
102
|
-
|
|
103
|
-
{/* Cancellation Info */}
|
|
104
|
-
{furs.cancellation_reason && (
|
|
105
|
-
<Alert>
|
|
106
|
-
<AlertCircle className="h-4 w-4" />
|
|
107
|
-
<AlertTitle>{t("Cancelled")}</AlertTitle>
|
|
108
|
-
<AlertDescription>{furs.cancellation_reason}</AlertDescription>
|
|
109
|
-
</Alert>
|
|
110
|
-
)}
|
|
111
|
-
|
|
112
|
-
{/* FURS Data */}
|
|
113
|
-
{furs.data && (
|
|
114
|
-
<div className="space-y-3">
|
|
115
|
-
{/* ZOI Code */}
|
|
116
|
-
{furs.data.zoi && (
|
|
117
|
-
<div className="flex items-center justify-between rounded-lg border p-3">
|
|
118
|
-
<div className="space-y-1">
|
|
119
|
-
<p className="font-medium text-sm">{t("ZOI")}</p>
|
|
120
|
-
<p className="font-mono text-muted-foreground text-xs">{furs.data.zoi}</p>
|
|
121
|
-
</div>
|
|
122
|
-
<Button variant="ghost" size="sm" onClick={() => copyToClipboard(furs.data!.zoi!, "zoi")}>
|
|
123
|
-
{copiedField === "zoi" ? <Check className="h-4 w-4 text-green-600" /> : <Copy className="h-4 w-4" />}
|
|
124
|
-
</Button>
|
|
125
|
-
</div>
|
|
126
|
-
)}
|
|
127
|
-
|
|
128
|
-
{/* EOR Code */}
|
|
129
|
-
{furs.data.eor && (
|
|
130
|
-
<div className="flex items-center justify-between rounded-lg border p-3">
|
|
131
|
-
<div className="space-y-1">
|
|
132
|
-
<p className="font-medium text-sm">{t("EOR")}</p>
|
|
133
|
-
<p className="font-mono text-muted-foreground text-xs">{furs.data.eor}</p>
|
|
134
|
-
</div>
|
|
135
|
-
<Button variant="ghost" size="sm" onClick={() => copyToClipboard(furs.data!.eor!, "eor")}>
|
|
136
|
-
{copiedField === "eor" ? <Check className="h-4 w-4 text-green-600" /> : <Copy className="h-4 w-4" />}
|
|
137
|
-
</Button>
|
|
138
|
-
</div>
|
|
139
|
-
)}
|
|
140
|
-
|
|
141
|
-
{/* Cancelled EOR */}
|
|
142
|
-
{furs.data.cancelled && furs.data.cancelled_eor && (
|
|
143
|
-
<div className="flex items-center justify-between rounded-lg border border-red-200 bg-red-50 p-3 dark:border-red-800 dark:bg-red-950">
|
|
144
|
-
<div className="space-y-1">
|
|
145
|
-
<p className="font-medium text-red-900 text-sm dark:text-red-100">{t("Cancellation EOR")}</p>
|
|
146
|
-
<p className="font-mono text-red-700 text-xs dark:text-red-300">{furs.data.cancelled_eor}</p>
|
|
147
|
-
</div>
|
|
148
|
-
<Button
|
|
149
|
-
variant="ghost"
|
|
150
|
-
size="sm"
|
|
151
|
-
onClick={() => copyToClipboard(furs.data!.cancelled_eor!, "cancelled_eor")}
|
|
152
|
-
>
|
|
153
|
-
{copiedField === "cancelled_eor" ? (
|
|
154
|
-
<Check className="h-4 w-4 text-green-600" />
|
|
155
|
-
) : (
|
|
156
|
-
<Copy className="h-4 w-4" />
|
|
157
|
-
)}
|
|
158
|
-
</Button>
|
|
159
|
-
</div>
|
|
160
|
-
)}
|
|
161
|
-
|
|
162
|
-
{/* Business Premise & Device */}
|
|
163
|
-
<div className="grid grid-cols-2 gap-3">
|
|
164
|
-
{furs.data.business_premise_name && (
|
|
165
|
-
<div className="space-y-1">
|
|
166
|
-
<p className="font-medium text-sm">{t("Business Premise")}</p>
|
|
167
|
-
<p className="text-muted-foreground text-sm">{furs.data.business_premise_name}</p>
|
|
168
|
-
</div>
|
|
169
|
-
)}
|
|
170
|
-
{furs.data.electronic_device_name && (
|
|
171
|
-
<div className="space-y-1">
|
|
172
|
-
<p className="font-medium text-sm">{t("Electronic Device")}</p>
|
|
173
|
-
<p className="text-muted-foreground text-sm">{furs.data.electronic_device_name}</p>
|
|
174
|
-
</div>
|
|
175
|
-
)}
|
|
176
|
-
</div>
|
|
177
|
-
|
|
178
|
-
{/* Invoice Number & Iteration */}
|
|
179
|
-
{furs.data.invoice_number && (
|
|
180
|
-
<div className="grid grid-cols-2 gap-3">
|
|
181
|
-
<div className="space-y-1">
|
|
182
|
-
<p className="font-medium text-sm">{t("Invoice Number")}</p>
|
|
183
|
-
<p className="text-muted-foreground text-sm">{furs.data.invoice_number}</p>
|
|
184
|
-
</div>
|
|
185
|
-
{furs.data.iteration !== undefined && (
|
|
186
|
-
<div className="space-y-1">
|
|
187
|
-
<p className="font-medium text-sm">{t("Iteration")}</p>
|
|
188
|
-
<p className="text-muted-foreground text-sm">{furs.data.iteration}</p>
|
|
189
|
-
</div>
|
|
190
|
-
)}
|
|
191
|
-
</div>
|
|
192
|
-
)}
|
|
193
|
-
|
|
194
|
-
{/* QR Code */}
|
|
195
|
-
{furs.data.qr_code && (
|
|
196
|
-
<div className="flex flex-col items-center gap-2 rounded-lg border p-4">
|
|
197
|
-
<p className="font-medium text-sm">{t("QR Code")}</p>
|
|
198
|
-
<img src={`data:image/png;base64,${furs.data.qr_code}`} alt="FURS QR Code" className="h-48 w-48" />
|
|
199
|
-
</div>
|
|
200
|
-
)}
|
|
201
|
-
</div>
|
|
202
|
-
)}
|
|
203
|
-
|
|
204
|
-
{/* Fiscalized Timestamp */}
|
|
205
|
-
{furs.fiscalized_at && (
|
|
206
|
-
<div className="pt-2 text-muted-foreground text-sm">
|
|
207
|
-
{t("Fiscalized at")}: {new Date(furs.fiscalized_at).toLocaleString()}
|
|
208
|
-
</div>
|
|
209
|
-
)}
|
|
210
|
-
</CardContent>
|
|
211
|
-
</Card>
|
|
212
|
-
);
|
|
213
|
-
}
|