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

Fix adding & removing children & parents

parent 109a3580
No related branches found
No related tags found
No related merge requests found
Pipeline #18297 passed
......@@ -122,16 +122,13 @@
async function addPerson(id: string, isChild: boolean): Promise<void> {
const entity = entityByKey[personEntityKey]
const personById = {
...situation[entity.key_plural],
}
const personById = situation[entity.key_plural]
const person = (personById[id] = {} as PopulationWithoutId)
if (isChild) {
person.date_naissance = {
[year]: new Date(year - 10, 6, 2).toISOString().split("T")[0],
}
}
situation = { ...situation, [entity.key_plural]: personById }
for (const groupEntity of Object.values(entityByKey) as GroupEntity[]) {
if (groupEntity.is_person) {
......@@ -472,18 +469,12 @@
let personById = $derived(
Object.fromEntries(persons.map((person) => [person.id, person])),
)
let adultsId
run(() => {
adultsId = [
let adultsId = $state([
...Object.keys(personById).filter((id) => id.startsWith("Adulte ")),
]
})
let childrenId
run(() => {
childrenId = [
])
let childrenId = $state([
...Object.keys(personById).filter((id) => id.startsWith("Enfant ")),
]
})
])
let adultSituations = $derived(
Object.entries(situation[personEntity.key_plural] ?? {})
.filter(([id]) => id.startsWith("Adulte "))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment