diff --git a/public/logos/product.png b/public/logos/product.png new file mode 100644 index 0000000..3435d17 Binary files /dev/null and b/public/logos/product.png differ diff --git a/src/assets/product.png b/src/assets/product.png new file mode 100644 index 0000000..3435d17 Binary files /dev/null and b/src/assets/product.png differ diff --git a/src/features/cart/lib/api.ts b/src/features/cart/lib/api.ts index 9dbc5c7..18938b6 100644 --- a/src/features/cart/lib/api.ts +++ b/src/features/cart/lib/api.ts @@ -5,25 +5,71 @@ import { AxiosResponse } from 'axios'; interface CartItem { id: string; cart_item: { - id: string; - product_name: string; - product_id: string; - product_image: string; + id: number; + product: { + id: number; + images: { + id: number; + image: string; + }[]; + liked: boolean; + meansurement: null | string; + inventory_id: null | string; + product_id: string; + code: string; + name: string; + short_name: string; + weight_netto: null | string; + weight_brutto: null | string; + litr: null | string; + box_type_code: null | string; + box_quant: null | string; + groups: number[]; + state: 'A' | 'P'; + barcodes: string | null; + article_code: null | string; + marketing_group_code: null | string; + inventory_kinds: { id: number; name: string }[]; + sector_codes: { id: number; code: string }[]; + prices: { + id: number; + price: string; + price_type: { + id: number; + name: string; + code: string; + }; + }[]; + }; quantity: number; - product_price: number; }[]; } export interface OrderCreateBody { - items: { - product_id: number; - quantity: number; + order: { + filial_code: string; + delivery_date: string; + room_code: string; + robot_code: string; + deal_time: string; + status: string; + sales_manager_code: string; + person_code: string; + currency_code: string; + owner_person_code: string; + note: string; + order_products: [ + { + inventory_kind: string; + product_code: string; + on_balance: string; + order_quant: number; + price_type_code: string; + product_price: string; + warehouse_code: string; + }, + ]; }[]; - comment: string; - long: number; - lat: number; - date: string; - time: string; } export const cart_api = { diff --git a/src/features/cart/ui/CartPage.tsx b/src/features/cart/ui/CartPage.tsx index 12e0c46..902bf3a 100644 --- a/src/features/cart/ui/CartPage.tsx +++ b/src/features/cart/ui/CartPage.tsx @@ -21,6 +21,7 @@ import { useTranslations } from 'next-intl'; import Image from 'next/image'; import { useEffect, useRef, useState } from 'react'; import { toast } from 'sonner'; +import ProductBanner from '@/assets/product.png'; const CartPage = () => { const { cart_id } = useCartId(); @@ -102,7 +103,10 @@ const CartPage = () => { ); const subtotal = cartItems.reduce( - (sum, item) => sum + item.product_price * Number(item.quantity), + (sum, item) => + sum + + Math.max(...item.product.prices.map((e) => Number(e.price))) * + Number(item.quantity), 0, ); @@ -145,7 +149,9 @@ const CartPage = () => {