From 256c9deef3d35873df41c05e0d59a72fcf5919fc Mon Sep 17 00:00:00 2001 From: lybell-art Date: Fri, 16 Aug 2024 15:56:03 +0900 Subject: [PATCH 01/34] =?UTF-8?q?[feat]=20=EC=98=A4=ED=94=88=EC=8B=9C?= =?UTF-8?q?=EA=B0=84/=EC=A2=85=EB=A3=8C=EC=8B=9C=EA=B0=84=20=EC=9D=BC?= =?UTF-8?q?=EA=B4=84=20=EC=84=A4=EC=A0=95=20=ED=8F=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eventEdit/BatchTimeUpdateInput.jsx | 29 ++++++++++ .../features/eventEdit/FcfsInput.jsx | 55 +++++++++++++------ 2 files changed, 67 insertions(+), 17 deletions(-) create mode 100644 src/adminPage/features/eventEdit/BatchTimeUpdateInput.jsx diff --git a/src/adminPage/features/eventEdit/BatchTimeUpdateInput.jsx b/src/adminPage/features/eventEdit/BatchTimeUpdateInput.jsx new file mode 100644 index 00000000..5fee28bb --- /dev/null +++ b/src/adminPage/features/eventEdit/BatchTimeUpdateInput.jsx @@ -0,0 +1,29 @@ +import { useState } from "react"; +import { Input } from "@admin/components/SmallInput.jsx"; +import Checkbox from "@common/components/Checkbox.jsx"; + +function BatchTimeUpdateInput({caption, value, applyBatch}) +{ + const [enabled, setEnabled] = useState(false); + + function onCheckboxClick(newValue) + { + setEnabled(newValue); + if(newValue) applyBatch(value); + } + function setTimeValue(newValue) + { + if(!enabled) return; + applyBatch(newValue); + } + + return +} + +export default BatchTimeUpdateInput; \ No newline at end of file diff --git a/src/adminPage/features/eventEdit/FcfsInput.jsx b/src/adminPage/features/eventEdit/FcfsInput.jsx index 11a090e2..afd31bed 100644 --- a/src/adminPage/features/eventEdit/FcfsInput.jsx +++ b/src/adminPage/features/eventEdit/FcfsInput.jsx @@ -1,27 +1,48 @@ import { useState } from "react"; -import { Input } from "@admin/components/SmallInput.jsx"; -import Checkbox from "@common/components/Checkbox.jsx"; -function FcfsInput() { - const [isOpenTimeBatch, SetOpenTimeBatch] = useState(false); - const [isCloseTimeBatch, SetCloseTimeBatch] = useState(false); +import BatchTimeUpdateInput from "./BatchTimeUpdateInput.jsx"; +import Button from "@common/components/Button.jsx"; + +const MINUTES = 60; + +function FcfsInput({state, dispatch}) { + const [batchStartTime, setBatchStartTime] = useState("00:00"); + const [batchEndTime, setBatchEndTime] = useState("23:55"); + function applyStartBatch(value) + { + setBatchStartTime(value); + if(value === "") return; + const [h,m] = value.split(":").map( Number ); + const time = h*MINUTES + m; + dispatch({type: "modify_all_fcfs_item", value: {start: time}}); + } + function applyEndBatch(value) + { + setBatchEndTime(value); + if(value === "") return; + const [h,m] = value.split(":").map( Number ); + const time = h*MINUTES + m; + dispatch({type: "modify_all_fcfs_item", value: {end: time}}); + } + function autoFill() + { + dispatch({type: "auto_fill_fcfs"}); + } return
- - - + + +
- {} + { + [...state.fcfs].map( (value)=>
+
{value.key}
+
{value.start}
+
{value.end}
+
) + }
; } From b88fc289f9f2da0a17e7c8c46111218def68c490 Mon Sep 17 00:00:00 2001 From: lybell-art Date: Fri, 16 Aug 2024 19:15:47 +0900 Subject: [PATCH 02/34] =?UTF-8?q?[refactor]=20context=20api=EB=A5=BC=20?= =?UTF-8?q?=EC=9D=B4=EC=9A=A9=ED=95=B4=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D=20=EB=A6=AC=EB=93=80=EC=84=9C=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=EA=B4=80=EB=A6=AC=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -[fix] 일괄설정 체크 해제 시에도 일괄설정 시각 폼이 유지되게 변경 --- .../eventEdit/BatchTimeUpdateInput.jsx | 29 ----------- .../{DrawInput.jsx => DrawInput/index.jsx} | 0 .../features/eventEdit/EventBaseDataInput.jsx | 28 +++++++---- .../features/eventEdit/EventDetailInput.jsx | 25 ++++++---- .../features/eventEdit/EventEditFetcher.jsx | 2 +- .../features/eventEdit/FcfsInput.jsx | 50 ------------------- .../FcfsInput/BatchTimeUpdateInput.jsx | 45 +++++++++++++++++ .../eventEdit/FcfsInput/BatchTimeUpdater.jsx | 25 ++++++++++ .../features/eventEdit/FcfsInput/index.jsx | 22 ++++++++ .../features/eventEdit/FcfsInput/reducer.js | 46 +++++++++++++++++ .../eventEdit/businessLogic/FcfsData.js | 5 +- .../eventEdit/businessLogic/constants.js | 3 ++ .../eventEdit/businessLogic/context.js | 6 +++ .../eventEdit/businessLogic/reducer.js | 3 +- src/adminPage/features/eventEdit/index.jsx | 24 +++++---- src/adminPage/pages/EventsCreatePage.jsx | 5 +- src/adminPage/pages/EventsEditPage.jsx | 5 +- 17 files changed, 209 insertions(+), 114 deletions(-) delete mode 100644 src/adminPage/features/eventEdit/BatchTimeUpdateInput.jsx rename src/adminPage/features/eventEdit/{DrawInput.jsx => DrawInput/index.jsx} (100%) delete mode 100644 src/adminPage/features/eventEdit/FcfsInput.jsx create mode 100644 src/adminPage/features/eventEdit/FcfsInput/BatchTimeUpdateInput.jsx create mode 100644 src/adminPage/features/eventEdit/FcfsInput/BatchTimeUpdater.jsx create mode 100644 src/adminPage/features/eventEdit/FcfsInput/index.jsx create mode 100644 src/adminPage/features/eventEdit/FcfsInput/reducer.js create mode 100644 src/adminPage/features/eventEdit/businessLogic/constants.js create mode 100644 src/adminPage/features/eventEdit/businessLogic/context.js diff --git a/src/adminPage/features/eventEdit/BatchTimeUpdateInput.jsx b/src/adminPage/features/eventEdit/BatchTimeUpdateInput.jsx deleted file mode 100644 index 5fee28bb..00000000 --- a/src/adminPage/features/eventEdit/BatchTimeUpdateInput.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import { useState } from "react"; -import { Input } from "@admin/components/SmallInput.jsx"; -import Checkbox from "@common/components/Checkbox.jsx"; - -function BatchTimeUpdateInput({caption, value, applyBatch}) -{ - const [enabled, setEnabled] = useState(false); - - function onCheckboxClick(newValue) - { - setEnabled(newValue); - if(newValue) applyBatch(value); - } - function setTimeValue(newValue) - { - if(!enabled) return; - applyBatch(newValue); - } - - return -} - -export default BatchTimeUpdateInput; \ No newline at end of file diff --git a/src/adminPage/features/eventEdit/DrawInput.jsx b/src/adminPage/features/eventEdit/DrawInput/index.jsx similarity index 100% rename from src/adminPage/features/eventEdit/DrawInput.jsx rename to src/adminPage/features/eventEdit/DrawInput/index.jsx diff --git a/src/adminPage/features/eventEdit/EventBaseDataInput.jsx b/src/adminPage/features/eventEdit/EventBaseDataInput.jsx index 1c28b66e..f9f0fa2f 100644 --- a/src/adminPage/features/eventEdit/EventBaseDataInput.jsx +++ b/src/adminPage/features/eventEdit/EventBaseDataInput.jsx @@ -1,7 +1,13 @@ +import { useContext } from "react"; import { Input, TextBox } from "@admin/components/SmallInput.jsx"; +import { EventEditContext, EventEditDispatchContext, EventEditModeContext } from "./businessLogic/context.js"; import DateTimeRangeInput from "./DateTimeRangeInput.jsx"; -function EventBaseDataInput({ state, dispatch, mode }) { +function EventBaseDataInput() { + const {name, eventId, eventFrameId, startTime, endTime, description, url} = useContext(EventEditContext); + const dispatch = useContext(EventEditDispatchContext); + const mode = useContext(EventEditModeContext); + const columnsStyle = "grid grid-cols-[6rem_1fr] items-center gap-2"; const NAME_MAX_LENGTH = 40; const DESCRIPTION_MAX_LENGTH = 100; @@ -15,7 +21,7 @@ function EventBaseDataInput({ state, dispatch, mode }) {
dispatch({ type: "set_name", value })} required maxLength="40" @@ -24,9 +30,9 @@ function EventBaseDataInput({ state, dispatch, mode }) { } /> = NAME_MAX_LENGTH ? "text-red-500" : "text-neutral-600"}`} + className={`absolute right-3 text-detail-l ${name.length >= NAME_MAX_LENGTH ? "text-red-500" : "text-neutral-600"}`} > - {state.name.length}/{NAME_MAX_LENGTH} + {name.length}/{NAME_MAX_LENGTH}
@@ -34,7 +40,7 @@ function EventBaseDataInput({ state, dispatch, mode }) { 이벤트 ID @@ -44,7 +50,7 @@ function EventBaseDataInput({ state, dispatch, mode }) { dispatch({ type: "set_event_frame", value })} required disabled={mode === "edit"} @@ -55,7 +61,7 @@ function EventBaseDataInput({ state, dispatch, mode }) { 이벤트 기간* { dispatch({ type: "set_date_range", value: range }); }} @@ -69,15 +75,15 @@ function EventBaseDataInput({ state, dispatch, mode }) {
dispatch({ type: "set_description", value })} rows="4" maxLength="100" /> = DESCRIPTION_MAX_LENGTH ? "text-red-500" : "text-neutral-600"}`} + className={`absolute right-3 bottom-3 text-detail-l ${description.length >= DESCRIPTION_MAX_LENGTH ? "text-red-500" : "text-neutral-600"}`} > - {state.description.length}/{DESCRIPTION_MAX_LENGTH} + {description.length}/{DESCRIPTION_MAX_LENGTH}
@@ -85,7 +91,7 @@ function EventBaseDataInput({ state, dispatch, mode }) { 이벤트 URL dispatch({ type: "set_url", value })} type="url" pattern="https?://.*" diff --git a/src/adminPage/features/eventEdit/EventDetailInput.jsx b/src/adminPage/features/eventEdit/EventDetailInput.jsx index 217a2aaa..d9808800 100644 --- a/src/adminPage/features/eventEdit/EventDetailInput.jsx +++ b/src/adminPage/features/eventEdit/EventDetailInput.jsx @@ -1,5 +1,8 @@ -import FcfsInput from "./FcfsInput.jsx"; -import DrawInput from "./DrawInput.jsx"; +import { useContext } from "react"; +import { EventEditContext, EventEditDispatchContext, EventEditModeContext } from "./businessLogic/context.js"; + +import FcfsInput from "./FcfsInput"; +import DrawInput from "./DrawInput"; function EventTypeSelector({ selected, onClick, children }) { const selectorBaseStyle = `flex justify-center items-center px-8 py-2 rounded-t-lg text-body-m relative hover:bg-blue-50`; @@ -17,7 +20,11 @@ function EventTypeSelector({ selected, onClick, children }) { ); } -function EventDetailInput({ state, dispatch, mode }) { +function EventDetailInput() { + const {eventType} = useContext(EventEditContext); + const dispatch = useContext(EventEditDispatchContext); + const mode = useContext(EventEditModeContext); + function selectEventType(type) { return () => { if (mode === "edit") return; @@ -29,24 +36,24 @@ function EventDetailInput({ state, dispatch, mode }) {
선착순 추첨
- {state.eventType === "fcfs" && ( - + {eventType === "fcfs" && ( + )} - {state.eventType === "draw" && ( - + {eventType === "draw" && ( + )}
diff --git a/src/adminPage/features/eventEdit/EventEditFetcher.jsx b/src/adminPage/features/eventEdit/EventEditFetcher.jsx index d71a4126..eb3f27ce 100644 --- a/src/adminPage/features/eventEdit/EventEditFetcher.jsx +++ b/src/adminPage/features/eventEdit/EventEditFetcher.jsx @@ -6,7 +6,7 @@ function EventEditFetcher({ eventId }) { const data = useQuery(`event-detail-${eventId}`, () => fetchServer(`/api/v1/admin/events/${eventId}`), ); - return ; + return ; } export default EventEditFetcher; diff --git a/src/adminPage/features/eventEdit/FcfsInput.jsx b/src/adminPage/features/eventEdit/FcfsInput.jsx deleted file mode 100644 index afd31bed..00000000 --- a/src/adminPage/features/eventEdit/FcfsInput.jsx +++ /dev/null @@ -1,50 +0,0 @@ -import { useState } from "react"; - -import BatchTimeUpdateInput from "./BatchTimeUpdateInput.jsx"; -import Button from "@common/components/Button.jsx"; - -const MINUTES = 60; - -function FcfsInput({state, dispatch}) { - const [batchStartTime, setBatchStartTime] = useState("00:00"); - const [batchEndTime, setBatchEndTime] = useState("23:55"); - function applyStartBatch(value) - { - setBatchStartTime(value); - if(value === "") return; - const [h,m] = value.split(":").map( Number ); - const time = h*MINUTES + m; - dispatch({type: "modify_all_fcfs_item", value: {start: time}}); - } - function applyEndBatch(value) - { - setBatchEndTime(value); - if(value === "") return; - const [h,m] = value.split(":").map( Number ); - const time = h*MINUTES + m; - dispatch({type: "modify_all_fcfs_item", value: {end: time}}); - } - function autoFill() - { - dispatch({type: "auto_fill_fcfs"}); - } - - return
-
- - - -
-
- { - [...state.fcfs].map( (value)=>
-
{value.key}
-
{value.start}
-
{value.end}
-
) - } -
-
; -} - -export default FcfsInput; diff --git a/src/adminPage/features/eventEdit/FcfsInput/BatchTimeUpdateInput.jsx b/src/adminPage/features/eventEdit/FcfsInput/BatchTimeUpdateInput.jsx new file mode 100644 index 00000000..0127d049 --- /dev/null +++ b/src/adminPage/features/eventEdit/FcfsInput/BatchTimeUpdateInput.jsx @@ -0,0 +1,45 @@ +import { useState } from "react"; +import { Input } from "@admin/components/SmallInput.jsx"; +import Checkbox from "@common/components/Checkbox.jsx"; + +import { padNumber } from "@common/utils.js"; + +const MINUTES = 60; + +function valueToTimeStr(value) +{ + const m = value % MINUTES; + const h = (value - m) / MINUTES; + return `${padNumber(h)}:${padNumber(m)}`; +} + +function timeStrToValue(str) +{ + let [h,m] = str.split(":").map( Number ); + return h*MINUTES+m; +} + +function BatchTimeUpdateInput({caption, type, state, dispatch}) +{ + const checked = state[`${type}Check`]; + const timeStr = valueToTimeStr( state[type] ); + + function onCheckboxClick(newValue) + { + dispatch({type: `toggle_${type}_time`, value: newValue}); + } + function setTimeValue(newValue) + { + dispatch({type: `set_${type}_time`, value: timeStrToValue(newValue)}); + } + + return +} + +export default BatchTimeUpdateInput; \ No newline at end of file diff --git a/src/adminPage/features/eventEdit/FcfsInput/BatchTimeUpdater.jsx b/src/adminPage/features/eventEdit/FcfsInput/BatchTimeUpdater.jsx new file mode 100644 index 00000000..5e11535c --- /dev/null +++ b/src/adminPage/features/eventEdit/FcfsInput/BatchTimeUpdater.jsx @@ -0,0 +1,25 @@ +import { useReducer, useContext } from "react"; +import { getDefaultState, fcfsBatchControlReducer, getBatchTimeConfig } from "./reducer.js"; +import BatchTimeUpdateInput from "./BatchTimeUpdateInput.jsx"; +import { EventEditContext, EventEditDispatchContext } from "../businessLogic/context.js"; +import Button from "@common/components/Button.jsx"; + +function BatchTimeUpdater() +{ + const { startTime, endTime } = useContext(EventEditContext); + const eventDispatch = useContext(EventEditDispatchContext); + const [batchTimeState, batchTimeDispatch] = useReducer(fcfsBatchControlReducer, null, getDefaultState); + + function autoFill() + { + eventDispatch({type: "auto_fill_fcfs", config: getBatchTimeConfig(batchTimeState)}); + } + + return
+ + + +
+} + +export default BatchTimeUpdater; \ No newline at end of file diff --git a/src/adminPage/features/eventEdit/FcfsInput/index.jsx b/src/adminPage/features/eventEdit/FcfsInput/index.jsx new file mode 100644 index 00000000..4ed88c9f --- /dev/null +++ b/src/adminPage/features/eventEdit/FcfsInput/index.jsx @@ -0,0 +1,22 @@ +import { useContext } from "react"; +import { EventEditContext } from "../businessLogic/context.js"; +import BatchTimeUpdater from "./BatchTimeUpdater.jsx"; + +function FcfsInput({state, dispatch}) { + const {fcfs} = useContext(EventEditContext); + + return
+ +
+ { + [...fcfs].map( (value)=>
+
{value.key}
+
{value.start}
+
{value.end}
+
) + } +
+
; +} + +export default FcfsInput; diff --git a/src/adminPage/features/eventEdit/FcfsInput/reducer.js b/src/adminPage/features/eventEdit/FcfsInput/reducer.js new file mode 100644 index 00000000..88f7154d --- /dev/null +++ b/src/adminPage/features/eventEdit/FcfsInput/reducer.js @@ -0,0 +1,46 @@ +import { DEFAULT_END_TIME } from "../businessLogic/constants.js"; + +const STEP = 5; + +export function getDefaultState() +{ + return { + start: 0, + end: DEFAULT_END_TIME, + startCheck: false, + endCheck: false, + } +} + +export function fcfsBatchControlReducer(state, action) +{ + switch(action.type) + { + case "toggle_start_time": + return {...state, startCheck : action.value}; + case "toggle_end_time": + return {...state, endCheck : action.value}; + case "set_start_time":{ + if(!state.startCheck) return state; + const value = Math.round(action.value / STEP) * STEP; + if(state.end > value) return {...state, start: value}; + if(state.end - STEP < 0) return {...state, start: 0, end: STEP}; + return {...state, start: state.end - STEP}; + } + case "set_end_time":{ + if(!state.endCheck) return state; + const value = Math.round(action.value / STEP) * STEP; + if(state.start < value) return {...state, end: value}; + if(state.start + STEP > DEFAULT_END_TIME) return {...state, start: DEFAULT_END_TIME - STEP, end: DEFAULT_END_TIME}; + return {...state, end: state.start + STEP}; + } + } +} + +export function getBatchTimeConfig(state) +{ + const result = {}; + if(state.startCheck) result.start = state.start; + if(state.endCheck) result.end = state.end; + return result; +} \ No newline at end of file diff --git a/src/adminPage/features/eventEdit/businessLogic/FcfsData.js b/src/adminPage/features/eventEdit/businessLogic/FcfsData.js index 4c691d45..790a2018 100644 --- a/src/adminPage/features/eventEdit/businessLogic/FcfsData.js +++ b/src/adminPage/features/eventEdit/businessLogic/FcfsData.js @@ -1,4 +1,5 @@ import makeUUID from "./makeUUID.js"; +import { DEFAULT_END_TIME, DEFATLT_PARTICIPANT } from "./constants.js"; const MINUTES = 60 * 1000; const ONE_DAY = 24 * 60 * MINUTES; @@ -10,7 +11,7 @@ function extractHourMinutes(date) { function getDefaultFcfsArray( startTime, endTime, - config = { start: 0, end: 1435, participantCount: 100 }, + config = { start: 0, end: DEFAULT_END_TIME, participantCount: DEFATLT_PARTICIPANT }, ) { if (startTime === null || endTime === null) return []; @@ -92,7 +93,7 @@ class FcfsData { data = { startTime: null, endTime: null, - participantCount: 100, + participantCount: DEFATLT_PARTICIPANT, prizeInfo: "", }, ) { diff --git a/src/adminPage/features/eventEdit/businessLogic/constants.js b/src/adminPage/features/eventEdit/businessLogic/constants.js new file mode 100644 index 00000000..c40f54af --- /dev/null +++ b/src/adminPage/features/eventEdit/businessLogic/constants.js @@ -0,0 +1,3 @@ +export const DEFAULT_END_TIME = 1435; +export const DEFATLT_PARTICIPANT = 100; +export const MAX_GRADE = 10; \ No newline at end of file diff --git a/src/adminPage/features/eventEdit/businessLogic/context.js b/src/adminPage/features/eventEdit/businessLogic/context.js new file mode 100644 index 00000000..27bd77e0 --- /dev/null +++ b/src/adminPage/features/eventEdit/businessLogic/context.js @@ -0,0 +1,6 @@ +import { createContext } from "react"; +import { setDefaultState } from "./reducer.js"; + +export const EventEditContext = createContext(setDefaultState()); +export const EventEditDispatchContext = createContext( ()=>console.error("context 지정 안 됨") ); +export const EventEditModeContext = createContext("create"); \ No newline at end of file diff --git a/src/adminPage/features/eventEdit/businessLogic/reducer.js b/src/adminPage/features/eventEdit/businessLogic/reducer.js index 094da4a7..322adbb6 100644 --- a/src/adminPage/features/eventEdit/businessLogic/reducer.js +++ b/src/adminPage/features/eventEdit/businessLogic/reducer.js @@ -1,6 +1,7 @@ import FcfsData from "./FcfsData.js"; import DrawGradeData from "./DrawGradeData.js"; import DrawPolicyData from "./DrawPolicyData.js"; +import { MAX_GRADE } from "./constants.js"; function makeVoidDrawData() { return { @@ -116,7 +117,7 @@ export function eventEditReducer(state, action) { } case "modify_draw_total_grade": if (state.eventType === "fcfs") return state; - if (action.value > 10 || action.value < 0) return state; + if (action.value > MAX_GRADE || action.value < 0) return state; return { ...state, draw: { diff --git a/src/adminPage/features/eventEdit/index.jsx b/src/adminPage/features/eventEdit/index.jsx index c41668bb..f42d2b3a 100644 --- a/src/adminPage/features/eventEdit/index.jsx +++ b/src/adminPage/features/eventEdit/index.jsx @@ -1,11 +1,13 @@ -import { useReducer } from "react"; +import { useReducer, useContext } from "react"; import { eventEditReducer, setDefaultState } from "./businessLogic/reducer.js"; +import { EventEditContext, EventEditDispatchContext, EventEditModeContext } from "./businessLogic/context.js"; import EventBaseDataInput from "./EventBaseDataInput.jsx"; import EventDetailInput from "./EventDetailInput.jsx"; import Button from "@common/components/Button.jsx"; -function EventEditor({ mode, initialData = null } = {}) { +function EventEditor({ initialData = null } = {}) { + const mode = useContext(EventEditModeContext); const [state, dispatch] = useReducer( eventEditReducer, initialData, @@ -35,13 +37,17 @@ function EventEditor({ mode, initialData = null } = {}) {
- -
- - 이벤트 종류* - - -
+ + + +
+ + 이벤트 종류* + + +
+
+
); diff --git a/src/adminPage/pages/EventsCreatePage.jsx b/src/adminPage/pages/EventsCreatePage.jsx index 53d5c096..188ed5b0 100644 --- a/src/adminPage/pages/EventsCreatePage.jsx +++ b/src/adminPage/pages/EventsCreatePage.jsx @@ -1,10 +1,13 @@ import Container from "@admin/components/Container.jsx"; import EventEditor from "../features/eventEdit/index.jsx"; +import { EventEditModeContext } from "../features/eventEdit/businessLogic/context.js"; function EventsCreatePage() { return ( - + + + ); } diff --git a/src/adminPage/pages/EventsEditPage.jsx b/src/adminPage/pages/EventsEditPage.jsx index 7133b698..fff3bdbb 100644 --- a/src/adminPage/pages/EventsEditPage.jsx +++ b/src/adminPage/pages/EventsEditPage.jsx @@ -2,6 +2,7 @@ import { useParams } from "react-router-dom"; import Container from "@admin/components/Container.jsx"; import Suspense from "@common/components/Suspense.jsx"; import ErrorBoundary from "@common/components/ErrorBoundary.jsx"; +import { EventEditModeContext } from "../features/eventEdit/businessLogic/context.js"; import EventEditFetcher from "../features/eventEdit/EventEditFetcher.jsx"; function EventsEditPage() { @@ -11,7 +12,9 @@ function EventsEditPage() { error}> loading}> - + + + From 1103c91858b1c8a7fe4c909eda6a094b86e33372 Mon Sep 17 00:00:00 2001 From: lybell-art Date: Fri, 16 Aug 2024 19:29:42 +0900 Subject: [PATCH 03/34] =?UTF-8?q?[fix]=20=EC=9D=BC=EA=B4=84=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=ED=8F=BC=20=EB=B3=80=EA=B2=BD=20=EC=8B=9C=20?= =?UTF-8?q?=EC=8B=A4=EC=A0=9C=20=EC=B1=84=EC=9B=8C=EC=A7=84=20=EC=84=A0?= =?UTF-8?q?=EC=B0=A9=EC=88=9C=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=EC=97=90=20?= =?UTF-8?q?=EB=B0=98=EC=98=81=EC=9D=B4=20=EC=95=88=20=EB=90=98=EB=8A=94=20?= =?UTF-8?q?=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eventEdit/FcfsInput/BatchTimeUpdateInput.jsx | 15 ++++++++++++--- .../features/eventEdit/FcfsInput/reducer.js | 3 +++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/adminPage/features/eventEdit/FcfsInput/BatchTimeUpdateInput.jsx b/src/adminPage/features/eventEdit/FcfsInput/BatchTimeUpdateInput.jsx index 0127d049..ed8a7e40 100644 --- a/src/adminPage/features/eventEdit/FcfsInput/BatchTimeUpdateInput.jsx +++ b/src/adminPage/features/eventEdit/FcfsInput/BatchTimeUpdateInput.jsx @@ -1,4 +1,6 @@ -import { useState } from "react"; +import { useState, useContext } from "react"; +import { EventEditDispatchContext } from "../businessLogic/context.js"; +import { fcfsBatchControlReducer, getBatchTimeConfig } from "./reducer.js"; import { Input } from "@admin/components/SmallInput.jsx"; import Checkbox from "@common/components/Checkbox.jsx"; @@ -21,16 +23,23 @@ function timeStrToValue(str) function BatchTimeUpdateInput({caption, type, state, dispatch}) { + const eventEditDispatch = useContext(EventEditDispatchContext); const checked = state[`${type}Check`]; const timeStr = valueToTimeStr( state[type] ); function onCheckboxClick(newValue) { - dispatch({type: `toggle_${type}_time`, value: newValue}); + const action = {type: `toggle_${type}_time`, value: newValue}; + const nextState = fcfsBatchControlReducer(state, action); + dispatch({type: "apply", value: nextState}); + eventEditDispatch({type: "modify_all_fcfs_item", value: getBatchTimeConfig(nextState)}); } function setTimeValue(newValue) { - dispatch({type: `set_${type}_time`, value: timeStrToValue(newValue)}); + const action = {type: `set_${type}_time`, value: timeStrToValue(newValue)}; + const nextState = fcfsBatchControlReducer(state, action); + dispatch({type: "apply", value: nextState}); + eventEditDispatch({type: "modify_all_fcfs_item", value: getBatchTimeConfig(nextState)}); } return