From ab2fd6bdeb3932013e8ae2cf764d1cd514dc7495 Mon Sep 17 00:00:00 2001 From: Ezequiel Ramos Date: Wed, 24 Apr 2024 15:26:06 -0300 Subject: [PATCH] feature/addingActivePropOnCardHumans --- src/controllers/humans.ts | 12 ++++++------ src/routes/cards.ts | 7 ++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/controllers/humans.ts b/src/controllers/humans.ts index e367c27..05a36bf 100644 --- a/src/controllers/humans.ts +++ b/src/controllers/humans.ts @@ -9,26 +9,26 @@ interface Human { name: string; comment: string; watch_lists: number[]; - meta: { [key: string]: unknown }; + meta: { [key: string]: unknown; }; active_after: null; active_before: null; - disable_schedule: { [key: string]: unknown }; + disable_schedule: { [key: string]: unknown; }; recount_schedule_on: null; face_objects: number; body_objects: number; face_cluster: number | null; body_cluster: number | null; - links_to_relations: { id: number, name: string, created_date: Date, card: number, relation: number }[]; + links_to_relations: { id: number, name: string, created_date: Date, card: number, relation: number; }[]; } let humanId = 0; -const humans: { [humanId: number]: Human | undefined } = {}; +const humans: { [humanId: number]: Human | undefined; } = {}; -function createHuman({ name }: { name: string }) { +function createHuman({ name, active }: { name: string; active: boolean; }) { humanId++; const human: Human = { "id": humanId, - "active": true, + "active": active, "filled": true, "created_date": new Date(), "modified_date": new Date(), diff --git a/src/routes/cards.ts b/src/routes/cards.ts index ab24f2b..8f40471 100644 --- a/src/routes/cards.ts +++ b/src/routes/cards.ts @@ -62,7 +62,8 @@ function loadCardRoutes(app: Express) { } const human = createHuman({ - name: req.body.name + name: req.body.name, + active: req.body.active ?? true }); return res.status(200).json(human); @@ -85,6 +86,10 @@ function loadCardRoutes(app: Express) { human.name = req.body.name; } + if (req.body.active) { + human.active = req.body.active; + } + return res.status(200).json(human); });