Skip to content

Commit

Permalink
♻️refactor: Itemcard, ItemComments jsx->tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
dudwns0213 committed Jun 2, 2024
1 parent e11f875 commit 5812151
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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<Comment[]>();

const fetch = async () => {
try {
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
<div className="itemCard">
<img src={item.images[0]} alt={item.name} className="itemCardThumbnail" />
Expand Down

0 comments on commit 5812151

Please sign in to comment.