From 7c5078fcdf4a5c3bb8fd3c105bd3a9c331df8217 Mon Sep 17 00:00:00 2001 From: juhyojeong Date: Sun, 11 Aug 2024 12:41:57 +0900 Subject: [PATCH 01/11] =?UTF-8?q?feat:=20=EC=84=A0=EC=B0=A9=EC=88=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/components/Layout/index.tsx | 5 +- admin/src/constants/rush.ts | 7 --- admin/src/features/Rush/EventList.tsx | 69 +++++++-------------------- admin/src/features/Rush/Layout.tsx | 10 ++++ admin/src/pages/Rush/index.tsx | 46 +++++++++--------- admin/src/router.tsx | 9 +++- admin/src/types/rush.ts | 14 +++--- 7 files changed, 66 insertions(+), 94 deletions(-) create mode 100644 admin/src/features/Rush/Layout.tsx diff --git a/admin/src/components/Layout/index.tsx b/admin/src/components/Layout/index.tsx index c37c7bb6..2d599896 100644 --- a/admin/src/components/Layout/index.tsx +++ b/admin/src/components/Layout/index.tsx @@ -1,5 +1,4 @@ import { Outlet } from "react-router-dom"; -import { RushEventContext } from "@/contexts/rushEventContext"; import Header from "../Header"; export default function Layout() { @@ -7,9 +6,7 @@ export default function Layout() {
- - - +
); diff --git a/admin/src/constants/rush.ts b/admin/src/constants/rush.ts index ba66e28d..e69de29b 100644 --- a/admin/src/constants/rush.ts +++ b/admin/src/constants/rush.ts @@ -1,7 +0,0 @@ -export const RUSH_SECTION = { - EVENT_LIST: "event_list", - APPLICANT_LIST: "applicant_list", - SELECTION_MANAGE: "selection_manage", - GIFT_MANAGE: "gift_manage", -}; -export type RushSectionType = (typeof RUSH_SECTION)[keyof typeof RUSH_SECTION]; diff --git a/admin/src/features/Rush/EventList.tsx b/admin/src/features/Rush/EventList.tsx index 31d5e2ff..2f1a343f 100644 --- a/admin/src/features/Rush/EventList.tsx +++ b/admin/src/features/Rush/EventList.tsx @@ -1,17 +1,14 @@ -import { useEffect } from "react"; +import { useNavigate } from "react-router-dom"; import Button from "@/components/Button"; import DatePicker from "@/components/DatePicker"; import Table from "@/components/Table"; import TimePicker from "@/components/TimePicker"; -import { RUSH_SECTION, RushSectionType } from "@/constants/rush"; import useRushEventDispatchContext from "@/hooks/useRushEventDispatchContext"; import useRushEventStateContext from "@/hooks/useRushEventStateContext"; import { RUSH_ACTION } from "@/types/rush"; import { getTimeDifference } from "@/utils/getTimeDifference"; -interface EventListProps { - handleSelectSection: (idx: number, section: RushSectionType) => void; -} +interface EventListProps {} const EVENT_LIST_HEADER = [ "ID", @@ -27,46 +24,12 @@ const EVENT_LIST_HEADER = [ "관리", ]; -export default function EventList({ handleSelectSection }: EventListProps) { +export default function EventList({}: EventListProps) { + const navigate = useNavigate(); + const { rushList } = useRushEventStateContext(); const dispatch = useRushEventDispatchContext(); - useEffect(() => { - // TODO: 데이터 패칭 로직 구현 - dispatch({ - type: RUSH_ACTION.SET_EVENT_LIST, - payload: [ - { - rush_event_id: 1, - event_date: "2024-07-25", - open_time: "20:00:00", - close_time: "20:10:00", - winner_count: 315, - prize_image_url: "prize1.png", - prize_description: "스타벅스 1만원 기프트카드", - }, - { - rush_event_id: 2, - event_date: "2024-07-26", - open_time: "20:00:00", - close_time: "20:10:00", - winner_count: 315, - prize_image_url: "prize2.png", - prize_description: "올리브영 1만원 기프트카드", - }, - { - rush_event_id: 2, - event_date: "2024-07-27", - open_time: "20:00:00", - close_time: "20:10:00", - winner_count: 315, - prize_image_url: "prize3.png", - prize_description: "배달의 민족 1만원 기프트카드", - }, - ], - }); - }, []); - const handleChangeItem = (key: string, changeIdx: number, date: string) => { const updatedTableItemList = rushList.map((item, idx) => { if (idx === changeIdx) { @@ -81,30 +44,32 @@ export default function EventList({ handleSelectSection }: EventListProps) { const getTableData = () => { return rushList.map((item, idx) => { return [ - item.rush_event_id, + item.rushEventId, handleChangeItem("event_date", idx, date)} + date={item.eventDate} + onChangeDate={(date) => handleChangeItem("eventDate", idx, date)} />, handleChangeItem("open_time", idx, time)} + time={item.openTime} + onChangeTime={(time) => handleChangeItem("openTime", idx, time)} />, handleChangeItem("close_time", idx, time)} + time={item.closeTime} + onChangeTime={(time) => handleChangeItem("closeTime", idx, time)} />, - getTimeDifference(item.open_time, item.close_time), + getTimeDifference(item.openTime, item.closeTime), , ,
-

{item.winner_count}

+

{item.winnerCount}

편집

, "오픈 전", , diff --git a/admin/src/features/Rush/Layout.tsx b/admin/src/features/Rush/Layout.tsx new file mode 100644 index 00000000..21b8749f --- /dev/null +++ b/admin/src/features/Rush/Layout.tsx @@ -0,0 +1,10 @@ +import { Outlet } from "react-router-dom"; +import { RushEventContext } from "@/contexts/rushEventContext"; + +export default function RushLayout() { + return ( + + + + ); +} diff --git a/admin/src/pages/Rush/index.tsx b/admin/src/pages/Rush/index.tsx index e3f0e947..5f200e1d 100644 --- a/admin/src/pages/Rush/index.tsx +++ b/admin/src/pages/Rush/index.tsx @@ -1,6 +1,6 @@ import { useEffect } from "react"; import TabHeader from "@/components/TabHeader"; -import ApplicantList from "@/features/Rush/ApplicantList"; +import EventList from "@/features/Rush/EventList"; import useRushEventDispatchContext from "@/hooks/useRushEventDispatchContext"; import { RUSH_ACTION } from "@/types/rush"; @@ -13,31 +13,31 @@ export default function Rush() { type: RUSH_ACTION.SET_EVENT_LIST, payload: [ { - rush_event_id: 1, - event_date: "2024-07-25", - open_time: "20:00:00", - close_time: "20:10:00", - winner_count: 315, - prize_image_url: "prize1.png", - prize_description: "스타벅스 1만원 기프트카드", + rushEventId: 1, + eventDate: "2024-07-25", + openTime: "20:00:00", + closeTime: "20:10:00", + winnerCount: 315, + prizeImageUrl: "prize1.png", + prizeDescription: "스타벅스 1만원 기프트카드", }, { - rush_event_id: 2, - event_date: "2024-07-26", - open_time: "20:00:00", - close_time: "20:10:00", - winner_count: 315, - prize_image_url: "prize2.png", - prize_description: "올리브영 1만원 기프트카드", + rushEventId: 2, + eventDate: "2024-07-26", + openTime: "20:00:00", + closeTime: "20:10:00", + winnerCount: 315, + prizeImageUrl: "prize2.png", + prizeDescription: "올리브영 1만원 기프트카드", }, { - rush_event_id: 2, - event_date: "2024-07-27", - open_time: "20:00:00", - close_time: "20:10:00", - winner_count: 315, - prize_image_url: "prize3.png", - prize_description: "배달의 민족 1만원 기프트카드", + rushEventId: 2, + eventDate: "2024-07-27", + openTime: "20:00:00", + closeTime: "20:10:00", + winnerCount: 315, + prizeImageUrl: "prize3.png", + prizeDescription: "배달의 민족 1만원 기프트카드", }, ], }); @@ -47,7 +47,7 @@ export default function Rush() {
- +
); } diff --git a/admin/src/router.tsx b/admin/src/router.tsx index 9a5ed0c4..a05087b4 100644 --- a/admin/src/router.tsx +++ b/admin/src/router.tsx @@ -1,5 +1,6 @@ import { createBrowserRouter } from "react-router-dom"; import Layout from "./components/Layout"; +import RushLayout from "./features/Rush/Layout"; import Login from "./pages/Login"; import Lottery from "./pages/Lottery"; import LotteryWinner from "./pages/LotteryWinner"; @@ -29,7 +30,13 @@ export const router = createBrowserRouter([ }, { path: "rush/", - element: , + element: , + children: [ + { + index: true, + element: , + }, + ], }, ], }, diff --git a/admin/src/types/rush.ts b/admin/src/types/rush.ts index dde663d8..0701e921 100644 --- a/admin/src/types/rush.ts +++ b/admin/src/types/rush.ts @@ -1,13 +1,13 @@ import { Dispatch } from "react"; export interface RushEventType { - rush_event_id: number; - event_date: string; - open_time: string; - close_time: string; - winner_count: number; - prize_image_url: string; - prize_description: string; + rushEventId: number; + eventDate: string; + openTime: string; + closeTime: string; + winnerCount: number; + prizeImageUrl: string; + prizeDescription: string; } export interface RushEventStateType { From 672275c7333bc7d7a102e9295e154d1a2dce45eb Mon Sep 17 00:00:00 2001 From: juhyojeong Date: Sun, 11 Aug 2024 13:22:01 +0900 Subject: [PATCH 02/11] =?UTF-8?q?feat:=20=EC=84=A0=ED=83=9D=EC=A7=80=20?= =?UTF-8?q?=EA=B4=80=EB=A6=AC=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/components/SelectForm/index.tsx | 38 +++++++ admin/src/components/TextField/index.tsx | 13 +++ admin/src/contexts/rushEventContext.tsx | 4 +- admin/src/features/Rush/EventList.tsx | 9 +- admin/src/pages/RushSelectForm/index.tsx | 129 ++++++++++++++++++++++ admin/src/router.tsx | 5 + admin/src/types/rush.ts | 39 +++---- 7 files changed, 216 insertions(+), 21 deletions(-) create mode 100644 admin/src/components/SelectForm/index.tsx create mode 100644 admin/src/components/TextField/index.tsx create mode 100644 admin/src/pages/RushSelectForm/index.tsx diff --git a/admin/src/components/SelectForm/index.tsx b/admin/src/components/SelectForm/index.tsx new file mode 100644 index 00000000..693d7b32 --- /dev/null +++ b/admin/src/components/SelectForm/index.tsx @@ -0,0 +1,38 @@ +import { ReactNode } from "react"; + +interface SelectFormProps { + header: ReactNode; + data: ReactNode[][]; +} + +export default function SelectForm({ header, data }: SelectFormProps) { + return ( +
+
+ + + + + + + + {data.map((tableData, idx) => ( + + {tableData.map((dataNode, idx) => ( + + ))} + + ))} + +
+ {header} +
+ {dataNode} +
+
+
+ ); +} diff --git a/admin/src/components/TextField/index.tsx b/admin/src/components/TextField/index.tsx new file mode 100644 index 00000000..3cfff79a --- /dev/null +++ b/admin/src/components/TextField/index.tsx @@ -0,0 +1,13 @@ +import { ComponentProps } from "react"; + +interface TextFieldProps extends ComponentProps<"textarea"> {} + +export default function TextField({ ...restProps }: TextFieldProps) { + return ( +