From b5ba7b355708ae8b7bee74dbb2acf140e4bebe92 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 1 Jun 2024 20:58:08 -0300 Subject: [PATCH] Update - removendo limite de supplies na listagem de abrigos (#136) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Melhorar a descoberta de que existem mais itens depois que o limite de 10 é excedido no card Conforme solicitado na issue [#257](https://github.com/SOS-RS/frontend/issues/257) foi removido o limite no retorno dos supplies de abrigo. PR do Frontend: https://github.com/SOS-RS/frontend/pull/249 --- src/shelter/ShelterSearch.ts | 33 +++++++------------------------ src/shelter/types/search.types.ts | 2 +- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/src/shelter/ShelterSearch.ts b/src/shelter/ShelterSearch.ts index d921dbf..3434413 100644 --- a/src/shelter/ShelterSearch.ts +++ b/src/shelter/ShelterSearch.ts @@ -12,9 +12,9 @@ import { } from './types/search.types'; const defaultTagsData: ShelterTagInfo = { - NeedDonations: 10, - NeedVolunteers: 10, - RemainingSupplies: 10, + NeedDonations: true, + NeedVolunteers: true, + RemainingSupplies: true, }; class ShelterSearch { @@ -204,27 +204,17 @@ function parseTagResponse( }; const parsed = results.map((result) => { - const qtd: Required = { - NeedDonations: 0, - NeedVolunteers: 0, - RemainingSupplies: 0, - }; return { ...result, shelterSupplies: result.shelterSupplies.reduce((prev, shelterSupply) => { const supplyTags: ShelterTagType[] = []; - let tagged: boolean = false; if ( tags.NeedDonations && [SupplyPriority.Needing, SupplyPriority.Urgent].includes( shelterSupply.priority, ) ) { - if (qtd.NeedDonations < tags.NeedDonations) { - qtd.NeedDonations++; - tagged = true; - supplyTags.push('NeedDonations'); - } + supplyTags.push('NeedDonations'); } if ( tags.NeedVolunteers && @@ -233,24 +223,15 @@ function parseTagResponse( shelterSupply.priority, ) ) { - if (qtd.NeedVolunteers < tags.NeedVolunteers) { - qtd.NeedVolunteers++; - tagged = true; - supplyTags.push('NeedVolunteers'); - } + supplyTags.push('NeedVolunteers'); } if ( tags.RemainingSupplies && [SupplyPriority.Remaining].includes(shelterSupply.priority) ) { - if (qtd.RemainingSupplies < tags.RemainingSupplies) { - qtd.RemainingSupplies++; - tagged = true; - supplyTags.push('RemainingSupplies'); - } + supplyTags.push('RemainingSupplies'); } - if (tagged) return [...prev, { ...shelterSupply, tags: supplyTags }]; - else return prev; + return [...prev, { ...shelterSupply, tags: supplyTags }]; }, [] as any), }; }); diff --git a/src/shelter/types/search.types.ts b/src/shelter/types/search.types.ts index ab5e6a1..1e5f273 100644 --- a/src/shelter/types/search.types.ts +++ b/src/shelter/types/search.types.ts @@ -14,7 +14,7 @@ const ShelterTagTypeSchema = z.enum([ const ShelterTagInfoSchema = z.record( ShelterTagTypeSchema, - z.number().optional(), + z.boolean().optional(), ); export type ShelterTagType = z.infer;