Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] feat: PB 상품 목록에서 상품 썸네일 삼김이로 변경 #818

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ProductDetailItem = ({ category, productDetail }: ProductDetailItemProps)
return (
<ProductDetailContainer>
<ImageWrapper>
{image !== null ? (
{image ? (
<img src={image} width={300} alt={name} />
) : category === CATEGORY_TYPE.FOOD ? (
<PreviewImage width={300} />
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/components/Product/ProductItem/ProductItem.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { Text, useTheme } from '@fun-eat/design-system';
import { memo, useState } from 'react';
import { useParams } from 'react-router-dom';
import styled from 'styled-components';

import PreviewImage from '@/assets/characters.svg';
import PBPreviewImage from '@/assets/samgakgimbab.svg';
import { Skeleton, SvgIcon } from '@/components/Common';
import { CATEGORY_TYPE } from '@/constants';
import type { Product } from '@/types/product';

interface ProductItemProps {
Expand All @@ -12,12 +15,17 @@ interface ProductItemProps {

const ProductItem = ({ product }: ProductItemProps) => {
const theme = useTheme();
const { category } = useParams();
const { name, price, image, averageRating, reviewCount } = product;
const [isImageLoading, setIsImageLoading] = useState(true);

if (!category) {
return null;
}

return (
<ProductItemContainer>
{image !== null ? (
{image ? (
<>
<ProductImage
src={image}
Expand All @@ -29,8 +37,10 @@ const ProductItem = ({ product }: ProductItemProps) => {
/>
{isImageLoading && <Skeleton width={90} height={90} />}
</>
) : (
) : category === CATEGORY_TYPE.FOOD ? (
<PreviewImage width={90} height={90} />
) : (
<PBPreviewImage width={90} height={90} />
)}
<ProductInfoWrapper>
<Text size="lg" weight="bold">
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/mocks/data/pbProducts.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"id": 5,
"name": "PB 버터링",
"price": 1000,
"image": "https://cdn.pixabay.com/photo/2016/03/23/15/00/ice-cream-1274894_1280.jpg",
"image": "",
"averageRating": 4.0,
"reviewCount": 100
},
Expand Down
Loading