diff --git a/src/pages/Event/Event2023FallHistory.tsx b/src/pages/Event/Event2023FallHistory.tsx index 282848e2d..43057e5c6 100644 --- a/src/pages/Event/Event2023FallHistory.tsx +++ b/src/pages/Event/Event2023FallHistory.tsx @@ -6,7 +6,6 @@ import { useValueRecoilState } from "hooks/useFetchRecoilState"; import useQuery from "hooks/useTaxiAPI"; import AdaptiveDiv from "components/AdaptiveDiv"; -import DottedLine from "components/DottedLine"; import Empty from "components/Empty"; import CreditAmountStatusContainer from "components/Event/CreditAmountStatusContainer"; import Footer from "components/Footer"; @@ -18,18 +17,71 @@ import WhiteContainerSuggestLogin from "components/WhiteContainer/WhiteContainer import dayjs, { day2str } from "tools/day"; import theme from "tools/theme"; +type HistoryItemProps = { + imageUrl: string; + title: string; + description: string; + date: Date; +}; + +const HistoryItem = ({ + imageUrl, + title, + description, + date, +}: HistoryItemProps) => ( + + + + + + + + {title} + {description} + + {day2str(dayjs(date))} + + + +); + const HistorySection = () => { const { transactions } = useQuery.get("/events/2023fall/transactions")[1] || {}; const purchaseHistory = useMemo( () => - (transactions || []) - .filter(({ type }: Transaction) => type === "use") - .sort((x: Transaction, y: Transaction) => - dayjs(y.doneat).diff(dayjs(x.doneat)) - ), + (transactions || []).sort((x: Transaction, y: Transaction) => + dayjs(y.createAt).diff(dayjs(x.createAt)) + ), [transactions] ) as Array; + const { quests } = useValueRecoilState("event2023FallInfo") || {}; return ( <> @@ -42,32 +94,32 @@ const HistorySection = () => { {purchaseHistory.length > 0 ? ( purchaseHistory.map( - ({ _id, amount, eventId, itemId, comment, doneat }: Transaction) => ( - - - {comment} - - - - - 구매 아이디 : {_id} - - 구매 상품 : {itemId || ""} - - 차감된 송편 : {amount || ""} - - 구매 시각 : {day2str(dayjs(doneat))} - - - - ) + ({ _id, type, comment, createAt, questId, item }: Transaction) => { + if (type === "get") { + const quest = quests?.find((quest) => quest.id === questId); + return ( + + ); + } else if (type === "use") { + return ( + + ); + } else { + return null; + } + } ) ) : ( 구매 이력이 없습니다. diff --git a/src/types/event2023fall.d.ts b/src/types/event2023fall.d.ts index b93ea3982..f4d6559c9 100644 --- a/src/types/event2023fall.d.ts +++ b/src/types/event2023fall.d.ts @@ -9,6 +9,24 @@ export type EventItem = { itemType: number; }; +export type Transaction = { + _id: string; + amount: number; + comment: string; + createAt: Date; +} & ( + | { + type: "get"; + questId: string; + item: never; + } + | { + type: "use"; + item: EventItem; + questId: never; + } +); + export type Quest = { description: string; id: QuestId; @@ -30,13 +48,3 @@ export type QuestId = | "adPushAgreement" | "eventSharingOnInstagram" | "purchaseSharingOnInstagram"; - -export type Transaction = { - _id: string; - type: "get" | "use"; - amount: number; - eventId?: string; - itemId?: string; - comment: string; - doneat: Date; -};