diff --git a/src/components/domain/card/trade-state-card/TradeStateCard.tsx b/src/components/domain/card/trade-state-card/TradeStateCard.tsx
index 055739f1..2263b072 100644
--- a/src/components/domain/card/trade-state-card/TradeStateCard.tsx
+++ b/src/components/domain/card/trade-state-card/TradeStateCard.tsx
@@ -8,19 +8,32 @@ import { Item } from '@/types'
type TradeStateCardProps = {
item: Item
}
+type TradeStateMap = {
+ [key: string]: {
+ style:
+ | 'primary'
+ | 'secondary'
+ | 'gradation'
+ | 'information'
+ | null
+ | undefined
+ text: string
+ }
+}
const TradeStateCard = ({
item: { image, cardTitle, tradeState, itemName, priceRange, createdAt },
}: TradeStateCardProps) => {
- const getStyleByTradeState = (tradeState: string) =>
- tradeState === 'possible' ? 'primary' : 'secondary'
- const getTextByTradeState = (tradeState: string) =>
- tradeState === 'possible' ? '거래가능' : '예약중'
- const renderBadgeByTradeState = (tradeState: string) => (
-
- {getTextByTradeState(tradeState)}
-
- )
+ const tradeStateMap: TradeStateMap = {
+ possible: {
+ style: 'primary',
+ text: '거래가능',
+ },
+ impossible: {
+ style: 'secondary',
+ text: '예약중',
+ },
+ }
return (
@@ -43,7 +56,9 @@ const TradeStateCard = ({
{cardTitle}
- {renderBadgeByTradeState(tradeState)}
+
+ {tradeStateMap[tradeState].text}
+
{itemName}
{priceRange}
diff --git a/src/components/ui/Card/Card.stories.tsx b/src/components/ui/Card/Card.stories.tsx
index 0c2d632d..e23a4d0f 100644
--- a/src/components/ui/Card/Card.stories.tsx
+++ b/src/components/ui/Card/Card.stories.tsx
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react'
-import TradeStateCard from '@/components/domain/card/TradeStateCard'
+import TradeStateCard from '@/components/domain/card/trade-state-card'
import Button from '../Button'
import { Card, CardFlex, CardImage, CardText } from './Card'