From 3415c06986633781403a43791536acf267b51608 Mon Sep 17 00:00:00 2001 From: lybell-art Date: Wed, 14 Aug 2024 10:04:15 +0900 Subject: [PATCH 01/25] =?UTF-8?q?[fix]=20=EC=9E=90=EB=8F=99=20=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=EA=B0=80=20=EC=A0=81=EC=9A=A9=EB=90=98=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EB=8D=98=20=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 --- .github/workflows/deploy_preview.yaml | 5 +++-- .github/workflows/deploy_production.yaml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy_preview.yaml b/.github/workflows/deploy_preview.yaml index 578e1b8b..7e89b298 100644 --- a/.github/workflows/deploy_preview.yaml +++ b/.github/workflows/deploy_preview.yaml @@ -7,8 +7,9 @@ on: branches: - "dev" paths: - - "common/**" - - "mainPage/**" + - "src/common/**" + - "src/mainPage/**" + - "public" jobs: deploy-preview: runs-on: ubuntu-latest diff --git a/.github/workflows/deploy_production.yaml b/.github/workflows/deploy_production.yaml index 7df4129f..01786244 100644 --- a/.github/workflows/deploy_production.yaml +++ b/.github/workflows/deploy_production.yaml @@ -7,8 +7,9 @@ on: branches: - "main" paths: - - "common/**" - - "mainPage/**" + - "src/common/**" + - "src/mainPage/**" + - "public" jobs: deploy-production: runs-on: ubuntu-latest From 20e35a7fe1fcd07bb9ed0a8b85157ab329f81ac1 Mon Sep 17 00:00:00 2001 From: lybell-art Date: Wed, 14 Aug 2024 10:26:43 +0900 Subject: [PATCH 02/25] =?UTF-8?q?[build]=20=EB=A6=AC=EB=B2=84=EC=8A=A4=20?= =?UTF-8?q?=ED=94=84=EB=A1=9D=EC=8B=B1=EC=9D=84=20=EC=8B=A4=EC=A0=9C=20?= =?UTF-8?q?=EB=B0=B1=EC=97=94=EB=93=9C=20=EC=84=9C=EB=B2=84=EC=9D=98=20?= =?UTF-8?q?=EB=8F=84=EB=A9=94=EC=9D=B8=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy_preview.yaml | 2 +- .github/workflows/deploy_production.yaml | 2 +- vercel.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy_preview.yaml b/.github/workflows/deploy_preview.yaml index 7e89b298..4b590343 100644 --- a/.github/workflows/deploy_preview.yaml +++ b/.github/workflows/deploy_preview.yaml @@ -9,7 +9,7 @@ on: paths: - "src/common/**" - "src/mainPage/**" - - "public" + - "public/**" jobs: deploy-preview: runs-on: ubuntu-latest diff --git a/.github/workflows/deploy_production.yaml b/.github/workflows/deploy_production.yaml index 01786244..fde35b9e 100644 --- a/.github/workflows/deploy_production.yaml +++ b/.github/workflows/deploy_production.yaml @@ -9,7 +9,7 @@ on: paths: - "src/common/**" - "src/mainPage/**" - - "public" + - "public/**" jobs: deploy-production: runs-on: ubuntu-latest diff --git a/vercel.json b/vercel.json index b0803975..22e58f1c 100644 --- a/vercel.json +++ b/vercel.json @@ -2,7 +2,7 @@ "rewrites": [ { "source": "/api/:path*", - "destination": "http://13.125.76.97:8080/api/:path*" + "destination": "http://softeerorange.store/api/:path*" } ] } \ No newline at end of file From 8fda8059ae20d4fdf72a6fa7f63b30065d817d03 Mon Sep 17 00:00:00 2001 From: lybell-art Date: Wed, 14 Aug 2024 10:27:41 +0900 Subject: [PATCH 03/25] =?UTF-8?q?[fix]=20=EB=B3=B8=EC=9D=B8=EC=9D=B8?= =?UTF-8?q?=EC=A6=9D=20=EB=A7=88=EC=BC=80=ED=8C=85=20=EC=88=98=EC=8B=A0?= =?UTF-8?q?=EB=8F=99=EC=9D=98=20required=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainPage/shared/auth/InfoInput/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mainPage/shared/auth/InfoInput/index.jsx b/src/mainPage/shared/auth/InfoInput/index.jsx index 390cb97b..c96fc5be 100644 --- a/src/mainPage/shared/auth/InfoInput/index.jsx +++ b/src/mainPage/shared/auth/InfoInput/index.jsx @@ -67,7 +67,7 @@ function AuthFirstSection({ 자세히 보기 } diff --git a/src/adminPage/pages/EventsDetailPage.jsx b/src/adminPage/pages/EventsDetailPage.jsx new file mode 100644 index 00000000..172040bc --- /dev/null +++ b/src/adminPage/pages/EventsDetailPage.jsx @@ -0,0 +1,11 @@ +import Container from "@admin/components/Container.jsx"; + +function EventsDetailPage() { + return ( + +
이벤트 디테일 들어갈 예정
+
+ ); +} + +export default EventsDetailPage; From 9324adcb5f3a99d6074d1735752adf4e17bfdcfb Mon Sep 17 00:00:00 2001 From: lybell-art Date: Wed, 14 Aug 2024 18:22:28 +0900 Subject: [PATCH 23/25] =?UTF-8?q?[feat]=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=ED=8E=98=EC=9D=B4=EC=A7=80=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=ED=95=98=EB=8A=94=20=EB=A7=81=ED=81=AC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/adminPage/App.jsx | 3 ++- src/adminPage/features/eventList/index.jsx | 3 ++- src/adminPage/pages/EventsCreatePage.jsx | 11 +++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 src/adminPage/pages/EventsCreatePage.jsx diff --git a/src/adminPage/App.jsx b/src/adminPage/App.jsx index 1d41ea26..54f676b9 100644 --- a/src/adminPage/App.jsx +++ b/src/adminPage/App.jsx @@ -3,6 +3,7 @@ import { Route, Routes } from "react-router-dom"; import LoginPage from "./pages/LoginPage.jsx"; import EventsPage from "./pages/EventsPage.jsx"; import EventsDetailPage from "./pages/EventsDetailPage.jsx"; +import EventsCreatePage from "./pages/EventsCreatePage.jsx"; import ProtectedRoute from "./pages/ProtectedRoute.jsx"; import RootRoute from "./pages/RootRoute.jsx"; import CommentsPage from "./pages/CommentsPage.jsx"; @@ -25,7 +26,7 @@ function App() { event 생성 화면} + element={} /> } /> } /> diff --git a/src/adminPage/features/eventList/index.jsx b/src/adminPage/features/eventList/index.jsx index dc191095..2b241f3d 100644 --- a/src/adminPage/features/eventList/index.jsx +++ b/src/adminPage/features/eventList/index.jsx @@ -1,4 +1,5 @@ import { useReducer, useDeferredValue } from "react"; +import { Link } from "react-router-dom"; import { searchReducer, setDefaultState, searchStateToQuery } from "./queryReducer.js"; import checkReducer from "./checkReducer.js"; @@ -20,7 +21,7 @@ function EventList() { return (
- +
{ dispatch({type:"set_query", value}); diff --git a/src/adminPage/pages/EventsCreatePage.jsx b/src/adminPage/pages/EventsCreatePage.jsx new file mode 100644 index 00000000..2d04d25c --- /dev/null +++ b/src/adminPage/pages/EventsCreatePage.jsx @@ -0,0 +1,11 @@ +import Container from "@admin/components/Container.jsx"; + +function EventsCreatePage() { + return ( + +
이벤트 생성 화면 들어갈 예정
+
+ ); +} + +export default EventsCreatePage; From 3656f2f29af64f6af4ac7d3ecae253de5645853f Mon Sep 17 00:00:00 2001 From: lybell-art Date: Wed, 14 Aug 2024 18:51:03 +0900 Subject: [PATCH 24/25] =?UTF-8?q?[wip]=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D=20=EA=B8=B0=EB=B3=B8=20=EB=BC=88=EB=8C=80=20?= =?UTF-8?q?=EA=B5=AC=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/adminPage/App.jsx | 5 +++++ .../features/eventEdit/Container.jsx | 21 +++++++++++++++++++ src/adminPage/features/eventEdit/index.jsx | 21 +++++++++++++++++++ src/adminPage/pages/EventsCreatePage.jsx | 6 +++++- 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/adminPage/features/eventEdit/Container.jsx create mode 100644 src/adminPage/features/eventEdit/index.jsx diff --git a/src/adminPage/App.jsx b/src/adminPage/App.jsx index 54f676b9..60ac99a7 100644 --- a/src/adminPage/App.jsx +++ b/src/adminPage/App.jsx @@ -28,6 +28,11 @@ function App() { path="/events/create" element={} /> + 이벤트 수정하는 페이지
} + /> } /> } /> 기대평 화면} /> diff --git a/src/adminPage/features/eventEdit/Container.jsx b/src/adminPage/features/eventEdit/Container.jsx new file mode 100644 index 00000000..3af72215 --- /dev/null +++ b/src/adminPage/features/eventEdit/Container.jsx @@ -0,0 +1,21 @@ +import Button from "@common/components/Button.jsx"; + +function EventEditContainer({title, children}) +{ + return
+
+
+

{title}

+

*는 필수 입력

+
+
+ + + +
+
+ {children} +
+} + +export default EventEditContainer; \ No newline at end of file diff --git a/src/adminPage/features/eventEdit/index.jsx b/src/adminPage/features/eventEdit/index.jsx new file mode 100644 index 00000000..f9e20b87 --- /dev/null +++ b/src/adminPage/features/eventEdit/index.jsx @@ -0,0 +1,21 @@ +import Input from "@common/components/Input.jsx"; + +function EventEditor({defaultValue}) +{ + return
+ + +
+ 이벤트 기간* + +
+
+} + +export default EventEditor; \ No newline at end of file diff --git a/src/adminPage/pages/EventsCreatePage.jsx b/src/adminPage/pages/EventsCreatePage.jsx index 2d04d25c..e9461ea6 100644 --- a/src/adminPage/pages/EventsCreatePage.jsx +++ b/src/adminPage/pages/EventsCreatePage.jsx @@ -1,9 +1,13 @@ import Container from "@admin/components/Container.jsx"; +import EventEditContainer from "../features/eventEdit/Container.jsx"; +import EventEditor from "../features/eventEdit/index.jsx"; function EventsCreatePage() { return ( -
이벤트 생성 화면 들어갈 예정
+ + +
); } From 836927716ff5cefbffd52eddab6e22acbcb12cd8 Mon Sep 17 00:00:00 2001 From: lybell-art Date: Wed, 14 Aug 2024 18:52:06 +0900 Subject: [PATCH 25/25] =?UTF-8?q?[chore]=20=EB=A6=B0=ED=8A=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EB=B0=8F=20=ED=94=84=EB=A6=AC=ED=8B=B0=EC=96=B4=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/adminPage/App.jsx | 6 +- .../features/eventEdit/Container.jsx | 35 ++++---- src/adminPage/features/eventEdit/index.jsx | 38 ++++---- .../features/eventList/DeleteButton.jsx | 73 ++++++++++------ .../features/eventList/checkReducer.js | 30 ++++--- src/adminPage/features/eventList/index.jsx | 30 +++++-- src/adminPage/features/eventList/mock.js | 87 +++++++++---------- .../features/eventList/queryReducer.js | 5 +- .../eventList/table/SearchResultBody.jsx | 25 +++--- .../eventList/table/SearchResultItem.jsx | 69 +++++++++++---- .../features/eventList/table/TableHeader.jsx | 6 +- .../features/eventList/table/index.jsx | 67 ++++++++------ src/adminPage/mock.js | 6 +- src/adminPage/shared/components/Container.jsx | 6 +- .../shared/components/Pagination.jsx | 85 ++++++++++++------ src/adminPage/shared/modals/AlertModal.jsx | 42 ++++----- src/adminPage/shared/modals/ConfirmModal.jsx | 53 ++++++----- .../shared/serverTime/EventStatus.js | 18 ++-- .../serverTime/ServerTimeInitializer.jsx | 26 +++--- src/adminPage/shared/serverTime/store.js | 14 +-- src/common/components/Checkbox.jsx | 17 ++-- src/common/dataFetch/getQuery.js | 45 +++++----- src/common/mock/utils.js | 1 - src/common/utils.js | 35 ++++---- .../commentCarousel/CommentCarousel.jsx | 4 +- src/mainPage/features/fcfs/mock.js | 17 ++-- src/mainPage/shared/realtimeEvent/store.js | 8 +- 27 files changed, 498 insertions(+), 350 deletions(-) diff --git a/src/adminPage/App.jsx b/src/adminPage/App.jsx index 60ac99a7..94aca487 100644 --- a/src/adminPage/App.jsx +++ b/src/adminPage/App.jsx @@ -23,11 +23,7 @@ function App() { <> }> - } - /> + } /> -
-
-

{title}

-

*는 필수 입력

-
-
- - - -
-
- {children} - +function EventEditContainer({ title, children }) { + return ( +
+
+
+

{title}

+

*는 필수 입력

+
+
+ + + +
+
+ {children} +
+ ); } -export default EventEditContainer; \ No newline at end of file +export default EventEditContainer; diff --git a/src/adminPage/features/eventEdit/index.jsx b/src/adminPage/features/eventEdit/index.jsx index f9e20b87..176ca6b9 100644 --- a/src/adminPage/features/eventEdit/index.jsx +++ b/src/adminPage/features/eventEdit/index.jsx @@ -1,21 +1,25 @@ import Input from "@common/components/Input.jsx"; -function EventEditor({defaultValue}) -{ - return
- - -
- 이벤트 기간* - -
-
+function EventEditor() { + return ( +
+ + +
+ + 이벤트 기간* + +
+
+ ); } -export default EventEditor; \ No newline at end of file +export default EventEditor; diff --git a/src/adminPage/features/eventList/DeleteButton.jsx b/src/adminPage/features/eventList/DeleteButton.jsx index 84bafe63..d77e84f1 100644 --- a/src/adminPage/features/eventList/DeleteButton.jsx +++ b/src/adminPage/features/eventList/DeleteButton.jsx @@ -5,34 +5,51 @@ import AlertModal from "@admin/modals/AlertModal.jsx"; import Button from "@common/components/Button.jsx"; import openModal from "@common/modal/openModal.js"; -function DeleteButton({selected, reset}) -{ - const mutate = useMutation( - "admin-event-list", - ()=>fetchServer("/api/v1/admin/events", { - method: "delete", - body: { - eventIds: [...selected] - } - }), - { - onSuccess: ()=>{ - openModal(); - reset(); - } - } - ); - const deleteConfirmModal = - 이 동작은 다시 돌이킬 수 없습니다. -
- {selected.keys().next().value}{selected.size > 1 && ` 외 ${selected.size - 1} 개의`} 이벤트를 삭제하시겠습니까? - } onConfirm={mutate} />; +function DeleteButton({ selected, reset }) { + const mutate = useMutation( + "admin-event-list", + () => + fetchServer("/api/v1/admin/events", { + method: "delete", + body: { + eventIds: [...selected], + }, + }), + { + onSuccess: () => { + openModal( + , + ); + reset(); + }, + }, + ); + const deleteConfirmModal = ( + + 이 동작은 다시 돌이킬 수 없습니다. +
+ + {selected.keys().next().value} + {selected.size > 1 && ` 외 ${selected.size - 1} 개의`} 이벤트를 + 삭제하시겠습니까? + + + } + onConfirm={mutate} + /> + ); - function onClick() - { - openModal(deleteConfirmModal); - } - return + function onClick() { + openModal(deleteConfirmModal); + } + return ( + + ); } -export default DeleteButton; \ No newline at end of file +export default DeleteButton; diff --git a/src/adminPage/features/eventList/checkReducer.js b/src/adminPage/features/eventList/checkReducer.js index 9b37e009..9837918d 100644 --- a/src/adminPage/features/eventList/checkReducer.js +++ b/src/adminPage/features/eventList/checkReducer.js @@ -2,21 +2,23 @@ function checkReducer(state, action) { switch (action.type) { case "reset": return new Set(); - case "check_key":{ - const newSet = new Set(state); - if(action.value === true) newSet.add(action.key); - else if(action.value === false) newSet.delete(action.key); - else if(state.has(action.key)) newSet.delete(action.key); - else newSet.add(action.key); - return newSet;} - case "toggle_keys":{ - const newSet = new Set(state); - let allFalse = action.keys.every( key=>state.has(key) === false ); - if(allFalse) action.keys.forEach( key=>newSet.add(key) ); - else action.keys.forEach( key=>newSet.delete(key) ); - return newSet;} + case "check_key": { + const newSet = new Set(state); + if (action.value === true) newSet.add(action.key); + else if (action.value === false) newSet.delete(action.key); + else if (state.has(action.key)) newSet.delete(action.key); + else newSet.add(action.key); + return newSet; + } + case "toggle_keys": { + const newSet = new Set(state); + let allFalse = action.keys.every((key) => state.has(key) === false); + if (allFalse) action.keys.forEach((key) => newSet.add(key)); + else action.keys.forEach((key) => newSet.delete(key)); + return newSet; + } } throw Error("unknown action."); } -export default checkReducer; \ No newline at end of file +export default checkReducer; diff --git a/src/adminPage/features/eventList/index.jsx b/src/adminPage/features/eventList/index.jsx index 2b241f3d..ec05408c 100644 --- a/src/adminPage/features/eventList/index.jsx +++ b/src/adminPage/features/eventList/index.jsx @@ -1,7 +1,11 @@ import { useReducer, useDeferredValue } from "react"; import { Link } from "react-router-dom"; -import { searchReducer, setDefaultState, searchStateToQuery } from "./queryReducer.js"; +import { + searchReducer, + setDefaultState, + searchStateToQuery, +} from "./queryReducer.js"; import checkReducer from "./checkReducer.js"; import SearchBar from "./SearchBar.jsx"; @@ -16,24 +20,34 @@ function EventList() { const [state, dispatch] = useReducer(searchReducer, null, setDefaultState); const [checkSet, setCheck] = useReducer(checkReducer, new Set()); const query = useDeferredValue(searchStateToQuery(state)); - const resetCheck = ()=>setCheck({type:"reset"}); + const resetCheck = () => setCheck({ type: "reset" }); return (
- + + +
- { - dispatch({type:"set_query", value}); - resetCheck(); - } } /> + { + dispatch({ type: "set_query", value }); + resetCheck(); + }} + />
Error
}> login}> - + diff --git a/src/adminPage/features/eventList/mock.js b/src/adminPage/features/eventList/mock.js index c35d89f4..558def55 100644 --- a/src/adminPage/features/eventList/mock.js +++ b/src/adminPage/features/eventList/mock.js @@ -4,76 +4,72 @@ import { makeLorem } from "@common/mock/utils.js"; function getEventsMock() { return Array.from({ length: 100 }, (_, i) => { const startTime = new Date( - Date.now() - 86400 * 30 * 1000 + Math.floor(Math.random() * 86400 * 60 * 1000), + Date.now() - + 86400 * 30 * 1000 + + Math.floor(Math.random() * 86400 * 60 * 1000), + ); + const endTime = new Date( + startTime.getTime() + Math.floor(Math.random() * 86400 * 120) * 1000, ); - const endTime = new Date(startTime.getTime() + Math.floor(Math.random() * 86400 * 120) * 1000); return { name: makeLorem(3, 7), eventType: Math.random() > 0.5 ? "fcfs" : "draw", startTime, endTime, - eventId: `HD_240808_${i.toString().padStart(3, "0")}` + eventId: `HD_240808_${i.toString().padStart(3, "0")}`, }; }); } const dummyData = getEventsMock(); -function filterData(filterParam) -{ +function filterData(filterParam) { const filterKey = filterParam.split(","); - return function(data) - { - if(filterKey.length === 0) return true; - for(let key of filterKey) - { - if(key === "fcfs" && data.eventType === "fcfs") return true; - if(key === "draw" && data.eventType === "draw") return true; + return function (data) { + if (filterKey.length === 0) return true; + for (let key of filterKey) { + if (key === "fcfs" && data.eventType === "fcfs") return true; + if (key === "draw" && data.eventType === "draw") return true; } return false; - } + }; } -function compareString(a, b) -{ - if(a < b) return -1; - if(a > b) return 1; +function compareString(a, b) { + if (a < b) return -1; + if (a > b) return 1; return 0; } - -function sortData(sortParam) -{ - const sortKey = sortParam.split(",").map( keyValue=>keyValue.split(":") ); - return function(a, b) - { - for(let [key, sorter] of sortKey) - { +function sortData(sortParam) { + const sortKey = sortParam.split(",").map((keyValue) => keyValue.split(":")); + return function (a, b) { + for (let [key, sorter] of sortKey) { const pm = sorter === "desc" ? -1 : 1; - if(key === "eventId") { + if (key === "eventId") { const compared = compareString(a.eventId, b.eventId) * pm; - if(compared !== 0) return compared; + if (compared !== 0) return compared; } - if(key === "name") { + if (key === "name") { const compared = compareString(a.name, b.name) * pm; - if(compared !== 0) return compared; - } - if(key === "startTime") { + if (compared !== 0) return compared; + } + if (key === "startTime") { const compared = (a.startTime - b.startTime) * pm; - if(compared !== 0) return compared; - } - if(key === "endTime") { + if (compared !== 0) return compared; + } + if (key === "endTime") { const compared = (a.endTime - b.endTime) * pm; - if(compared !== 0) return compared; + if (compared !== 0) return compared; } - if(key === "eventType") { + if (key === "eventType") { const compared = compareString(a.eventType, b.eventType) * pm; - if(compared !== 0) return compared; + if (compared !== 0) return compared; } } return 0; - } + }; } const handlers = [ @@ -86,20 +82,19 @@ const handlers = [ const size = +url.searchParams.get("size") ?? 5; const result = dummyData - .filter( ({name})=>search === null ? true : name.includes(search) ) - .filter( filterData(filter) ) - .sort( sortData(sort) ) - .slice( (page-1) * size, (page) * size ); + .filter(({ name }) => (search === null ? true : name.includes(search))) + .filter(filterData(filter)) + .sort(sortData(sort)) + .slice((page - 1) * size, page * size); return HttpResponse.json(result); }), http.delete("/api/v1/admin/events", async ({ request }) => { const { eventIds } = await request.json(); - for(let id of eventIds) - { - const index = dummyData.findIndex( ({eventId})=>eventId === id ); - if(index === -1) continue; + for (let id of eventIds) { + const index = dummyData.findIndex(({ eventId }) => eventId === id); + if (index === -1) continue; dummyData.splice(index, 1); } diff --git a/src/adminPage/features/eventList/queryReducer.js b/src/adminPage/features/eventList/queryReducer.js index 2c8bb0fd..04b98192 100644 --- a/src/adminPage/features/eventList/queryReducer.js +++ b/src/adminPage/features/eventList/queryReducer.js @@ -37,7 +37,10 @@ export function searchReducer(state, action) { }, }; case "set_page": - return { ...state, page: Number.isNaN(+action.value) ? 1 : +action.value }; + return { + ...state, + page: Number.isNaN(+action.value) ? 1 : +action.value, + }; } throw Error("unknown action."); } diff --git a/src/adminPage/features/eventList/table/SearchResultBody.jsx b/src/adminPage/features/eventList/table/SearchResultBody.jsx index 0d30315a..7c3a8495 100644 --- a/src/adminPage/features/eventList/table/SearchResultBody.jsx +++ b/src/adminPage/features/eventList/table/SearchResultBody.jsx @@ -1,15 +1,18 @@ import SearchResultItem from "./SearchResultItem.jsx"; -function SearchResultBody({data, checkState, setCheck}) -{ - return
- {data.map( item=> )} -
+function SearchResultBody({ data, checkState, setCheck }) { + return ( +
+ {data.map((item) => ( + + ))} +
+ ); } -export default SearchResultBody; \ No newline at end of file +export default SearchResultBody; diff --git a/src/adminPage/features/eventList/table/SearchResultItem.jsx b/src/adminPage/features/eventList/table/SearchResultItem.jsx index 3b88493d..eb7be91d 100644 --- a/src/adminPage/features/eventList/table/SearchResultItem.jsx +++ b/src/adminPage/features/eventList/table/SearchResultItem.jsx @@ -6,24 +6,55 @@ import Button from "@common/components/Button.jsx"; import Checkbox from "@common/components/Checkbox.jsx"; import { formatDate } from "@common/utils.js"; -function SearchResultItem({eventId, name, startTime, endTime, eventType, checked, setCheck }) -{ - return +function SearchResultItem({ + eventId, + name, + startTime, + endTime, + eventType, + checked, + setCheck, +}) { + return ( + + ); } -export default SearchResultItem; \ No newline at end of file +export default SearchResultItem; diff --git a/src/adminPage/features/eventList/table/TableHeader.jsx b/src/adminPage/features/eventList/table/TableHeader.jsx index 4ed133d0..94f3f84f 100644 --- a/src/adminPage/features/eventList/table/TableHeader.jsx +++ b/src/adminPage/features/eventList/table/TableHeader.jsx @@ -18,7 +18,11 @@ function TableHeader({ state, dispatch, checkSelect }) {
- {headerData.map(({ key, name }) => ( diff --git a/src/adminPage/features/eventList/table/index.jsx b/src/adminPage/features/eventList/table/index.jsx index 62ac5b65..4a79444d 100644 --- a/src/adminPage/features/eventList/table/index.jsx +++ b/src/adminPage/features/eventList/table/index.jsx @@ -1,5 +1,3 @@ -import { useDeferredValue } from "react"; - import TableHeader from "./TableHeader.jsx"; import SearchResultBody from "./SearchResultBody.jsx"; import Pagination from "@admin/components/Pagination.jsx"; @@ -7,32 +5,47 @@ import Pagination from "@admin/components/Pagination.jsx"; import { useQuery } from "@common/dataFetch/getQuery.js"; import { fetchServer } from "@common/dataFetch/fetchServer.js"; -function SearchResult({query, -queryState, -queryDispatch, -checkState, -checkDispatch}) -{ - const dataList = useQuery("admin-event-list", ()=>fetchServer(query), { - dependencyArray: [query], - deferred: true - }); - const page = 10; +function SearchResult({ + query, + queryState, + queryDispatch, + checkState, + checkDispatch, +}) { + const dataList = useQuery("admin-event-list", () => fetchServer(query), { + dependencyArray: [query], + deferred: true, + }); + const page = 10; - const checkSelect = () =>{ - const keys = dataList.map( ({eventId})=>eventId ); - checkDispatch({ type:"toggle_keys", keys }); - } + const checkSelect = () => { + const keys = dataList.map(({ eventId }) => eventId); + checkDispatch({ type: "toggle_keys", keys }); + }; - return <> - - { - return (value)=>checkDispatch({type:"check_key", key, value}); - } } /> -
- queryDispatch({type:"set_page", value})} maxPage={page} /> -
- + return ( + <> + + { + return (value) => checkDispatch({ type: "check_key", key, value }); + }} + /> +
+ queryDispatch({ type: "set_page", value })} + maxPage={page} + /> +
+ + ); } -export default SearchResult; \ No newline at end of file +export default SearchResult; diff --git a/src/adminPage/mock.js b/src/adminPage/mock.js index 0cea4d48..58928ebc 100644 --- a/src/adminPage/mock.js +++ b/src/adminPage/mock.js @@ -6,4 +6,8 @@ import eventSearchHandler from "./features/eventList/mock.js"; // mocking은 기본적으로 각 feature 폴더 내의 mock.js로 정의합니다. // 새로운 feature의 mocking을 추가하셨으면, mock.js의 setupWorker 내부 함수에 인자를 spread 연산자를 이용해 추가해주세요. // 예시 : export default setupWorker(...authHandler, ...questionHandler, ...articleHandler); -export default setupWorker(...authHandler, ...eventSearchHandler, ...serverTimeHandler); +export default setupWorker( + ...authHandler, + ...eventSearchHandler, + ...serverTimeHandler, +); diff --git a/src/adminPage/shared/components/Container.jsx b/src/adminPage/shared/components/Container.jsx index 50ae1e1a..38e4a8c4 100644 --- a/src/adminPage/shared/components/Container.jsx +++ b/src/adminPage/shared/components/Container.jsx @@ -1,10 +1,12 @@ import NavBar from "./NavBar.jsx"; -function Container({ children, shouldCenter=false }) { +function Container({ children, shouldCenter = false }) { return (
-
+
{children}
diff --git a/src/adminPage/shared/components/Pagination.jsx b/src/adminPage/shared/components/Pagination.jsx index 9a47f1d8..e187e041 100644 --- a/src/adminPage/shared/components/Pagination.jsx +++ b/src/adminPage/shared/components/Pagination.jsx @@ -1,36 +1,69 @@ import { clamp } from "@common/utils.js"; -function getPaginationItem(currentPage, maxPage, length) -{ - let prevDelta = length % 2 === 1 ? (length - 1) / 2 : length / 2 - 1; - let postDelta = length % 2 === 1 ? (length - 1) / 2 : length / 2; +function getPaginationItem(currentPage, maxPage, length) { + let prevDelta = length % 2 === 1 ? (length - 1) / 2 : length / 2 - 1; + let postDelta = length % 2 === 1 ? (length - 1) / 2 : length / 2; - if(currentPage - prevDelta <= 0) return Array.from({length}, (_, i)=>i+1); - if(currentPage + postDelta > maxPage) return Array.from({length}, (_, i)=>maxPage - length + i + 1); - return Array.from({length}, (_, i)=>currentPage - prevDelta + i); + if (currentPage - prevDelta <= 0) + return Array.from({ length }, (_, i) => i + 1); + if (currentPage + postDelta > maxPage) + return Array.from({ length }, (_, i) => maxPage - length + i + 1); + return Array.from({ length }, (_, i) => currentPage - prevDelta + i); } -function PaginationButton({onClick, disabled, highlighted, children}) -{ - return +function PaginationButton({ onClick, disabled, highlighted, children }) { + return ( + + ); } -function Pagination({currentPage, setPage: _setPage, maxPage, length=5}) -{ - const setPage = (index)=>()=>_setPage(clamp(index, 1, maxPage)); +function Pagination({ currentPage, setPage: _setPage, maxPage, length = 5 }) { + const setPage = (index) => () => _setPage(clamp(index, 1, maxPage)); - return
- << - < - { - getPaginationItem(currentPage, maxPage, length).map( (i)=>{i} ) - } - maxPage}>> - maxPage}>>> -
+ return ( +
+ + << + + + < + + {getPaginationItem(currentPage, maxPage, length).map((i) => ( + + {i} + + ))} + maxPage} + > + > + + maxPage} + > + >> + +
+ ); } -export default Pagination; \ No newline at end of file +export default Pagination; diff --git a/src/adminPage/shared/modals/AlertModal.jsx b/src/adminPage/shared/modals/AlertModal.jsx index 214d3951..ecc8e38f 100644 --- a/src/adminPage/shared/modals/AlertModal.jsx +++ b/src/adminPage/shared/modals/AlertModal.jsx @@ -2,27 +2,27 @@ import { useContext } from "react"; import { ModalCloseContext } from "@common/modal/modal.jsx"; import Button from "@common/components/Button.jsx"; -function AlertModal({title, description}) -{ - const close = useContext(ModalCloseContext); +function AlertModal({ title, description }) { + const close = useContext(ModalCloseContext); - return
-
-
-

{title}

- -
-
{description}
-
-
- -
-
+ return ( +
+
+
+

{title}

+ +
+
{description}
+
+
+ +
+
+ ); } -export default AlertModal; \ No newline at end of file +export default AlertModal; diff --git a/src/adminPage/shared/modals/ConfirmModal.jsx b/src/adminPage/shared/modals/ConfirmModal.jsx index 357e4f09..3abc2aa2 100644 --- a/src/adminPage/shared/modals/ConfirmModal.jsx +++ b/src/adminPage/shared/modals/ConfirmModal.jsx @@ -2,28 +2,37 @@ import { useContext } from "react"; import { ModalCloseContext } from "@common/modal/modal.jsx"; import Button from "@common/components/Button.jsx"; -function ConfirmModal({title, description, onConfirm}) -{ - const close = useContext(ModalCloseContext); +function ConfirmModal({ title, description, onConfirm }) { + const close = useContext(ModalCloseContext); - return
-
-
-

{title}

- -
-
{description}
-
-
- - -
-
+ return ( +
+
+
+

{title}

+ +
+
{description}
+
+
+ + +
+
+ ); } -export default ConfirmModal; \ No newline at end of file +export default ConfirmModal; diff --git a/src/adminPage/shared/serverTime/EventStatus.js b/src/adminPage/shared/serverTime/EventStatus.js index 6c90eb4d..a8551314 100644 --- a/src/adminPage/shared/serverTime/EventStatus.js +++ b/src/adminPage/shared/serverTime/EventStatus.js @@ -1,14 +1,14 @@ import useServerTime from "./store.js"; -function EventStatus({startTime: _startTime, endTime: _endTime}) -{ - const serverTime = useServerTime( store=>store.serverTime ); - const startTime = _startTime instanceof Date ? _startTime : new Date(_startTime); - const endTime = _endTime instanceof Date ? _endTime : new Date(_endTime); +function EventStatus({ startTime: _startTime, endTime: _endTime }) { + const serverTime = useServerTime((store) => store.serverTime); + const startTime = + _startTime instanceof Date ? _startTime : new Date(_startTime); + const endTime = _endTime instanceof Date ? _endTime : new Date(_endTime); - if(startTime > serverTime) return "예정"; - if(endTime > serverTime) return "진행중"; - return "종료"; + if (startTime > serverTime) return "예정"; + if (endTime > serverTime) return "진행중"; + return "종료"; } -export default EventStatus; \ No newline at end of file +export default EventStatus; diff --git a/src/adminPage/shared/serverTime/ServerTimeInitializer.jsx b/src/adminPage/shared/serverTime/ServerTimeInitializer.jsx index 5c2be86d..84e2788b 100644 --- a/src/adminPage/shared/serverTime/ServerTimeInitializer.jsx +++ b/src/adminPage/shared/serverTime/ServerTimeInitializer.jsx @@ -2,20 +2,20 @@ import useServerTime from "./store.js"; import Suspense from "@common/components/Suspense.jsx"; import ErrorBoundary from "@common/components/ErrorBoundary.jsx"; -function ServerTimeInitializerInternal() -{ - const getData = useServerTime( store=>store.getData ); - getData(); - return null; +function ServerTimeInitializerInternal() { + const getData = useServerTime((store) => store.getData); + getData(); + return null; } -function ServerTimeInitializer() -{ - return - - - - +function ServerTimeInitializer() { + return ( + + + + + + ); } -export default ServerTimeInitializer; \ No newline at end of file +export default ServerTimeInitializer; diff --git a/src/adminPage/shared/serverTime/store.js b/src/adminPage/shared/serverTime/store.js index bebe4ec9..6a69f15c 100644 --- a/src/adminPage/shared/serverTime/store.js +++ b/src/adminPage/shared/serverTime/store.js @@ -2,16 +2,16 @@ import { create } from "zustand"; import { getQuerySuspense } from "@/common/dataFetch/getQuery.js"; import { getServerPresiseTime } from "@common/utils.js"; -const serverTimeStore = create((set)=>({ +const serverTimeStore = create((set) => ({ serverTime: new Date("2024-08-31 12:00"), // <-- dummy initial data - getData: ()=>{ - const promiseFn = async ()=>{ + getData: () => { + const promiseFn = async () => { const time = await getServerPresiseTime(); - set({serverTime : new Date(time)}); + set({ serverTime: new Date(time) }); return time; - } + }; return getQuerySuspense("server-precise-time", promiseFn, [set]); - } + }, })); -export default serverTimeStore; \ No newline at end of file +export default serverTimeStore; diff --git a/src/common/components/Checkbox.jsx b/src/common/components/Checkbox.jsx index ddce7e90..54700331 100644 --- a/src/common/components/Checkbox.jsx +++ b/src/common/components/Checkbox.jsx @@ -1,4 +1,10 @@ -function Checkbox({ className, checked, onChange: userOnChange, defaultChecked, ...otherProps }) { +function Checkbox({ + className, + checked, + onChange: userOnChange, + defaultChecked, + ...otherProps +}) { const checkboxStyle = `${className} size-4 appearance-none border border-neutral-300 checked:bg-blue-400 checked:border-0 checked:bg-checked bg-center bg-cover`; @@ -7,8 +13,7 @@ function Checkbox({ className, checked, onChange: userOnChange, defaultChecked, userOnChange(target.checked); } - if(checked !== null && checked !== undefined) - { + if (checked !== null && checked !== undefined) { return ( - ) + ); } return ( ); diff --git a/src/common/dataFetch/getQuery.js b/src/common/dataFetch/getQuery.js index 3f8b03db..85c16328 100644 --- a/src/common/dataFetch/getQuery.js +++ b/src/common/dataFetch/getQuery.js @@ -5,26 +5,24 @@ const queryMap = new Map(); const queryObservers = new Map(); const CACHE_DURATION = 10 * 60 * 1000; -function subscribeQuery(key) -{ - return (callback)=>{ - if(!queryObservers.has(key)) queryObservers.set(key, new Set()); +function subscribeQuery(key) { + return (callback) => { + if (!queryObservers.has(key)) queryObservers.set(key, new Set()); const set = queryObservers.get(key); set.add(callback); - return ()=>{ + return () => { const set = queryObservers.get(key); set.delete(callback); - if(set.size === 0) queryObservers.delete(key); - } - } + if (set.size === 0) queryObservers.delete(key); + }; + }; } -function updateSubscribedQuery(key) -{ +function updateSubscribedQuery(key) { queryMap.delete(key); - if(!queryObservers.has(key)) return; - queryObservers.get(key).forEach( callback=>callback() ); + if (!queryObservers.has(key)) return; + queryObservers.get(key).forEach((callback) => callback()); } function isSame(arr1, arr2) { @@ -43,30 +41,31 @@ export function getQuery(key, promiseFn, dependencyArray = []) { return promise; } -export function useQuery(key, promiseFn, config={}) { - let _config = {dependencyArray: []}; - if(Array.isArray(config)) _config.dependencyArray = config; +export function useQuery(key, promiseFn, config = {}) { + let _config = { dependencyArray: [] }; + if (Array.isArray(config)) _config.dependencyArray = config; else _config = Object.assign(_config, config); - const query = useSyncExternalStore(subscribeQuery(key), ()=>getQuery(key, promiseFn, _config.dependencyArray)); + const query = useSyncExternalStore(subscribeQuery(key), () => + getQuery(key, promiseFn, _config.dependencyArray), + ); const deferredQuery = useDeferredValue(query); - if(_config.deferred) return use( deferredQuery ); + if (_config.deferred) return use(deferredQuery); return use(query); } -export function useMutation(key, promiseFn, {onSuccess, onError}={}) { - return async ()=>{ +export function useMutation(key, promiseFn, { onSuccess, onError } = {}) { + return async () => { try { const value = await promiseFn(); updateSubscribedQuery(key); onSuccess?.(value); - } - catch(e) { + } catch (e) { onError?.(e); - if(onError === undefined) throw e; + if (onError === undefined) throw e; } - } + }; } export function getQuerySuspense(key, promiseFn, dependencyArray = []) { diff --git a/src/common/mock/utils.js b/src/common/mock/utils.js index 7eae7bbb..cffa3324 100644 --- a/src/common/mock/utils.js +++ b/src/common/mock/utils.js @@ -16,4 +16,3 @@ export function makeLorem(min, max) { } return result.join(" "); } - diff --git a/src/common/utils.js b/src/common/utils.js index fc1ec08e..8f796cff 100644 --- a/src/common/utils.js +++ b/src/common/utils.js @@ -31,28 +31,31 @@ export function formatDate(rawDate, format) { const date = new Date(rawDate); const components = { - 'YYYY': date.getFullYear(), - 'YY': String(date.getFullYear()).slice(-2), - 'MM': String(date.getMonth() + 1).padStart(2, '0'), - 'M': date.getMonth() + 1, - 'DD': String(date.getDate()).padStart(2, '0'), - 'D': date.getDate(), - 'hh': String(date.getHours()).padStart(2, '0'), - 'h': date.getHours(), - 'mm': String(date.getMinutes()).padStart(2, '0'), - 'm': date.getMinutes(), - 'ss': String(date.getSeconds()).padStart(2, '0'), - 's': date.getSeconds() + YYYY: date.getFullYear(), + YY: String(date.getFullYear()).slice(-2), + MM: String(date.getMonth() + 1).padStart(2, "0"), + M: date.getMonth() + 1, + DD: String(date.getDate()).padStart(2, "0"), + D: date.getDate(), + hh: String(date.getHours()).padStart(2, "0"), + h: date.getHours(), + mm: String(date.getMinutes()).padStart(2, "0"), + m: date.getMinutes(), + ss: String(date.getSeconds()).padStart(2, "0"), + s: date.getSeconds(), }; - return format.replace(/YYYY|YY|MM|M|DD|D|hh|h|mm|m|ss|s/g, match => components[match]); + return format.replace( + /YYYY|YY|MM|M|DD|D|hh|h|mm|m|ss|s/g, + (match) => components[match], + ); } export async function getServerPresiseTime() { const startClientTime = performance.now(); - const { timestamp: serverTime } = await fetch("/api/serverTime").then((e) => - e.json(), - ).catch( ()=>new Date() ); + const { timestamp: serverTime } = await fetch("/api/serverTime") + .then((e) => e.json()) + .catch(() => new Date()); const networkPayloadTime = performance.now() - startClientTime; return new Date(serverTime).getTime() + networkPayloadTime; diff --git a/src/mainPage/features/comment/commentCarousel/CommentCarousel.jsx b/src/mainPage/features/comment/commentCarousel/CommentCarousel.jsx index 9bab86ad..e021f4a9 100644 --- a/src/mainPage/features/comment/commentCarousel/CommentCarousel.jsx +++ b/src/mainPage/features/comment/commentCarousel/CommentCarousel.jsx @@ -27,7 +27,9 @@ function CommentCarousel() {

{content}

{mask(userName)} 님

-

{formatDate(createdAt, "YYYY. MM. DD")}

+

+ {formatDate(createdAt, "YYYY. MM. DD")} +

))} diff --git a/src/mainPage/features/fcfs/mock.js b/src/mainPage/features/fcfs/mock.js index eafea143..83afb158 100644 --- a/src/mainPage/features/fcfs/mock.js +++ b/src/mainPage/features/fcfs/mock.js @@ -14,15 +14,18 @@ const handlers = [ eventStatus: "countdown", }); }), - http.get("/api/v1/event/fcfs/:eventFrameId/participated", async ({ request }) => { - const token = request.headers.get("authorization"); - if (token === null) - return HttpResponse.json({ answerResult: false, winner: false }); + http.get( + "/api/v1/event/fcfs/:eventFrameId/participated", + async ({ request }) => { + const token = request.headers.get("authorization"); + if (token === null) + return HttpResponse.json({ answerResult: false, winner: false }); - //await delay(10000); + //await delay(10000); - return HttpResponse.json({ answerResult: false, winner: false }); - }), + return HttpResponse.json({ answerResult: false, winner: false }); + }, + ), http.post("/api/v1/event/fcfs/:eventFrameId", async ({ request }) => { const { eventAnswer } = await request.json(); diff --git a/src/mainPage/shared/realtimeEvent/store.js b/src/mainPage/shared/realtimeEvent/store.js index b59527b9..7cc6433c 100644 --- a/src/mainPage/shared/realtimeEvent/store.js +++ b/src/mainPage/shared/realtimeEvent/store.js @@ -13,7 +13,9 @@ const HOURS = 60 * 60; async function getFcfsEventInfo() { try { - const eventData = await fetchServer(`/api/v1/event/fcfs/${EVENT_FCFS_ID}/info`); + const eventData = await fetchServer( + `/api/v1/event/fcfs/${EVENT_FCFS_ID}/info`, + ); return eventData; } catch (e) { if (e instanceof HTTPError && e.status === 404) @@ -32,7 +34,9 @@ async function getFcfsEventInfo() { async function getFcfsParticipated() { try { - const eventData = await fetchServer(`/api/v1/event/fcfs/${EVENT_FCFS_ID}/participated`); // ??? + const eventData = await fetchServer( + `/api/v1/event/fcfs/${EVENT_FCFS_ID}/participated`, + ); // ??? return eventData; } catch (e) { if (e instanceof HTTPError && (e.status === 401 || e.status == 404))