diff --git a/src/modules/registratura/components/registratura-module.tsx b/src/modules/registratura/components/registratura-module.tsx index 84f5d5e..39034b0 100644 --- a/src/modules/registratura/components/registratura-module.tsx +++ b/src/modules/registratura/components/registratura-module.tsx @@ -70,9 +70,11 @@ export function RegistraturaModule() { const [viewMode, setViewMode] = useState("list"); const [editingEntry, setEditingEntry] = useState(null); const [viewingEntry, setViewingEntry] = useState(null); - /** Entry to reply to (conex) — pre-sets threadParentId in new form */ + /** Entry to reply to (Inchide flow) — pre-sets threadParentId + flips direction */ const [replyToEntry, setReplyToEntry] = useState(null); - /** If set, the parent entry will be closed after saving the new conex entry */ + /** Entry to link as conex (Conex flow) — adds to linkedEntryIds, keeps direction */ + const [conexToEntry, setConexToEntry] = useState(null); + /** If set, the parent entry will be closed after saving the new reply entry */ const [closesEntryId, setClosesEntryId] = useState(null); const [closingId, setClosingId] = useState(null); const [linkCheckId, setLinkCheckId] = useState(null); @@ -160,6 +162,7 @@ export function RegistraturaModule() { setClosesEntryId(null); } setReplyToEntry(null); + setConexToEntry(null); setViewMode("list"); }; @@ -176,17 +179,20 @@ export function RegistraturaModule() { setViewingEntry(full ?? entry); }; - const handleReply = (entry: RegistryEntry) => { - setReplyToEntry(entry); + /** Conex: create a new entry linked to this one (clarificari, solicitari) */ + const handleConex = (entry: RegistryEntry) => { + setConexToEntry(entry); + setReplyToEntry(null); setClosesEntryId(null); setViewingEntry(null); setEditingEntry(null); setViewMode("add"); }; - /** Close entry via conex: create reply entry that closes the parent */ - const handleCloseViaConex = (entry: RegistryEntry) => { + /** Inchide: create a reply entry (raspuns la) that closes the parent */ + const handleCloseViaReply = (entry: RegistryEntry) => { setReplyToEntry(entry); + setConexToEntry(null); setClosesEntryId(entry.id); setViewingEntry(null); setEditingEntry(null); @@ -248,6 +254,7 @@ export function RegistraturaModule() { setViewMode("list"); setEditingEntry(null); setReplyToEntry(null); + setConexToEntry(null); setClosesEntryId(null); }; @@ -426,8 +433,8 @@ export function RegistraturaModule() { onView={handleView} onEdit={handleEdit} onDelete={handleDelete} - onClose={handleCloseViaConex} - onReply={handleReply} + onClose={handleCloseViaReply} + onReply={handleConex} /> {!loading && ( @@ -444,7 +451,7 @@ export function RegistraturaModule() { {replyToEntry ? ( <> - Conex la {replyToEntry.number} + Raspuns la {replyToEntry.number} Raspuns @@ -454,6 +461,13 @@ export function RegistraturaModule() { )} + ) : conexToEntry ? ( + <> + Conex cu {conexToEntry.number} + + Clarificare + + ) : ( <> Inregistrare noua @@ -468,6 +482,7 @@ export function RegistraturaModule() { diff --git a/src/modules/registratura/components/registry-entry-form.tsx b/src/modules/registratura/components/registry-entry-form.tsx index 9310ad4..31fdb30 100644 --- a/src/modules/registratura/components/registry-entry-form.tsx +++ b/src/modules/registratura/components/registry-entry-form.tsx @@ -87,8 +87,10 @@ import { getDeadlineType } from "../services/deadline-catalog"; interface RegistryEntryFormProps { initial?: RegistryEntry; - /** Pre-fill as reply (conex) to this entry — sets threadParentId, flips direction */ + /** Pre-fill as reply to this entry — sets threadParentId, flips direction (used by "Inchide") */ replyTo?: RegistryEntry; + /** Pre-fill as related/conex entry — adds to linkedEntryIds, keeps direction (used by "Conex") */ + conexTo?: RegistryEntry; allEntries?: RegistryEntry[]; onSubmit: ( data: Omit, @@ -109,6 +111,7 @@ interface RegistryEntryFormProps { export function RegistryEntryForm({ initial, replyTo, + conexTo, allEntries, onSubmit, onCancel, @@ -193,7 +196,7 @@ export function RegistryEntryForm({ ); const [notes, setNotes] = useState(initial?.notes ?? ""); const [linkedEntryIds, setLinkedEntryIds] = useState( - initial?.linkedEntryIds ?? [], + initial?.linkedEntryIds ?? (conexTo ? [conexTo.id] : []), ); const [attachments, setAttachments] = useState( initial?.attachments ?? [], @@ -557,7 +560,7 @@ export function RegistryEntryForm({ deadline: deadline || undefined, assignee: assignee || undefined, assigneeContactId: assigneeContactId || undefined, - threadParentId: threadParentId || undefined, + threadParentId: threadParentId || "", recipientRegNumber: recipientRegNumber || undefined, recipientRegDate: recipientRegDate || undefined, expiryDate: expiryDate || undefined, diff --git a/src/modules/registratura/components/registry-table.tsx b/src/modules/registratura/components/registry-table.tsx index 59ef1da..0dc42b8 100644 --- a/src/modules/registratura/components/registry-table.tsx +++ b/src/modules/registratura/components/registry-table.tsx @@ -483,7 +483,7 @@ export function RegistryTable({ e.stopPropagation(); onReply(entry); }} - title="Conex — creeaza raspuns" + title="Conex — clarificare / solicitare" >