From 5812151b629fde2398ee04c4e060ae5239c88185 Mon Sep 17 00:00:00 2001 From: dudwns0213 Date: Sun, 2 Jun 2024 21:49:57 +0900 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8Frefactor:=20Itemcard,=20ItemC?= =?UTF-8?q?omments=20jsx->tsx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/{ItemComments.jsx => ItemComments.tsx} | 9 +++++---- .../MarketPage/components/{ItemCard.jsx => ItemCard.tsx} | 9 ++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) rename src/pages/ItemDetailPage/components/{ItemComments.jsx => ItemComments.tsx} (87%) rename src/pages/MarketPage/components/{ItemCard.jsx => ItemCard.tsx} (79%) diff --git a/src/pages/ItemDetailPage/components/ItemComments.jsx b/src/pages/ItemDetailPage/components/ItemComments.tsx similarity index 87% rename from src/pages/ItemDetailPage/components/ItemComments.jsx rename to src/pages/ItemDetailPage/components/ItemComments.tsx index 0a550a674..fa0c75f0d 100644 --- a/src/pages/ItemDetailPage/components/ItemComments.jsx +++ b/src/pages/ItemDetailPage/components/ItemComments.tsx @@ -1,11 +1,12 @@ import React, { useEffect, useState } from "react"; import { useParams } from "react-router-dom"; import { getProductCommentsById } from "../../../api/itemApi"; -import NoneCommentsImg from "../../../assets/images/img_nonecomment.png"; +import NoneCommentsImg from "../../../assets/images/icons/img_nonecomment.svg"; +import { Comment } from "../../../types/Items"; function ItemComments() { const { itemId } = useParams(); - const [comments, setCommnets] = useState(); + const [comments, setCommnets] = useState(); const fetch = async () => { try { @@ -16,8 +17,8 @@ function ItemComments() { } }; - function formatTime(time) { - const elapsed = (new Date() - new Date(time)) / 1000; + function formatTime(time: Date) { + const elapsed = (new Date().getTime() - new Date(time).getTime()) / 1000; const intervals = { 일: 86400, diff --git a/src/pages/MarketPage/components/ItemCard.jsx b/src/pages/MarketPage/components/ItemCard.tsx similarity index 79% rename from src/pages/MarketPage/components/ItemCard.jsx rename to src/pages/MarketPage/components/ItemCard.tsx index 226c06baa..b5485d83e 100644 --- a/src/pages/MarketPage/components/ItemCard.jsx +++ b/src/pages/MarketPage/components/ItemCard.tsx @@ -1,7 +1,14 @@ import React from "react"; import { ReactComponent as HeartIcon } from "../../../assets/images/icons/ic_heart.svg"; -function ItemCard({ item }) { +interface Item { + images: string[]; + name: string; + favoriteCount: number; + price: number; +} + +function ItemCard({ item }: { item: Item }) { return (
{item.name}