import { produce } from 'immer' export default function setDeliveryTypeMenuPrice (item: IAppMenuItem, deliveryType: TDeliveryType): IAppMenuItem { return produce(item, (item) => { if (deliveryType === 'table') { return } if (deliveryType === 'storeDelivery') { deliveryType = 'takeaway' } const deliveryTypePrice = item.prices?.find(price => price.type === deliveryType) if (deliveryTypePrice != null) { item.price = deliveryTypePrice.price item.discount = deliveryTypePrice.discount item.priceUndetermined = false return } if (item.priceUndetermined) { item.takeawayDisabled = true } }) }