diff --git a/src/modules/address-book/components/address-book-module.tsx b/src/modules/address-book/components/address-book-module.tsx index 6b5f686..145c527 100644 --- a/src/modules/address-book/components/address-book-module.tsx +++ b/src/modules/address-book/components/address-book-module.tsx @@ -174,7 +174,7 @@ function ContactCard({ contact, onEdit, onDelete }: { {contact.website} )} - {contact.contactPersons.length > 0 && ( + {(contact.contactPersons ?? []).length > 0 && (

Persoane de contact ({contact.contactPersons.length}) diff --git a/src/modules/address-book/hooks/use-contacts.ts b/src/modules/address-book/hooks/use-contacts.ts index d0601ee..6c2695e 100644 --- a/src/modules/address-book/hooks/use-contacts.ts +++ b/src/modules/address-book/hooks/use-contacts.ts @@ -76,8 +76,8 @@ export function useContacts() { c.company.toLowerCase().includes(q) || c.email.toLowerCase().includes(q) || c.phone.includes(q) || - c.department.toLowerCase().includes(q) || - c.role.toLowerCase().includes(q) + (c.department ?? '').toLowerCase().includes(q) || + (c.role ?? '').toLowerCase().includes(q) ); } return true; diff --git a/src/modules/digital-signatures/components/digital-signatures-module.tsx b/src/modules/digital-signatures/components/digital-signatures-module.tsx index fea5988..a1051c6 100644 --- a/src/modules/digital-signatures/components/digital-signatures-module.tsx +++ b/src/modules/digital-signatures/components/digital-signatures-module.tsx @@ -157,8 +157,8 @@ export function DigitalSignaturesModule() { {asset.usageNotes && (

Note: {asset.usageNotes}

)} - {asset.versions.length > 0 && ( -

Versiuni: {asset.versions.length + 1}

+ {(asset.versions ?? []).length > 0 && ( +

Versiuni: {(asset.versions ?? []).length + 1}

)}
diff --git a/src/modules/digital-signatures/hooks/use-signatures.ts b/src/modules/digital-signatures/hooks/use-signatures.ts index c4a32e7..5a721fb 100644 --- a/src/modules/digital-signatures/hooks/use-signatures.ts +++ b/src/modules/digital-signatures/hooks/use-signatures.ts @@ -60,7 +60,7 @@ export function useSignatures() { const existing = assets.find((a) => a.id === assetId); if (!existing) return; const version: AssetVersion = { id: uuid(), imageUrl, notes, createdAt: new Date().toISOString() }; - const updatedVersions = [...existing.versions, version]; + const updatedVersions = [...(existing.versions ?? []), version]; await updateAsset(assetId, { imageUrl, versions: updatedVersions }); }, [assets, updateAsset]); diff --git a/src/modules/it-inventory/hooks/use-inventory.ts b/src/modules/it-inventory/hooks/use-inventory.ts index a6bea65..50fce67 100644 --- a/src/modules/it-inventory/hooks/use-inventory.ts +++ b/src/modules/it-inventory/hooks/use-inventory.ts @@ -79,9 +79,9 @@ export function useInventory() { item.name.toLowerCase().includes(q) || item.serialNumber.toLowerCase().includes(q) || item.assignedTo.toLowerCase().includes(q) || - item.ipAddress.toLowerCase().includes(q) || - item.vendor.toLowerCase().includes(q) || - item.model.toLowerCase().includes(q) + (item.ipAddress ?? '').toLowerCase().includes(q) || + (item.vendor ?? '').toLowerCase().includes(q) || + (item.model ?? '').toLowerCase().includes(q) ); } return true; diff --git a/src/modules/registratura/components/registratura-module.tsx b/src/modules/registratura/components/registratura-module.tsx index 9a96bc6..bc19e61 100644 --- a/src/modules/registratura/components/registratura-module.tsx +++ b/src/modules/registratura/components/registratura-module.tsx @@ -50,7 +50,7 @@ export function RegistraturaModule() { const handleCloseRequest = (id: string) => { const entry = allEntries.find((e) => e.id === id); - if (entry && entry.linkedEntryIds.length > 0) { + if (entry && (entry.linkedEntryIds ?? []).length > 0) { setClosingId(id); } else { closeEntry(id, false); @@ -158,7 +158,7 @@ export function RegistraturaModule() {

- Această înregistrare are {closingEntry?.linkedEntryIds.length ?? 0} înregistrări legate. + Această înregistrare are {closingEntry?.linkedEntryIds?.length ?? 0} înregistrări legate. Vrei să le închizi și pe acestea?

diff --git a/src/modules/registratura/components/registry-table.tsx b/src/modules/registratura/components/registry-table.tsx index 3764390..7a84aae 100644 --- a/src/modules/registratura/components/registry-table.tsx +++ b/src/modules/registratura/components/registry-table.tsx @@ -69,7 +69,7 @@ export function RegistryTable({ entries, loading, onEdit, onDelete, onClose }: R {entries.map((entry) => { - const overdueDays = entry.status === 'deschis' ? getOverdueDays(entry.deadline) : null; + const overdueDays = (entry.status === 'deschis' || !entry.status) ? getOverdueDays(entry.deadline) : null; const isOverdue = overdueDays !== null && overdueDays > 0; return ( - {DIRECTION_LABELS[entry.direction]} + {DIRECTION_LABELS[entry.direction] ?? entry.direction ?? '—'} - {DOC_TYPE_LABELS[entry.documentType]} + {DOC_TYPE_LABELS[entry.documentType] ?? entry.documentType ?? '—'} {entry.subject} - {entry.linkedEntryIds.length > 0 && ( + {(entry.linkedEntryIds ?? []).length > 0 && ( )} - {entry.attachments.length > 0 && ( + {(entry.attachments ?? []).length > 0 && ( {entry.attachments.length} fișiere diff --git a/src/modules/registratura/hooks/use-registry.ts b/src/modules/registratura/hooks/use-registry.ts index de11fdb..2380979 100644 --- a/src/modules/registratura/hooks/use-registry.ts +++ b/src/modules/registratura/hooks/use-registry.ts @@ -76,8 +76,9 @@ export function useRegistry() { const entry = entries.find((e) => e.id === id); if (!entry) return; await updateEntry(id, { status: 'inchis' }); - if (closeLinked && entry.linkedEntryIds.length > 0) { - for (const linkedId of entry.linkedEntryIds) { + const linked = entry.linkedEntryIds ?? []; + if (closeLinked && linked.length > 0) { + for (const linkedId of linked) { const linked = entries.find((e) => e.id === linkedId); if (linked && linked.status !== 'inchis') { const updatedLinked: RegistryEntry = { diff --git a/src/modules/word-templates/components/word-templates-module.tsx b/src/modules/word-templates/components/word-templates-module.tsx index 8936c81..7426475 100644 --- a/src/modules/word-templates/components/word-templates-module.tsx +++ b/src/modules/word-templates/components/word-templates-module.tsx @@ -124,9 +124,9 @@ export function WordTemplatesModule() { {tpl.clonedFrom && Clonă} {/* Placeholders display */} - {tpl.placeholders.length > 0 && ( + {(tpl.placeholders ?? []).length > 0 && (
- {tpl.placeholders.map((p) => ( + {(tpl.placeholders ?? []).map((p) => ( {`{{${p}}}`} ))}
@@ -181,7 +181,7 @@ function TemplateForm({ initial, onSubmit, onCancel }: { const [fileUrl, setFileUrl] = useState(initial?.fileUrl ?? ''); const [company, setCompany] = useState(initial?.company ?? 'beletage'); const [version, setVersion] = useState(initial?.version ?? '1.0.0'); - const [placeholdersText, setPlaceholdersText] = useState(initial?.placeholders.join(', ') ?? ''); + const [placeholdersText, setPlaceholdersText] = useState((initial?.placeholders ?? []).join(', ')); return (
{