fix: differentiate Conex (linkedEntryIds) vs Inchide (threadParentId) semantics
- Conex button now adds to linkedEntryIds (for clarificari/solicitari) instead of setting threadParentId - Inchide button sets threadParentId (direct reply) + auto-closes parent - Fix Sterge button persistence bug: threadParentId now saves as empty string instead of undefined (which was stripped in JSON serialization) - Card headers: "Conex cu X" (amber) vs "Raspuns la X" (blue + green) - Add conexTo prop to RegistryEntryForm for linked entry pre-fill Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -70,9 +70,11 @@ export function RegistraturaModule() {
|
||||
const [viewMode, setViewMode] = useState<ViewMode>("list");
|
||||
const [editingEntry, setEditingEntry] = useState<RegistryEntry | null>(null);
|
||||
const [viewingEntry, setViewingEntry] = useState<RegistryEntry | null>(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<RegistryEntry | null>(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<RegistryEntry | null>(null);
|
||||
/** If set, the parent entry will be closed after saving the new reply entry */
|
||||
const [closesEntryId, setClosesEntryId] = useState<string | null>(null);
|
||||
const [closingId, setClosingId] = useState<string | null>(null);
|
||||
const [linkCheckId, setLinkCheckId] = useState<string | null>(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() {
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
{replyToEntry ? (
|
||||
<>
|
||||
Conex la {replyToEntry.number}
|
||||
Raspuns la {replyToEntry.number}
|
||||
<Badge variant="outline" className="text-xs text-blue-600 border-blue-300">
|
||||
Raspuns
|
||||
</Badge>
|
||||
@@ -454,6 +461,13 @@ export function RegistraturaModule() {
|
||||
</Badge>
|
||||
)}
|
||||
</>
|
||||
) : conexToEntry ? (
|
||||
<>
|
||||
Conex cu {conexToEntry.number}
|
||||
<Badge variant="outline" className="text-xs text-amber-600 border-amber-300">
|
||||
Clarificare
|
||||
</Badge>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
Inregistrare noua
|
||||
@@ -468,6 +482,7 @@ export function RegistraturaModule() {
|
||||
<RegistryEntryForm
|
||||
allEntries={allEntries}
|
||||
replyTo={replyToEntry ?? undefined}
|
||||
conexTo={conexToEntry ?? undefined}
|
||||
onSubmit={handleAdd}
|
||||
onCancel={handleCancel}
|
||||
onCreateContact={handleCreateContact}
|
||||
@@ -504,9 +519,9 @@ export function RegistraturaModule() {
|
||||
if (!open) setViewingEntry(null);
|
||||
}}
|
||||
onEdit={handleEdit}
|
||||
onClose={handleCloseViaConex}
|
||||
onClose={handleCloseViaReply}
|
||||
onDelete={handleDelete}
|
||||
onReply={handleReply}
|
||||
onReply={handleConex}
|
||||
allEntries={allEntries}
|
||||
/>
|
||||
|
||||
|
||||
@@ -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<RegistryEntry, "id" | "number" | "createdAt" | "updatedAt">,
|
||||
@@ -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<string[]>(
|
||||
initial?.linkedEntryIds ?? [],
|
||||
initial?.linkedEntryIds ?? (conexTo ? [conexTo.id] : []),
|
||||
);
|
||||
const [attachments, setAttachments] = useState<RegistryAttachment[]>(
|
||||
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,
|
||||
|
||||
@@ -483,7 +483,7 @@ export function RegistryTable({
|
||||
e.stopPropagation();
|
||||
onReply(entry);
|
||||
}}
|
||||
title="Conex — creeaza raspuns"
|
||||
title="Conex — clarificare / solicitare"
|
||||
>
|
||||
<Reply className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user