From b4bc3297cbed065e67d2f2d27bdf60afb71d6ef5 Mon Sep 17 00:00:00 2001 From: Matheus Reis <35343551+matheusgnreis@users.noreply.github.com> Date: Mon, 10 Jun 2024 00:48:49 -0300 Subject: [PATCH] chore: send shipped when collected --- functions/lib/integration/update-tracking.js | 48 +++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/functions/lib/integration/update-tracking.js b/functions/lib/integration/update-tracking.js index a0c4bd2..0618439 100644 --- a/functions/lib/integration/update-tracking.js +++ b/functions/lib/integration/update-tracking.js @@ -6,27 +6,31 @@ const getAppData = require('../store-api/get-app-data') const ecomUtils = require('@ecomplus/utils') const sendTag = require('./send-tag') -const parseStatus = (id) => { - switch (id) { - case '1': - return 'delivered' - break; - case '101': - case '110': - case '31': - case '33': - case '118': - case '160': - case '122': - case '123': - case '124': - case '119': - case '120': - case '0': - case '121': - return 'shipped' - break; - } + +const parseStatus = (id, name) => { + switch (id) { + case '1': + return 'delivered' + break; + case '101': + case '110': + case '31': + case '33': + case '118': + case '160': + case '122': + case '123': + case '124': + case '119': + case '120': + case '0': + case '121': + return 'shipped' + break; + } + if (name === 'Encomenda coletada') { + return 'shipped' + } } const listStoreIds = () => { @@ -90,7 +94,7 @@ const fetchTracking = ({ appSdk, storeId }) => { && resultTracking.data.events[0]; if (tracking && tracking.id) { - const status = parseStatus(tracking.id) + const status = parseStatus(tracking.id, tracking.name) let indexTracking if (metafields && metafields.length) {