export function isValidSpecValue(value: string) { if (!value) { return; } const notValidValues = new Set(["X", "-", "U", "가격 미확인"]); return value.length > 0 && !notValidValues.has(value); } export const validateSpecValue = (value: string) => { const isValid = isValidSpecValue(value); return isValid ? value : ""; }; export function getPriceString(price: string) { const endText = price.slice(-2, price.length); if (endText === "만원") return price; return price + "만원"; } export function numberWithCommas(num: number): string { return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } export function getDiscountPercentage({ fixedPrice, goodsPrice, }: { fixedPrice: number; goodsPrice: number; }) { if (fixedPrice > goodsPrice) { return Math.round(((fixedPrice - goodsPrice) / fixedPrice) * 100); } return 0; }