From 3b2fdce975e02674fb72c0f7384751b3a4cdf7f9 Mon Sep 17 00:00:00 2001
From: Hugo NOUTS <hnouts@grandlyon.com>
Date: Fri, 24 Feb 2023 09:18:12 +0000
Subject: [PATCH] fix(structureService): filter keys are cast to booleans no
 matter the case

---
 src/structures/services/structures.service.ts | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/structures/services/structures.service.ts b/src/structures/services/structures.service.ts
index ae063bcab..afe382adb 100644
--- a/src/structures/services/structures.service.ts
+++ b/src/structures/services/structures.service.ts
@@ -208,13 +208,14 @@ export class StructuresService {
    * Parse filter value from string to boolean and map filter category to categories key
    * @param filters
    */
-  private parseFilter(filters: Array<any>): Array<any> {
+  private parseFilter(filters: Array<{ [key: string]: unknown }>): Array<{ [key: string]: unknown }> {
     return filters.map((filter) => {
-      const key = Object.keys(filter)[0];
-      if (filter[key] === 'True') {
+      const [key, value] = Object.entries(filter)[0];
+
+      if (typeof value === 'string' && value.toLowerCase() === 'true') {
         return { [key]: true };
       } else {
-        return { [`categories.${key}`]: filter[key] };
+        return { [`categories.${key}`]: value };
       }
     });
   }
-- 
GitLab