fix: guard against undefined fields when loading old localStorage data
Old entries in localStorage lack new fields (department, role, contactPersons, linkedEntryIds, attachments, versions, placeholders, ipAddress, vendor, model). Add null-coalescing guards to prevent client-side crashes on property access. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -157,8 +157,8 @@ export function DigitalSignaturesModule() {
|
||||
{asset.usageNotes && (
|
||||
<p className="text-xs text-muted-foreground line-clamp-1">Note: {asset.usageNotes}</p>
|
||||
)}
|
||||
{asset.versions.length > 0 && (
|
||||
<p className="text-xs text-muted-foreground">Versiuni: {asset.versions.length + 1}</p>
|
||||
{(asset.versions ?? []).length > 0 && (
|
||||
<p className="text-xs text-muted-foreground">Versiuni: {(asset.versions ?? []).length + 1}</p>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
|
||||
@@ -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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user