refactor: improve document duplication handling

- Remove unnecessary console logs
- Add null check before duplicating document to evaluation within another social work
This commit is contained in:
2025-08-25 14:57:48 +02:00
parent 4d90c7028f
commit 9d58904969

View File

@@ -298,9 +298,6 @@ const store = createStore({
);
},
addDuplicatedDocument(state, { document, evaluation_key }) {
console.log("add duplicated document", document);
console.log("add duplicated dcuemnt - evaluation key", evaluation_key);
let evaluation = state.evaluationsPicked.find(
(e) => e.key === evaluation_key,
);
@@ -311,8 +308,11 @@ const store = createStore({
let evaluationDest = state.evaluationsPicked.find(
(e) => e.id === evaluation.id,
);
document.key = evaluationDest.documents.length + 1;
evaluationDest.documents.splice(0, 0, document);
if (evaluationDest) {
console.log("add duplicated document to evaluation", evaluationDest);
document.key = evaluationDest.documents.length + 1;
evaluationDest.documents.splice(0, 0, document);
}
},
/**
* Replaces a document in the state with a new document.