From 105ed84fcabddf15e2e343b4c89033c2f793af9f Mon Sep 17 00:00:00 2001 From: Jamal Soueidan Date: Thu, 30 May 2024 04:09:17 +0200 Subject: [PATCH] Refactor tag assignment to exclude home and salon when destination exists --- .../customer/update/update-article.ts | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/functions/customer/orchestrations/customer/update/update-article.ts b/src/functions/customer/orchestrations/customer/update/update-article.ts index bb85ce12..c31caf90 100644 --- a/src/functions/customer/orchestrations/customer/update/update-article.ts +++ b/src/functions/customer/orchestrations/customer/update/update-article.ts @@ -55,19 +55,20 @@ export const updateArticle = async ({ ); if (destination) { tags.push("location-destination"); - } - const originTypeHome = locations.find( - (l) => l.originType === LocationOriginTypes.HOME - ); - if (originTypeHome) { - tags.push("location-home"); - } - - const originTypeSalon = locations.find( - (l) => l.originType === LocationOriginTypes.COMMERCIAL - ); - if (originTypeSalon) { - tags.push("location-salon"); + } else { + const originTypeHome = locations.find( + (l) => l.originType === LocationOriginTypes.HOME + ); + if (originTypeHome) { + tags.push("location-home"); + } + + const originTypeSalon = locations.find( + (l) => l.originType === LocationOriginTypes.COMMERCIAL + ); + if (originTypeSalon) { + tags.push("location-salon"); + } } }