const isSelfDelivery = await selfDeliveryService.merchantHasSelfDelivery(warehouse.merchantId); const zeroMileTerminalGeoId = getZeroMileTerminalGeoId(pickupRegion); const zeroMile = zeroMileTerminalGeoId ? { terminalGeoId: zeroMileTerminalGeoId, carrierCode: getZeromileCarrierCode(pickupRegion, zeroMileTerminalGeoId) } : null; } const terminalGeoId = zeroMile ? zeroMile.terminalGeoId : warehouse.geoId;
The above code checks whether the merchant has self delivery and if it does, it returns the first terminalGeoId (which is the geoId of the warehouse) else, it checks if there is a zero mile terminal and if it is, it returns the terminalGeoId of the zero mile terminal else it returns the geoId of the warehouse.