From 42e5966e32c10f2b9ea6944b33d7f0fe49cf0b58 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Sun, 7 Sep 2025 11:28:45 +0330 Subject: [PATCH] base information --- public/images/tick.svg | 3 + src/app/globals.css | 4 + .../product/components/BaseInformation.tsx | 100 +++++++++++++++--- src/config/const.ts | 4 +- src/types/product.types.ts | 15 ++- 5 files changed, 107 insertions(+), 19 deletions(-) create mode 100644 public/images/tick.svg diff --git a/public/images/tick.svg b/public/images/tick.svg new file mode 100644 index 0000000..563f4a5 --- /dev/null +++ b/public/images/tick.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/app/globals.css b/src/app/globals.css index 336fda5..fe3a65e 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -240,3 +240,7 @@ textarea.place-black::placeholder { .dltr { direction: ltr; } + +.filterBlack { + filter: brightness(0) saturate(100%); +} diff --git a/src/app/product/components/BaseInformation.tsx b/src/app/product/components/BaseInformation.tsx index 3b72df1..9ad2505 100644 --- a/src/app/product/components/BaseInformation.tsx +++ b/src/app/product/components/BaseInformation.tsx @@ -1,16 +1,27 @@ 'use client' import { Star1 } from 'iconsax-react' -import { FC } from 'react' +import { FC, useState } from 'react' import { Product } from '@/types/product.types' +import Image from 'next/image' +import { clx } from '@/helpers/utils' interface BaseInformationProps { product: Product } const BaseInformation: FC = ({ product }) => { - const defaultVariant = product.default_variant const brand = product.brand - const size = defaultVariant.size + + // State برای انتخاب variant ها + const [selectedSize, setSelectedSize] = useState( + product.variants.find(v => v.size)?.size?._id?.toString() || null + ) + const [selectedColor, setSelectedColor] = useState( + product.variants.find(v => v.color)?.color?._id?.toString() || null + ) + const [selectedMeterage, setSelectedMeterage] = useState( + product.variants.find(v => v.meterage)?.meterage?._id?.toString() || null + ) return (
@@ -37,20 +48,77 @@ const BaseInformation: FC = ({ product }) => {
-
- اندازه : {size.value} -
+ {/* نمایش variant ها */} +
+ {/* متراژ */} +
+ {product.variants.map((variant) => { + if (variant.meterage) { + const isSelected = selectedMeterage === variant.meterage._id.toString() + return ( + + ) + } + return null + })} +
-
- {product.variants.map((variant, index) => ( -
- {index + 1} -
- ))} + {/* رنگ ها */} +
+ {product.variants.map((variant) => { + if (variant.color) { + const isSelected = selectedColor === variant.color._id.toString() + return ( + + ) + } + return null + })} +
+ + {/* سایزها */} +
+ {product.variants.map((variant) => { + if (variant.size) { + const isSelected = selectedSize === variant.size._id.toString() + return ( + + ) + } + return null + })} +
diff --git a/src/config/const.ts b/src/config/const.ts index b8dc482..97d0d5c 100644 --- a/src/config/const.ts +++ b/src/config/const.ts @@ -1,6 +1,6 @@ export const TOKEN_NAME = "sh_token"; export const REFRESH_TOKEN_NAME = "sh_refresh_token"; -export const BASE_URL = "https://api.shinan.ir"; -// export const BASE_URL = "https://api-sondos.run.danakcorp.com"; +// export const BASE_URL = "https://api.shinan.ir"; +export const BASE_URL = "https://api-sondos.run.danakcorp.com"; export const PRIMARY_COLOR = "#015699"; diff --git a/src/types/product.types.ts b/src/types/product.types.ts index f3e73de..23d4bab 100644 --- a/src/types/product.types.ts +++ b/src/types/product.types.ts @@ -14,6 +14,17 @@ export interface ProductSize { value: string; } +export interface ProductColor { + _id: number; + value: string; + hexColor?: string; +} + +export interface ProductMeterage { + _id: number; + value: string; +} + export interface ProductWarranty { _id: number; duration: string; @@ -52,7 +63,9 @@ export interface ProductVariant { shop: ProductShop; shipmentMethod: ShipmentMethod[]; warranty: ProductWarranty; - size: ProductSize; + size?: ProductSize; + color?: ProductColor; + meterage?: ProductMeterage; } export interface ProductBrand {