// Generated with util/create-component.js import React from "react"; import PickLabel from "../PickLabel"; import NsImage from "../shared/ns-image"; import Timer from "../Timer"; import Heading from "../UI/Heading"; import Text from "../UI/Text"; import { TimedealProps } from "./Timedeal.types"; const Timedeal: React.FC = (props) => { const { data, isLogin = false } = props; const { goodsNo, goodsName, brandName, imageUrl, ImageWrapper, goodsPrice, fixedPrice, periodDiscountStart, periodDiscountEnd, pickType, benefitUseType, goodsAccess, } = data; return (
{brandName} {goodsName}
{!isLogin && goodsAccess === "member" ? ( 회원전용 시크릿 특가 ) : (
{fixedPrice > goodsPrice ? ( {discountPercetage({ fixedPrice, goodsPrice })}% ) : ( "" )} {numberWithCommas(goodsPrice)}원
)}
); }; export default Timedeal; const numberWithCommas = (num: number): string => { return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); }; const discountPercetage = (props: { fixedPrice: number; goodsPrice: number; }): number => { const { fixedPrice, goodsPrice } = props; if (fixedPrice > goodsPrice) { return Math.round(((fixedPrice - goodsPrice) / fixedPrice) * 100); } return 0; };