This commit is contained in:
2025-11-02 00:35:32 +01:00
parent 49998fa23d
commit 09430c6f40
6 changed files with 867 additions and 782 deletions
+38
View File
@@ -0,0 +1,38 @@
export const resolveCorrespondents = (doc) => {
if (!doc || !Array.isArray(doc.correspondents)) {
return [];
}
const seen = new Set();
const results = [];
doc.correspondents.forEach((entry, index) => {
if (!entry || typeof entry.name !== 'string') {
return;
}
const id = entry.id;
const name = entry.name.trim();
if (!name) {
return;
}
if (id && seen.has(id)) {
return;
}
if (id) {
seen.add(id);
}
results.push({
id,
name,
key: id ?? `${name}-${index}`,
});
});
return results;
};
export default resolveCorrespondents;