-
+
setName(e.target.value)}
className="mt-1"
- required
+ required={!company.trim()}
/>
-
+
setCompany(e.target.value)}
className="mt-1"
+ required={!name.trim()}
/>
@@ -934,6 +949,14 @@ function ContactForm({
}
className="min-w-[150px] flex-1 text-sm"
/>
+
+ updateContactPerson(i, "department", e.target.value)
+ }
+ className="w-[140px] text-sm"
+ />
a.name.localeCompare(b.name));
+ results.sort((a, b) =>
+ (a.name || a.company).localeCompare(b.name || b.company, "ro"),
+ );
setContacts(results);
setLoading(false);
}, [storage]);
diff --git a/src/modules/address-book/services/vcard-export.ts b/src/modules/address-book/services/vcard-export.ts
index 7da07a8..07598cf 100644
--- a/src/modules/address-book/services/vcard-export.ts
+++ b/src/modules/address-book/services/vcard-export.ts
@@ -6,11 +6,12 @@ import type { AddressContact } from "../types";
export function downloadVCard(contact: AddressContact): void {
const lines: string[] = ["BEGIN:VCARD", "VERSION:3.0"];
- // Full name
- lines.push(`FN:${esc(contact.name)}`);
+ // Full name — use company as fallback if no personal name
+ const displayName = contact.name || contact.company || "Contact";
+ lines.push(`FN:${esc(displayName)}`);
// Structured name — try to split first/last (best-effort)
- const nameParts = contact.name.trim().split(/\s+/);
+ const nameParts = displayName.trim().split(/\s+/);
const last =
nameParts.length > 1 ? (nameParts[nameParts.length - 1] ?? "") : "";
const first =
@@ -64,7 +65,7 @@ export function downloadVCard(contact: AddressContact): void {
const cpNote = contact.contactPersons
.map(
(cp) =>
- `${cp.name}${cp.role ? ` (${cp.role})` : ""}${cp.email ? ` <${cp.email}>` : ""}${cp.phone ? ` ${cp.phone}` : ""}`,
+ `${cp.name}${cp.department ? ` [${cp.department}]` : ""}${cp.role ? ` (${cp.role})` : ""}${cp.email ? ` <${cp.email}>` : ""}${cp.phone ? ` ${cp.phone}` : ""}`,
)
.join("; ");
lines.push(`NOTE:Persoane contact: ${esc(cpNote)}`);
@@ -78,7 +79,7 @@ export function downloadVCard(contact: AddressContact): void {
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
- a.download = `${contact.name
+ a.download = `${displayName
.replace(/[^a-zA-Z0-9\s-]/g, "")
.trim()
.replace(/\s+/g, "_")}.vcf`;
diff --git a/src/modules/address-book/types.ts b/src/modules/address-book/types.ts
index 9d0fd4b..b8f2b29 100644
--- a/src/modules/address-book/types.ts
+++ b/src/modules/address-book/types.ts
@@ -11,6 +11,7 @@ export type ContactType =
/** A contact person within an organization/entity */
export interface ContactPerson {
name: string;
+ department: string;
role: string;
email: string;
phone: string;