Skip to content
Snippets Groups Projects
Commit 1b9c92a7 authored by Emmanuel Raviart's avatar Emmanuel Raviart
Browse files

Ensure that entity situation id is unique.

parent a593226c
No related branches found
No related tags found
No related merge requests found
......@@ -43,9 +43,13 @@
const entitySituationById = {
...situation[entity.key_plural],
}
const entitySituationId = `${entity.label ?? entity.key} ${
Object.keys(entitySituationById).length + 1
}`
let entitySituationId: string
for (let i = Object.keys(entitySituationById).length + 1; ; i++) {
entitySituationId = `${entity.label ?? entity.key} ${i}`
if (entitySituationById[entitySituationId] === undefined) {
break
}
}
entitySituationById[entitySituationId] = {}
situation = { ...situation, [entity.key_plural]: entitySituationById }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment