From f09d5f8d946a1ce31b8cb572f60686b42ff7cd27 Mon Sep 17 00:00:00 2001 From: gimdogyun Date: Wed, 20 Nov 2024 16:38:27 +0900 Subject: [PATCH] feat: product link - #147 --- .../SchedulePage/BestScheduleSection.tsx | 1 - .../features/SchedulePage/ScheduleCard.tsx | 6 +++--- .../features/StorePage/ProductCard.tsx | 10 +++++----- .../StorePage/ProductList/ProductsView.tsx | 8 +++++++- src/pages/SchedulePage/index.tsx | 12 ++++++++++-- src/pages/SellerPage/SellerProductList.tsx | 18 ++++++++++-------- 6 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/components/features/SchedulePage/BestScheduleSection.tsx b/src/components/features/SchedulePage/BestScheduleSection.tsx index 2240eb6..f81be3e 100644 --- a/src/components/features/SchedulePage/BestScheduleSection.tsx +++ b/src/components/features/SchedulePage/BestScheduleSection.tsx @@ -11,7 +11,6 @@ const BestScheduleSection = () => ( ({ ...item, - disabled: true, }))} columns={2} gap="20px" diff --git a/src/components/features/SchedulePage/ScheduleCard.tsx b/src/components/features/SchedulePage/ScheduleCard.tsx index cdd7a54..18611fb 100644 --- a/src/components/features/SchedulePage/ScheduleCard.tsx +++ b/src/components/features/SchedulePage/ScheduleCard.tsx @@ -4,11 +4,11 @@ import ImageCard, { ImageCardProps } from "@components/common/ImageCard"; import { Schedule } from "@type/index"; type ScheduleCardProps = ImageCardProps & { - item: Schedule & { disabled?: boolean }; + item: Schedule & { link?: string }; }; const ScheduleCard = ({ item, ...props }: ScheduleCardProps) => ( - + ( }} bgImg={item.mainImage} _hover={ - !item?.disabled + item.link ? { transform: "scale(1.05)", } diff --git a/src/components/features/StorePage/ProductCard.tsx b/src/components/features/StorePage/ProductCard.tsx index 1f15241..115453c 100644 --- a/src/components/features/StorePage/ProductCard.tsx +++ b/src/components/features/StorePage/ProductCard.tsx @@ -1,17 +1,17 @@ import { Link } from "react-router-dom"; -import { Flex, Text } from "@chakra-ui/react"; +import { Box, Flex, Text } from "@chakra-ui/react"; import Avatar from "@components/common/Avatar"; import Card, { CardProps } from "@components/common/Card"; import Image from "@components/common/Image"; import { Product } from "@type/index"; export type ProductCardProps = { - item: Product; + item: Product & { link?: string }; } & CardProps; const ProductCard = ({ item, ...props }: ProductCardProps) => ( - - + + {item.name} @@ -34,7 +34,7 @@ const ProductCard = ({ item, ...props }: ProductCardProps) => ( {item.farm.name} - + ); export default ProductCard; diff --git a/src/components/features/StorePage/ProductList/ProductsView.tsx b/src/components/features/StorePage/ProductList/ProductsView.tsx index 1898017..7c17f47 100644 --- a/src/components/features/StorePage/ProductList/ProductsView.tsx +++ b/src/components/features/StorePage/ProductList/ProductsView.tsx @@ -10,7 +10,13 @@ type ProductsViewProps = { const ProductsView = ({ filters, ...props }: ProductsViewProps) => { const { data: products } = useGetProducts(filters[0] ? Number(filters[0]) : 0); - return ; + return ( + ({ ...p, link: `/store/${p.id}` }))} + ItemComponent={ProductCard} + {...props} + /> + ); }; export default ProductsView; diff --git a/src/pages/SchedulePage/index.tsx b/src/pages/SchedulePage/index.tsx index b1a88e1..ab3bd4b 100644 --- a/src/pages/SchedulePage/index.tsx +++ b/src/pages/SchedulePage/index.tsx @@ -6,7 +6,7 @@ import BestScheduleSection from "@components/features/SchedulePage/BestScheduleS import ScheduleCard from "@components/features/SchedulePage/ScheduleCard"; import ScheduleCategory from "@components/features/SchedulePage/ScheduleCategory"; import size from "@constants/size"; -import { FarmCategory } from "@type/index"; +import { FarmCategory, Schedule } from "@type/index"; const SchedulePage = () => { const [category, setCategory] = useState(null); @@ -24,7 +24,15 @@ const SchedulePage = () => { setCategory(ct)} /> - + ({ + ...s, + link: `/schedule/${s.id}`, + }))} + ItemComponent={ScheduleCard} + columns={3} + gap="10" + /> ); diff --git a/src/pages/SellerPage/SellerProductList.tsx b/src/pages/SellerPage/SellerProductList.tsx index 2d58f34..d8ca983 100644 --- a/src/pages/SellerPage/SellerProductList.tsx +++ b/src/pages/SellerPage/SellerProductList.tsx @@ -1,19 +1,21 @@ -import { useNavigate } from "react-router-dom"; import { Box } from "@chakra-ui/react"; import GridView from "@components/ItemView/GridView"; import Card from "@components/common/Card"; -import ProductCard, { ProductCardProps } from "@components/features/StorePage/ProductCard"; +import ProductCard from "@components/features/StorePage/ProductCard"; import mockProducts from "@mocks/mockItem/mockProducts"; -const EditProductCard = (props: ProductCardProps) => { - const navigate = useNavigate(); - return navigate(`/seller/product-edit/${props?.item.id}`)} />; -}; - const SellerProductListPage = () => ( - + ({ + ...p, + link: `/seller/product-edit/${p.id}`, + }))} + ItemComponent={ProductCard} + columns={3} + gap="10" + /> );