690329:2252 Fixing refactor Correspondence GPT-5.3-Codex #05
This commit is contained in:
@@ -25,6 +25,15 @@ interface CorrespondenceDetailProps {
|
||||
selectedRevisionId?: string;
|
||||
}
|
||||
|
||||
const normalizeUuid = (value?: string): string | undefined => {
|
||||
if (typeof value !== 'string') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const normalized = value.trim().toLowerCase();
|
||||
return normalized.length > 0 ? normalized : undefined;
|
||||
};
|
||||
|
||||
export function CorrespondenceDetail({ data, selectedRevisionId }: CorrespondenceDetailProps) {
|
||||
const submitMutation = useSubmitCorrespondence();
|
||||
const processMutation = useProcessWorkflow();
|
||||
@@ -36,8 +45,9 @@ export function CorrespondenceDetail({ data, selectedRevisionId }: Correspondenc
|
||||
|
||||
if (!data) return <div>No data found</div>;
|
||||
|
||||
const selectedRevision = selectedRevisionId
|
||||
? data.revisions?.find((r) => r.publicId === selectedRevisionId)
|
||||
const normalizedSelectedRevisionId = normalizeUuid(selectedRevisionId);
|
||||
const selectedRevision = normalizedSelectedRevisionId
|
||||
? data.revisions?.find((r) => normalizeUuid(r.publicId) === normalizedSelectedRevisionId)
|
||||
: undefined;
|
||||
const currentRevision = selectedRevision || data.revisions?.find((r) => r.isCurrent) || data.revisions?.[0];
|
||||
const subject = currentRevision?.subject || '-';
|
||||
|
||||
@@ -125,6 +125,11 @@ const normalizePublicId = (value: unknown): string | undefined => {
|
||||
return trimmed.length > 0 ? trimmed : undefined;
|
||||
};
|
||||
|
||||
const normalizeUuid = (value: unknown): string | undefined => {
|
||||
const normalized = normalizePublicId(value);
|
||||
return normalized ? normalized.toLowerCase() : undefined;
|
||||
};
|
||||
|
||||
export function CorrespondenceForm({
|
||||
initialData,
|
||||
uuid,
|
||||
@@ -147,8 +152,9 @@ export function CorrespondenceForm({
|
||||
const correspondenceTypes = extractArrayData<CorrespondenceTypeOption>(correspondenceTypesData);
|
||||
|
||||
// Extract initial values if editing
|
||||
const selectedRevision = selectedRevisionId
|
||||
? initialData?.revisions?.find((r) => normalizePublicId(r.publicId) === selectedRevisionId)
|
||||
const normalizedSelectedRevisionId = normalizeUuid(selectedRevisionId);
|
||||
const selectedRevision = normalizedSelectedRevisionId
|
||||
? initialData?.revisions?.find((r) => normalizeUuid(r.publicId) === normalizedSelectedRevisionId)
|
||||
: undefined;
|
||||
const currentRev = selectedRevision || initialData?.revisions?.find((r) => r.isCurrent) || initialData?.revisions?.[0];
|
||||
const initialToRecipient = initialData?.recipients?.find((r) => r.recipientType === 'TO');
|
||||
|
||||
Reference in New Issue
Block a user