diff --git a/src/modules/digital-signatures/components/digital-signatures-module.tsx b/src/modules/digital-signatures/components/digital-signatures-module.tsx index a1051c6..a11a5cf 100644 --- a/src/modules/digital-signatures/components/digital-signatures-module.tsx +++ b/src/modules/digital-signatures/components/digital-signatures-module.tsx @@ -1,7 +1,7 @@ 'use client'; -import { useState } from 'react'; -import { Plus, Pencil, Trash2, Search, PenTool, Stamp, Type, History, AlertTriangle } from 'lucide-react'; +import { useState, useRef } from 'react'; +import { Plus, Pencil, Trash2, Search, PenTool, Stamp, Type, History, AlertTriangle, Upload, X } from 'lucide-react'; import { Button } from '@/shared/components/ui/button'; import { Input } from '@/shared/components/ui/input'; import { Label } from '@/shared/components/ui/label'; @@ -206,6 +206,46 @@ export function DigitalSignaturesModule() { ); } +function ImageUploadField({ value, onChange }: { value: string; onChange: (v: string) => void }) { + const fileRef = useRef(null); + + const handleFile = (file: File) => { + if (!file.type.startsWith('image/')) return; + const reader = new FileReader(); + reader.onload = (e) => onChange(e.target?.result as string); + reader.readAsDataURL(file); + }; + + return ( +
+
fileRef.current?.click()} + onDragOver={(e) => e.preventDefault()} + onDrop={(e) => { e.preventDefault(); const f = e.dataTransfer.files[0]; if (f) handleFile(f); }} + > + {value ? ( + // eslint-disable-next-line @next/next/no-img-element + preview + ) : ( + <> + + Trage imaginea aici sau apasă pentru a selecta + + )} +
+ { const f = e.target.files?.[0]; if (f) handleFile(f); }} /> + {value && ( + + )} +
+ ); +} + function AddVersionForm({ onSubmit, onCancel, history }: { onSubmit: (imageUrl: string, notes: string) => void; onCancel: () => void; @@ -228,8 +268,8 @@ function AddVersionForm({ onSubmit, onCancel, history }: { )}
- - setImageUrl(e.target.value)} className="mt-1" placeholder="https://... sau data:image/png;base64,..." required /> + +
@@ -256,6 +296,19 @@ function AssetForm({ initial, onSubmit, onCancel }: { const [expirationDate, setExpirationDate] = useState(initial?.expirationDate ?? ''); const [legalStatus, setLegalStatus] = useState(initial?.legalStatus ?? ''); const [usageNotes, setUsageNotes] = useState(initial?.usageNotes ?? ''); + const [tags, setTags] = useState(initial?.tags ?? []); + const [tagInput, setTagInput] = useState(''); + + const addTag = (raw: string) => { + const t = raw.trim().toLowerCase(); + if (t && !tags.includes(t)) setTags((prev) => [...prev, t]); + setTagInput(''); + }; + + const handleTagKeyDown = (e: React.KeyboardEvent) => { + if (e.key === 'Enter' || e.key === ',') { e.preventDefault(); addTag(tagInput); } + if (e.key === 'Backspace' && tagInput === '' && tags.length > 0) setTags((prev) => prev.slice(0, -1)); + }; return (
{ @@ -265,7 +318,7 @@ function AssetForm({ initial, onSubmit, onCancel }: { expirationDate: expirationDate || undefined, legalStatus, usageNotes, versions: initial?.versions ?? [], - tags: initial?.tags ?? [], visibility: initial?.visibility ?? 'all', + tags, visibility: initial?.visibility ?? 'all', }); }} className="space-y-4">
@@ -296,15 +349,35 @@ function AssetForm({ initial, onSubmit, onCancel }: {
- - setImageUrl(e.target.value)} className="mt-1" placeholder="https://... sau data:image/png;base64,..." /> -

URL către imaginea semnăturii/ștampilei. Suportă URL-uri externe sau base64.

+ +
setExpirationDate(e.target.value)} className="mt-1" />
setLegalStatus(e.target.value)} className="mt-1" placeholder="Valid, Anulat..." />
setUsageNotes(e.target.value)} className="mt-1" placeholder="Doar pentru contracte..." />
+
+ +
+ {tags.map((tag) => ( + + {tag} + + + ))} + setTagInput(e.target.value)} + onKeyDown={handleTagKeyDown} + onBlur={() => { if (tagInput.trim()) addTag(tagInput); }} + placeholder={tags.length === 0 ? 'Adaugă etichete (Enter sau virgulă)...' : ''} + className="min-w-[120px] flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground" + /> +
+