export const handleQuantity = (sku, quantity, mutator) => {
  return mutator(state => {
    return state.filter((product: any) => {
      if (product.sku === sku) {
        // Get new quantity
        const updatedQuantity = (product.quantity += quantity)

        // If quantity is above 0
        if (updatedQuantity > 0) {
          return {
            ...product,
            quantity: updatedQuantity
          }
        } else {
          // If its not..
          return null
        }
      } else {
        return product
      }
    })
  })
}
