From cbb1e790134f88a737c4dacf22b44d82b785c3e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EC=9A=B1?= Date: Fri, 24 Feb 2023 16:42:23 +0900 Subject: [PATCH 01/17] =?UTF-8?q?[Feat]=20api=20=EC=9A=94=EC=B2=AD=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=20=EB=B3=80=EA=B2=BD=20/=20=EC=8A=A4?= =?UTF-8?q?=EC=BC=80=EC=A5=B4=20=EC=8A=AC=EB=A1=AF=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?#663?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/scheduler/SchedulerCurrent.tsx | 12 +-- components/admin/scheduler/SchedulerMain.tsx | 87 +++++++++++++++---- .../admin/scheduler/SchedulerPreview.tsx | 55 ++++++++++-- 3 files changed, 124 insertions(+), 30 deletions(-) diff --git a/components/admin/scheduler/SchedulerCurrent.tsx b/components/admin/scheduler/SchedulerCurrent.tsx index cf231d875..71227c04c 100644 --- a/components/admin/scheduler/SchedulerCurrent.tsx +++ b/components/admin/scheduler/SchedulerCurrent.tsx @@ -15,19 +15,14 @@ type Slots = { mode: string; }; -export default function SchedulerCurrent() { +export default function SchedulerCurrent(props: { slotInfo: Match }) { const [slotInfo, setSlotInfo] = useState({ intervalMinute: 0, matchBoards: [], }); - const initSlotInfo = async () => { - try { - const res = await instance.get(`/pingpong/match/tables/${1}/rank/single`); - setSlotInfo({ ...res?.data }); - } catch (e) { - console.error(e); - } + const initSlotInfo = () => { + setSlotInfo(props.slotInfo); }; useEffect(() => { @@ -37,7 +32,6 @@ export default function SchedulerCurrent() { return (
{slotInfo.matchBoards.map((slot: Slots[], index) => { - console.log(slot.length); return (
diff --git a/components/admin/scheduler/SchedulerMain.tsx b/components/admin/scheduler/SchedulerMain.tsx index 5273af0c5..7216043ba 100644 --- a/components/admin/scheduler/SchedulerMain.tsx +++ b/components/admin/scheduler/SchedulerMain.tsx @@ -4,22 +4,43 @@ import styles from 'styles/admin/scheduler/SchedulerEdit.module.scss'; import SchedulerCurrent from './SchedulerCurrent'; import SchedulerPreview from './SchedulerPreview'; -interface EditedSchedule { +type EditedSchedule = { viewTimePast: number; viewTimeFuture: number; - gameTime: 15 | 30 | 60; + gameTime: number; blindShowTime: number; -} +}; + +type Match = { + intervalMinute: number; + matchBoards: Slots[][]; +}; + +type Slots = { + slotId: number; + status: string; + headCount: number; + time: string; + mode: string; +}; export default function SchedulerMain() { const [scheduleInfo, setScheduleInfo] = useState({ - viewTimePast: 6, - viewTimeFuture: 6, + viewTimePast: 0, + viewTimeFuture: 0, gameTime: 15, blindShowTime: 5, }); - const initInfo = async () => { + const [slotInfo, setSlotInfo] = useState({ + intervalMinute: 0, + matchBoards: [], + }); + + const [showTime, setShowTime] = useState(0); + const [lastHour, setLastHour] = useState(0); + + const initScheduleInfo = async () => { try { // const res = await instance.get(``); //ToDo: api 명세 나오면 바꾸기 // setScheduleInfo(res?.data); @@ -28,15 +49,32 @@ export default function SchedulerMain() { } }; + const initSlotInfo = async () => { + try { + const res = await instance.get(`/pingpong/match/tables/${1}/rank/single`); + setSlotInfo({ ...res?.data }); + setShowTime(res?.data.matchBoards.length); + setLastHour( + parseInt( + res?.data.matchBoards[res?.data.matchBoards.length - 1][0].time[11] + ) * + 10 + + parseInt( + res?.data.matchBoards[res?.data.matchBoards.length - 1][0].time[12] + ) + + 1 + ); + } catch (e) { + console.error(e); + } + }; + useEffect(() => { - initInfo(); + initScheduleInfo(); + initSlotInfo(); }, []); - const inputHandler = ( - e: - | React.ChangeEvent - | React.ChangeEvent - ) => { + const inputHandler = (e: React.ChangeEvent) => { const { name, value } = e.target; setScheduleInfo((prev) => ({ ...prev, @@ -44,11 +82,30 @@ export default function SchedulerMain() { })); }; + const inputNumHandler = (e: React.ChangeEvent) => { + const { name, value } = e.target; + const intValue = parseInt(value); + console.log(intValue); + setScheduleInfo((prev) => ({ + ...prev, + [name]: intValue, + })); + }; + return (
- - + {slotInfo.matchBoards.length > 0 && ( + + )} + {scheduleInfo.viewTimeFuture + scheduleInfo.viewTimeFuture > 0 && + showTime > 0 && ( + + )}
@@ -63,7 +120,7 @@ export default function SchedulerMain() {
게임 시간 - diff --git a/components/admin/scheduler/SchedulerPreview.tsx b/components/admin/scheduler/SchedulerPreview.tsx index 7cb606301..a13aa08ab 100644 --- a/components/admin/scheduler/SchedulerPreview.tsx +++ b/components/admin/scheduler/SchedulerPreview.tsx @@ -1,16 +1,59 @@ import { useEffect, useState } from 'react'; -export default function SchedulerPreview(props: any) { - const [slotPrevInfo, setSlotPrevInfo] = useState({ - slot: [], +type EditedSchedule = { + viewTimePast: number; + viewTimeFuture: number; + gameTime: number; + blindShowTime: number; +}; + +type Slots = { + status: string; + time: number; +}; + +type Match = { + intervalMinute: number; + matchBoards: Slots[][]; +}; + +export default function SchedulerPreview(props: { + scheduleInfo: EditedSchedule; + showTime: number; + lastHour: number; +}) { + const { showTime, lastHour, scheduleInfo } = props; + const [slotInfo, setSlotInfo] = useState({ + intervalMinute: 0, + matchBoards: [], }); + useEffect(() => { + console.log(slotInfo); + }, [slotInfo]); + useEffect(() => { initSlotInfo(); - }, []); + }, [props]); const initSlotInfo = () => { - //ToDo: props.scheduleInfo 토대로 슬롯 정보 객체 생성 + const scheduleTime: number = + parseInt(`${scheduleInfo.viewTimePast}`) + + parseInt(`${scheduleInfo.viewTimeFuture}`); + if (scheduleTime >= showTime) { + const slots: Slots[][] = Array(scheduleTime - showTime + 1) + .fill(null) + .map((i: number) => + Array(60 / scheduleInfo.gameTime).fill({ + status: 'open', + time: lastHour + i >= 24 ? (lastHour + i) % 24 : lastHour + i, + }) + ); + setSlotInfo({ + intervalMinute: scheduleInfo.gameTime, + matchBoards: slots, + }); + } }; - return
{/* ToDo: 새로 생성되는 슬롯 */}
; + return
; } From 6087827ebafce366927d6a9bcabe8a39b0d5cb06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EC=9A=B1?= Date: Sun, 26 Feb 2023 12:41:59 +0900 Subject: [PATCH 02/17] =?UTF-8?q?[Feat]=20preview=20=EC=8A=AC=EB=A1=AF=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20#684?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/scheduler/SchedulerPreview.tsx | 30 +++++++++++++++++-- .../scheduler/SchedulerCurrent.module.scss | 4 +++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/components/admin/scheduler/SchedulerPreview.tsx b/components/admin/scheduler/SchedulerPreview.tsx index a13aa08ab..14937a24c 100644 --- a/components/admin/scheduler/SchedulerPreview.tsx +++ b/components/admin/scheduler/SchedulerPreview.tsx @@ -1,4 +1,5 @@ import { useEffect, useState } from 'react'; +import styles from 'styles/admin/scheduler/SchedulerCurrent.module.scss'; type EditedSchedule = { viewTimePast: number; @@ -10,6 +11,7 @@ type EditedSchedule = { type Slots = { status: string; time: number; + slotId: string; }; type Match = { @@ -43,10 +45,11 @@ export default function SchedulerPreview(props: { if (scheduleTime >= showTime) { const slots: Slots[][] = Array(scheduleTime - showTime + 1) .fill(null) - .map((i: number) => + .map((i: number, index: number) => Array(60 / scheduleInfo.gameTime).fill({ - status: 'open', + status: 'preview', time: lastHour + i >= 24 ? (lastHour + i) % 24 : lastHour + i, + slotId: `${index}-${i}`, }) ); setSlotInfo({ @@ -55,5 +58,26 @@ export default function SchedulerPreview(props: { }); } }; - return
; + return ( +
+ {slotInfo.matchBoards.map((slot: Slots[], index) => { + return ( +
+
{slot[0].time}시
+
+ {slot.map((item) => ( +
+
{item.status}
+
+ ))} +
+
+ ); + })} +
+ ); } diff --git a/styles/admin/scheduler/SchedulerCurrent.module.scss b/styles/admin/scheduler/SchedulerCurrent.module.scss index 32051e8fe..8c2cab49a 100644 --- a/styles/admin/scheduler/SchedulerCurrent.module.scss +++ b/styles/admin/scheduler/SchedulerCurrent.module.scss @@ -48,3 +48,7 @@ .close { background-color: lightcoral; } + +.preview { + background-color: lightblue; +} From 3a9fb4c86181fd9949402ef5b0cd9bff56a9d723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EC=9A=B1?= Date: Sun, 26 Feb 2023 13:10:43 +0900 Subject: [PATCH 03/17] =?UTF-8?q?[Feat]=20preview=EC=8A=AC=EB=A1=AF=20?= =?UTF-8?q?=EA=B3=A0=EC=9C=A0id=20=EC=83=9D=EC=84=B1=20#684?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/admin/scheduler/SchedulerCurrent.tsx | 5 ++++- components/admin/scheduler/SchedulerMain.tsx | 8 +++++++- components/admin/scheduler/SchedulerPreview.tsx | 17 +++++++++++------ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/components/admin/scheduler/SchedulerCurrent.tsx b/components/admin/scheduler/SchedulerCurrent.tsx index 71227c04c..bd0ef4cb1 100644 --- a/components/admin/scheduler/SchedulerCurrent.tsx +++ b/components/admin/scheduler/SchedulerCurrent.tsx @@ -15,7 +15,10 @@ type Slots = { mode: string; }; -export default function SchedulerCurrent(props: { slotInfo: Match }) { +export default function SchedulerCurrent(props: { + slotInfo: Match; + scheduleInfo: any; +}) { const [slotInfo, setSlotInfo] = useState({ intervalMinute: 0, matchBoards: [], diff --git a/components/admin/scheduler/SchedulerMain.tsx b/components/admin/scheduler/SchedulerMain.tsx index 7216043ba..7e1f6424e 100644 --- a/components/admin/scheduler/SchedulerMain.tsx +++ b/components/admin/scheduler/SchedulerMain.tsx @@ -9,6 +9,7 @@ type EditedSchedule = { viewTimeFuture: number; gameTime: number; blindShowTime: number; + futurePreview: number; }; type Match = { @@ -30,6 +31,7 @@ export default function SchedulerMain() { viewTimeFuture: 0, gameTime: 15, blindShowTime: 5, + futurePreview: 0, }); const [slotInfo, setSlotInfo] = useState({ @@ -96,7 +98,7 @@ export default function SchedulerMain() {
{slotInfo.matchBoards.length > 0 && ( - + )} {scheduleInfo.viewTimeFuture + scheduleInfo.viewTimeFuture > 0 && showTime > 0 && ( @@ -130,6 +132,10 @@ export default function SchedulerMain() { 블라인드 해제 시간
+
+ N시간 후: + +
); diff --git a/components/admin/scheduler/SchedulerPreview.tsx b/components/admin/scheduler/SchedulerPreview.tsx index 14937a24c..e0f1bff8e 100644 --- a/components/admin/scheduler/SchedulerPreview.tsx +++ b/components/admin/scheduler/SchedulerPreview.tsx @@ -45,12 +45,17 @@ export default function SchedulerPreview(props: { if (scheduleTime >= showTime) { const slots: Slots[][] = Array(scheduleTime - showTime + 1) .fill(null) - .map((i: number, index: number) => - Array(60 / scheduleInfo.gameTime).fill({ - status: 'preview', - time: lastHour + i >= 24 ? (lastHour + i) % 24 : lastHour + i, - slotId: `${index}-${i}`, - }) + .map((_, index: number) => + Array(60 / scheduleInfo.gameTime) + .fill(null) + .map((_, slotIndex: number) => ({ + status: 'preview', + time: + lastHour + index >= 24 + ? (lastHour + index) % 24 + : lastHour + index, + slotId: `${index}-${slotIndex}`, + })) ); setSlotInfo({ intervalMinute: scheduleInfo.gameTime, From ecf3c0faf2203db05b9d752845a2c8dbb0fb8ed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EC=9A=B1?= Date: Sun, 26 Feb 2023 13:32:48 +0900 Subject: [PATCH 04/17] =?UTF-8?q?[Feat]=20n=EC=8B=9C=EA=B0=84=ED=9B=84=20c?= =?UTF-8?q?urrent=EC=8A=AC=EB=A1=AF=20=EC=83=81=ED=83=9C=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=20#684?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/scheduler/SchedulerCurrent.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/components/admin/scheduler/SchedulerCurrent.tsx b/components/admin/scheduler/SchedulerCurrent.tsx index bd0ef4cb1..b91fa84bf 100644 --- a/components/admin/scheduler/SchedulerCurrent.tsx +++ b/components/admin/scheduler/SchedulerCurrent.tsx @@ -25,12 +25,26 @@ export default function SchedulerCurrent(props: { }); const initSlotInfo = () => { - setSlotInfo(props.slotInfo); + const updatedMatchBoards = props.slotInfo.matchBoards.map( + (slots, index) => { + if (index < props.scheduleInfo.futurePreview) { + const updatedSlots = slots.map((slot) => { + return { ...slot, status: 'noSlot' }; + }); + return updatedSlots; + } + return slots; + } + ); + setSlotInfo({ + ...props.slotInfo, + matchBoards: updatedMatchBoards, + }); }; useEffect(() => { initSlotInfo(); - }, []); + }, [props]); return (
From 77713b7532fe0e6e02f898fd81567fa791b19ffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EC=9A=B1?= Date: Sun, 26 Feb 2023 15:53:45 +0900 Subject: [PATCH 05/17] =?UTF-8?q?[Feat]=20current=20=EC=8A=AC=EB=A1=AF=20c?= =?UTF-8?q?lose=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20#684?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/scheduler/SchedulerCurrent.tsx | 10 +++++++++ .../admin/scheduler/SchedulerPreview.tsx | 22 ++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/components/admin/scheduler/SchedulerCurrent.tsx b/components/admin/scheduler/SchedulerCurrent.tsx index b91fa84bf..59a9cbc9b 100644 --- a/components/admin/scheduler/SchedulerCurrent.tsx +++ b/components/admin/scheduler/SchedulerCurrent.tsx @@ -32,6 +32,16 @@ export default function SchedulerCurrent(props: { return { ...slot, status: 'noSlot' }; }); return updatedSlots; + } else if ( + index <= + parseInt(`${props.scheduleInfo.viewTimePast}`) + + parseInt(`${props.scheduleInfo.futurePreview}`) + + 1 + ) { + const updatedSlots = slots.map((slot) => { + return { ...slot, status: 'close' }; + }); + return updatedSlots; } return slots; } diff --git a/components/admin/scheduler/SchedulerPreview.tsx b/components/admin/scheduler/SchedulerPreview.tsx index e0f1bff8e..42670068b 100644 --- a/components/admin/scheduler/SchedulerPreview.tsx +++ b/components/admin/scheduler/SchedulerPreview.tsx @@ -6,6 +6,7 @@ type EditedSchedule = { viewTimeFuture: number; gameTime: number; blindShowTime: number; + futurePreview: number; }; type Slots = { @@ -41,15 +42,30 @@ export default function SchedulerPreview(props: { const initSlotInfo = () => { const scheduleTime: number = parseInt(`${scheduleInfo.viewTimePast}`) + - parseInt(`${scheduleInfo.viewTimeFuture}`); + parseInt(`${scheduleInfo.viewTimeFuture}`) + + parseInt(`${scheduleInfo.futurePreview}`); if (scheduleTime >= showTime) { - const slots: Slots[][] = Array(scheduleTime - showTime + 1) + const slots: Slots[][] = Array( + parseInt(`${scheduleInfo.viewTimePast}`) + + parseInt(`${scheduleInfo.viewTimeFuture}`) > + showTime + ? scheduleTime - showTime + : scheduleTime - showTime + 1 + ) .fill(null) .map((_, index: number) => Array(60 / scheduleInfo.gameTime) .fill(null) .map((_, slotIndex: number) => ({ - status: 'preview', + status: + showTime + index < scheduleInfo.futurePreview + ? 'noSlot' + : index >= scheduleInfo.futurePreview + ? 'preview' + : scheduleInfo.futurePreview > + parseInt(`${scheduleInfo.viewTimePast}`) + index + ? 'close' + : 'open', time: lastHour + index >= 24 ? (lastHour + index) % 24 From 37ea35ebab3ba014d68128570be1c50a712dfbb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EC=9A=B1?= Date: Sun, 26 Feb 2023 20:25:36 +0900 Subject: [PATCH 06/17] =?UTF-8?q?[Feat]=20=ED=98=84=EC=9E=AC=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=20=EA=B8=B0=EC=A4=80=EC=9C=BC=EB=A1=9C=20=EC=8A=AC?= =?UTF-8?q?=EB=A1=AF=20=EC=83=9D=EC=84=B1=20#684?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/scheduler/SchedulerCurrent.tsx | 22 +++++++-- components/admin/scheduler/SchedulerMain.tsx | 14 +++++- .../admin/scheduler/SchedulerPreview.tsx | 48 +++++++++---------- 3 files changed, 53 insertions(+), 31 deletions(-) diff --git a/components/admin/scheduler/SchedulerCurrent.tsx b/components/admin/scheduler/SchedulerCurrent.tsx index 59a9cbc9b..c6ad808e8 100644 --- a/components/admin/scheduler/SchedulerCurrent.tsx +++ b/components/admin/scheduler/SchedulerCurrent.tsx @@ -18,6 +18,8 @@ type Slots = { export default function SchedulerCurrent(props: { slotInfo: Match; scheduleInfo: any; + firstHour: number; + currentHour: number; }) { const [slotInfo, setSlotInfo] = useState({ intervalMinute: 0, @@ -27,16 +29,26 @@ export default function SchedulerCurrent(props: { const initSlotInfo = () => { const updatedMatchBoards = props.slotInfo.matchBoards.map( (slots, index) => { - if (index < props.scheduleInfo.futurePreview) { + if ( + parseInt(`${props.firstHour}`) + index < + (parseInt(`${props.currentHour}`) - + parseInt(`${props.scheduleInfo.viewTimePast}`) < + 0 + ? parseInt(`${props.currentHour}`) - + parseInt(`${props.scheduleInfo.viewTimePast}`) + + 24 + : parseInt(`${props.currentHour}`) - + parseInt(`${props.scheduleInfo.viewTimePast}`)) + ) { const updatedSlots = slots.map((slot) => { return { ...slot, status: 'noSlot' }; }); return updatedSlots; } else if ( - index <= - parseInt(`${props.scheduleInfo.viewTimePast}`) + - parseInt(`${props.scheduleInfo.futurePreview}`) + - 1 + index < + parseInt(`${props.currentHour}`) - + parseInt(`${props.firstHour}`) + + parseInt(`${props.scheduleInfo.futurePreview}`) ) { const updatedSlots = slots.map((slot) => { return { ...slot, status: 'close' }; diff --git a/components/admin/scheduler/SchedulerMain.tsx b/components/admin/scheduler/SchedulerMain.tsx index 7e1f6424e..251e4781d 100644 --- a/components/admin/scheduler/SchedulerMain.tsx +++ b/components/admin/scheduler/SchedulerMain.tsx @@ -41,6 +41,8 @@ export default function SchedulerMain() { const [showTime, setShowTime] = useState(0); const [lastHour, setLastHour] = useState(0); + const [firstHour, setFirstHour] = useState(0); + const currentHour = new Date().getHours(); const initScheduleInfo = async () => { try { @@ -56,6 +58,10 @@ export default function SchedulerMain() { const res = await instance.get(`/pingpong/match/tables/${1}/rank/single`); setSlotInfo({ ...res?.data }); setShowTime(res?.data.matchBoards.length); + setFirstHour( + parseInt(res?.data.matchBoards[0][0].time[11]) * 10 + + parseInt(res?.data.matchBoards[0][0].time[12]) + ); setLastHour( parseInt( res?.data.matchBoards[res?.data.matchBoards.length - 1][0].time[11] @@ -98,13 +104,19 @@ export default function SchedulerMain() {
{slotInfo.matchBoards.length > 0 && ( - + )} {scheduleInfo.viewTimeFuture + scheduleInfo.viewTimeFuture > 0 && showTime > 0 && ( )} diff --git a/components/admin/scheduler/SchedulerPreview.tsx b/components/admin/scheduler/SchedulerPreview.tsx index 42670068b..c23fabbd5 100644 --- a/components/admin/scheduler/SchedulerPreview.tsx +++ b/components/admin/scheduler/SchedulerPreview.tsx @@ -24,8 +24,9 @@ export default function SchedulerPreview(props: { scheduleInfo: EditedSchedule; showTime: number; lastHour: number; + currentHour: number; }) { - const { showTime, lastHour, scheduleInfo } = props; + const { showTime, lastHour, scheduleInfo, currentHour } = props; const [slotInfo, setSlotInfo] = useState({ intervalMinute: 0, matchBoards: [], @@ -35,37 +36,28 @@ export default function SchedulerPreview(props: { console.log(slotInfo); }, [slotInfo]); - useEffect(() => { - initSlotInfo(); - }, [props]); + const initEmptySlot = () => { + const slots: Slots[][] = Array(0).fill(null); + return slots; + }; - const initSlotInfo = () => { + const initSlotInfo = (slots: Slots[][]) => { const scheduleTime: number = - parseInt(`${scheduleInfo.viewTimePast}`) + - parseInt(`${scheduleInfo.viewTimeFuture}`) + - parseInt(`${scheduleInfo.futurePreview}`); - if (scheduleTime >= showTime) { - const slots: Slots[][] = Array( - parseInt(`${scheduleInfo.viewTimePast}`) + - parseInt(`${scheduleInfo.viewTimeFuture}`) > - showTime - ? scheduleTime - showTime - : scheduleTime - showTime + 1 + parseInt(`${lastHour}`) - parseInt(`${currentHour}`) < 0 + ? parseInt(`${lastHour}`) - parseInt(`${currentHour}`) + 24 + : parseInt(`${lastHour}`) - parseInt(`${currentHour}`); + if (scheduleTime <= scheduleInfo.viewTimeFuture) { + const newSlots: Slots[][] = Array( + parseInt(`${scheduleInfo.viewTimeFuture}`) - + parseInt(`${scheduleTime}`) + + 1 ) .fill(null) .map((_, index: number) => Array(60 / scheduleInfo.gameTime) .fill(null) .map((_, slotIndex: number) => ({ - status: - showTime + index < scheduleInfo.futurePreview - ? 'noSlot' - : index >= scheduleInfo.futurePreview - ? 'preview' - : scheduleInfo.futurePreview > - parseInt(`${scheduleInfo.viewTimePast}`) + index - ? 'close' - : 'open', + status: 'preview', time: lastHour + index >= 24 ? (lastHour + index) % 24 @@ -75,10 +67,16 @@ export default function SchedulerPreview(props: { ); setSlotInfo({ intervalMinute: scheduleInfo.gameTime, - matchBoards: slots, + matchBoards: newSlots.concat(slots), }); } }; + + useEffect(() => { + const emptySlots = initEmptySlot(); + initSlotInfo(emptySlots); + }, [props]); + return (
{slotInfo.matchBoards.map((slot: Slots[], index) => { From 02bdc899b70faf36040aec4dd7ac77899fa0c55b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EC=9A=B1?= Date: Sun, 26 Feb 2023 20:35:22 +0900 Subject: [PATCH 07/17] =?UTF-8?q?[Feat]=20n=EC=8B=9C=EA=B0=84=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=A5=B8=20current=20noSlot=20=EC=88=98=EC=A0=95=20#6?= =?UTF-8?q?84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/admin/scheduler/SchedulerCurrent.tsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/components/admin/scheduler/SchedulerCurrent.tsx b/components/admin/scheduler/SchedulerCurrent.tsx index c6ad808e8..607d1133c 100644 --- a/components/admin/scheduler/SchedulerCurrent.tsx +++ b/components/admin/scheduler/SchedulerCurrent.tsx @@ -27,18 +27,15 @@ export default function SchedulerCurrent(props: { }); const initSlotInfo = () => { + const noSlotIndex: number = + parseInt(`${props.currentHour}`) + + parseInt(`${props.scheduleInfo.futurePreview}`) - + parseInt(`${props.scheduleInfo.viewTimePast}`); const updatedMatchBoards = props.slotInfo.matchBoards.map( (slots, index) => { if ( parseInt(`${props.firstHour}`) + index < - (parseInt(`${props.currentHour}`) - - parseInt(`${props.scheduleInfo.viewTimePast}`) < - 0 - ? parseInt(`${props.currentHour}`) - - parseInt(`${props.scheduleInfo.viewTimePast}`) + - 24 - : parseInt(`${props.currentHour}`) - - parseInt(`${props.scheduleInfo.viewTimePast}`)) + (noSlotIndex < 0 ? noSlotIndex + 24 : noSlotIndex) ) { const updatedSlots = slots.map((slot) => { return { ...slot, status: 'noSlot' }; From 08b98e9c083303e793be8c2a5a75386335af5be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EC=9A=B1?= Date: Sun, 26 Feb 2023 21:29:18 +0900 Subject: [PATCH 08/17] =?UTF-8?q?[Feat]=20preview=EC=8A=AC=EB=A1=AF=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=EA=B4=80=EB=A6=AC=20=EC=88=98=EC=A0=95=20#68?= =?UTF-8?q?4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/scheduler/SchedulerPreview.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/components/admin/scheduler/SchedulerPreview.tsx b/components/admin/scheduler/SchedulerPreview.tsx index c23fabbd5..213462979 100644 --- a/components/admin/scheduler/SchedulerPreview.tsx +++ b/components/admin/scheduler/SchedulerPreview.tsx @@ -50,6 +50,7 @@ export default function SchedulerPreview(props: { const newSlots: Slots[][] = Array( parseInt(`${scheduleInfo.viewTimeFuture}`) - parseInt(`${scheduleTime}`) + + parseInt(`${scheduleInfo.futurePreview}`) + 1 ) .fill(null) @@ -57,7 +58,23 @@ export default function SchedulerPreview(props: { Array(60 / scheduleInfo.gameTime) .fill(null) .map((_, slotIndex: number) => ({ - status: 'preview', + status: + parseInt(`${currentHour}`) + + parseInt(`${scheduleInfo.futurePreview}`) - + parseInt(`${scheduleInfo.viewTimePast}`) > + parseInt(`${lastHour}`) + parseInt(`${index}`) + ? 'noSlot' + : parseInt(`${currentHour}`) + + parseInt(`${scheduleInfo.futurePreview}`) > + parseInt(`${lastHour}`) + parseInt(`${index}`) + ? 'close' + : scheduleInfo.futurePreview > 0 && + index !== + parseInt(`${scheduleInfo.viewTimeFuture}`) - + parseInt(`${scheduleTime}`) + + parseInt(`${scheduleInfo.futurePreview}`) + ? 'open' + : 'preview', time: lastHour + index >= 24 ? (lastHour + index) % 24 From 5325aee650ddad349eb01658739e6cec8bb2503d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EC=9A=B1?= Date: Sun, 26 Feb 2023 21:48:34 +0900 Subject: [PATCH 09/17] =?UTF-8?q?[Style]=20=EC=8A=AC=EB=A1=AF=20CSS=20#684?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/scheduler/SchedulerCurrent.tsx | 4 ++-- .../admin/scheduler/SchedulerPreview.tsx | 6 +++-- .../scheduler/SchedulerCurrent.module.scss | 24 +++++++++---------- .../admin/scheduler/SchedulerEdit.module.scss | 3 ++- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/components/admin/scheduler/SchedulerCurrent.tsx b/components/admin/scheduler/SchedulerCurrent.tsx index 607d1133c..b07cbb404 100644 --- a/components/admin/scheduler/SchedulerCurrent.tsx +++ b/components/admin/scheduler/SchedulerCurrent.tsx @@ -66,7 +66,7 @@ export default function SchedulerCurrent(props: { }, [props]); return ( -
+
{slotInfo.matchBoards.map((slot: Slots[], index) => { return (
@@ -74,7 +74,7 @@ export default function SchedulerCurrent(props: { {slot[0].time[11] === '0' ? '' : slot[0].time[11]} {slot[0].time[12]}시
-
+
{slot.map((item) => (
{slot[0].time}시
-
+
{slot.map((item) => (
{item.status}
diff --git a/styles/admin/scheduler/SchedulerCurrent.module.scss b/styles/admin/scheduler/SchedulerCurrent.module.scss index 8c2cab49a..1425f787c 100644 --- a/styles/admin/scheduler/SchedulerCurrent.module.scss +++ b/styles/admin/scheduler/SchedulerCurrent.module.scss @@ -1,9 +1,3 @@ -.current { - width: auto; - height: 500px; - overflow-y: scroll; -} - .hourContainer { display: flex; margin-top: 5px; @@ -13,19 +7,25 @@ width: 50px; } -.hourSlot3 { +.hourSlot { display: flex; flex-wrap: wrap; width: 202px; height: 52px; border: 1px solid black; + text-align: center; } -.hourSlot4 { - display: flex; - flex-wrap: wrap; - width: 202px; - height: 52px; +.minuteSlot1 { + width: 200px; + height: 50px; + border: 1px solid black; + line-height: 40px; +} + +.minuteSlot2 { + width: 200px; + height: 25px; border: 1px solid black; } diff --git a/styles/admin/scheduler/SchedulerEdit.module.scss b/styles/admin/scheduler/SchedulerEdit.module.scss index 542e66cfe..4f68b54e8 100644 --- a/styles/admin/scheduler/SchedulerEdit.module.scss +++ b/styles/admin/scheduler/SchedulerEdit.module.scss @@ -3,8 +3,9 @@ } .imgContainer { - height: 800px; + height: 700px; width: 50%; + overflow-y: scroll; } .inputContainer { From 7417e057b0b551f918c3de6a0b1fb45f523b851a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EC=9A=B1?= Date: Sun, 26 Feb 2023 22:13:24 +0900 Subject: [PATCH 10/17] =?UTF-8?q?[Feat]=20inputHandler=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20#684?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/admin/scheduler/SchedulerMain.tsx | 57 +++++++++++++------ .../admin/scheduler/SchedulerPreview.tsx | 9 ++- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/components/admin/scheduler/SchedulerMain.tsx b/components/admin/scheduler/SchedulerMain.tsx index 251e4781d..1614c1a8b 100644 --- a/components/admin/scheduler/SchedulerMain.tsx +++ b/components/admin/scheduler/SchedulerMain.tsx @@ -27,8 +27,8 @@ type Slots = { export default function SchedulerMain() { const [scheduleInfo, setScheduleInfo] = useState({ - viewTimePast: 0, - viewTimeFuture: 0, + viewTimePast: 12, + viewTimeFuture: 12, gameTime: 15, blindShowTime: 5, futurePreview: 0, @@ -82,18 +82,21 @@ export default function SchedulerMain() { initSlotInfo(); }, []); - const inputHandler = (e: React.ChangeEvent) => { + const inputHandler = ( + e: + | React.ChangeEvent + | React.ChangeEvent + ) => { const { name, value } = e.target; - setScheduleInfo((prev) => ({ - ...prev, - [name]: value, - })); - }; + let intValue = parseInt(value); + if (isNaN(intValue)) intValue = 0; + if ( + ((name === 'futurePreview' || name === 'blindShowTime') && + intValue < 0) || + ((name === 'viewTimePast' || name === 'viewTimeFuture') && intValue < 1) + ) + return; - const inputNumHandler = (e: React.ChangeEvent) => { - const { name, value } = e.target; - const intValue = parseInt(value); - console.log(intValue); setScheduleInfo((prev) => ({ ...prev, [name]: intValue, @@ -128,13 +131,23 @@ export default function SchedulerMain() {
과거 - + 미래 - +
게임 시간 - @@ -142,11 +155,21 @@ export default function SchedulerMain() {
블라인드 해제 시간 - +
N시간 후: - +
diff --git a/components/admin/scheduler/SchedulerPreview.tsx b/components/admin/scheduler/SchedulerPreview.tsx index 5ebe459d5..ff10bd55b 100644 --- a/components/admin/scheduler/SchedulerPreview.tsx +++ b/components/admin/scheduler/SchedulerPreview.tsx @@ -32,10 +32,6 @@ export default function SchedulerPreview(props: { matchBoards: [], }); - useEffect(() => { - console.log(slotInfo); - }, [slotInfo]); - const initEmptySlot = () => { const slots: Slots[][] = Array(0).fill(null); return slots; @@ -46,7 +42,10 @@ export default function SchedulerPreview(props: { parseInt(`${lastHour}`) - parseInt(`${currentHour}`) < 0 ? parseInt(`${lastHour}`) - parseInt(`${currentHour}`) + 24 : parseInt(`${lastHour}`) - parseInt(`${currentHour}`); - if (scheduleTime <= scheduleInfo.viewTimeFuture) { + if ( + scheduleTime <= scheduleInfo.viewTimeFuture && + scheduleInfo.futurePreview >= 0 + ) { const newSlots: Slots[][] = Array( parseInt(`${scheduleInfo.viewTimeFuture}`) - parseInt(`${scheduleTime}`) + From 0373ad2a2d5170650fbbd0fdd37cb44e2fa0dd19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EC=9A=B1?= Date: Sun, 26 Feb 2023 22:22:16 +0900 Subject: [PATCH 11/17] =?UTF-8?q?[Feat]=20=ED=83=80=EC=9E=85=EC=88=98?= =?UTF-8?q?=EC=A0=95,=20axios=EC=82=AD=EC=A0=9C=20#684?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/admin/scheduler/SchedulerCurrent.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/components/admin/scheduler/SchedulerCurrent.tsx b/components/admin/scheduler/SchedulerCurrent.tsx index b07cbb404..2359acd3b 100644 --- a/components/admin/scheduler/SchedulerCurrent.tsx +++ b/components/admin/scheduler/SchedulerCurrent.tsx @@ -1,5 +1,4 @@ import { useEffect, useState } from 'react'; -import instance from 'utils/axios'; import styles from 'styles/admin/scheduler/SchedulerCurrent.module.scss'; type Match = { @@ -15,9 +14,17 @@ type Slots = { mode: string; }; +type EditedSchedule = { + viewTimePast: number; + viewTimeFuture: number; + gameTime: number; + blindShowTime: number; + futurePreview: number; +}; + export default function SchedulerCurrent(props: { slotInfo: Match; - scheduleInfo: any; + scheduleInfo: EditedSchedule; firstHour: number; currentHour: number; }) { From cebe3f79a9becc786ed88f7760f86a743579af72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EC=9A=B1?= Date: Mon, 27 Feb 2023 09:20:46 +0900 Subject: [PATCH 12/17] =?UTF-8?q?[Fix]=20=EC=98=A4=EC=A0=84=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=EC=97=90=20=EC=8A=AC=EB=A1=AF=20=EC=83=81=ED=83=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#684?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/admin/scheduler/SchedulerCurrent.tsx | 2 +- components/admin/scheduler/SchedulerPreview.tsx | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/components/admin/scheduler/SchedulerCurrent.tsx b/components/admin/scheduler/SchedulerCurrent.tsx index 2359acd3b..dfb59deb8 100644 --- a/components/admin/scheduler/SchedulerCurrent.tsx +++ b/components/admin/scheduler/SchedulerCurrent.tsx @@ -42,7 +42,7 @@ export default function SchedulerCurrent(props: { (slots, index) => { if ( parseInt(`${props.firstHour}`) + index < - (noSlotIndex < 0 ? noSlotIndex + 24 : noSlotIndex) + /* noSlotIndex < 0 ? noSlotIndex + 24 : */ noSlotIndex //todo: 오후 12시 전/후 확인필요 ) { const updatedSlots = slots.map((slot) => { return { ...slot, status: 'noSlot' }; diff --git a/components/admin/scheduler/SchedulerPreview.tsx b/components/admin/scheduler/SchedulerPreview.tsx index ff10bd55b..72d3c9372 100644 --- a/components/admin/scheduler/SchedulerPreview.tsx +++ b/components/admin/scheduler/SchedulerPreview.tsx @@ -43,8 +43,14 @@ export default function SchedulerPreview(props: { ? parseInt(`${lastHour}`) - parseInt(`${currentHour}`) + 24 : parseInt(`${lastHour}`) - parseInt(`${currentHour}`); if ( - scheduleTime <= scheduleInfo.viewTimeFuture && - scheduleInfo.futurePreview >= 0 + scheduleTime <= + scheduleInfo.viewTimeFuture + scheduleInfo.futurePreview && + scheduleInfo.futurePreview >= 0 && + parseInt(`${scheduleInfo.viewTimeFuture}`) - + parseInt(`${scheduleTime}`) + + parseInt(`${scheduleInfo.futurePreview}`) + + 1 > + 0 ) { const newSlots: Slots[][] = Array( parseInt(`${scheduleInfo.viewTimeFuture}`) - From fbf4d22574df52866198064bdcd9cfc2a0d597e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EC=9A=B1?= Date: Mon, 27 Feb 2023 09:27:11 +0900 Subject: [PATCH 13/17] =?UTF-8?q?[Fix]=20preview=20=EC=8A=AC=EB=A1=AF=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20?= =?UTF-8?q?=ED=98=84=EC=83=81=20fix=20#684?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/admin/scheduler/SchedulerPreview.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/admin/scheduler/SchedulerPreview.tsx b/components/admin/scheduler/SchedulerPreview.tsx index 72d3c9372..12d51c096 100644 --- a/components/admin/scheduler/SchedulerPreview.tsx +++ b/components/admin/scheduler/SchedulerPreview.tsx @@ -91,6 +91,12 @@ export default function SchedulerPreview(props: { intervalMinute: scheduleInfo.gameTime, matchBoards: newSlots.concat(slots), }); + } else { + const slots: Slots[][] = Array(0).fill(null); + setSlotInfo({ + intervalMinute: scheduleInfo.gameTime, + matchBoards: slots, + }); } }; From 6c2756163bc9011317671222e0bd251703e15f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EC=9A=B1?= Date: Mon, 27 Feb 2023 10:52:43 +0900 Subject: [PATCH 14/17] =?UTF-8?q?[Feat]=20=ED=98=84=EC=9E=AC=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=20=ED=91=9C=EA=B8=B0=20#684?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/admin/scheduler/SchedulerCurrent.tsx | 14 +++++++++++--- components/admin/scheduler/SchedulerPreview.tsx | 13 ++++++++++++- .../admin/scheduler/SchedulerCurrent.module.scss | 6 ++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/components/admin/scheduler/SchedulerCurrent.tsx b/components/admin/scheduler/SchedulerCurrent.tsx index dfb59deb8..6d1f004df 100644 --- a/components/admin/scheduler/SchedulerCurrent.tsx +++ b/components/admin/scheduler/SchedulerCurrent.tsx @@ -75,11 +75,19 @@ export default function SchedulerCurrent(props: { return (
{slotInfo.matchBoards.map((slot: Slots[], index) => { + const slotTime = + parseInt(slot[0].time[11]) * 10 + parseInt(slot[0].time[12]); return (
-
- {slot[0].time[11] === '0' ? '' : slot[0].time[11]} - {slot[0].time[12]}시 +
+ {slotTime}시
{slot.map((item) => ( diff --git a/components/admin/scheduler/SchedulerPreview.tsx b/components/admin/scheduler/SchedulerPreview.tsx index 12d51c096..8a7324e04 100644 --- a/components/admin/scheduler/SchedulerPreview.tsx +++ b/components/admin/scheduler/SchedulerPreview.tsx @@ -110,7 +110,18 @@ export default function SchedulerPreview(props: { {slotInfo.matchBoards.map((slot: Slots[], index) => { return (
-
{slot[0].time}시
+
= 24 + ? (currentHour + scheduleInfo.futurePreview) % 24 + : currentHour + scheduleInfo.futurePreview) + ? styles.currentTime + : styles.time + } + > + {slot[0].time}시 +
{slot.map((item) => (
Date: Mon, 27 Feb 2023 12:23:04 +0900 Subject: [PATCH 15/17] =?UTF-8?q?[Feat]=20parseInt=20=EC=A0=9C=EA=B1=B0/cu?= =?UTF-8?q?rrent=20=EB=AF=B8=EB=9E=98=EC=8A=A4=EC=BC=80=EC=A5=B4=20?= =?UTF-8?q?=EB=B0=98=EC=98=81=20#684?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/scheduler/SchedulerCurrent.tsx | 37 +++++++++++++--- components/admin/scheduler/SchedulerMain.tsx | 1 + .../admin/scheduler/SchedulerPreview.tsx | 44 +++++++++---------- 3 files changed, 53 insertions(+), 29 deletions(-) diff --git a/components/admin/scheduler/SchedulerCurrent.tsx b/components/admin/scheduler/SchedulerCurrent.tsx index 6d1f004df..303ec3ff8 100644 --- a/components/admin/scheduler/SchedulerCurrent.tsx +++ b/components/admin/scheduler/SchedulerCurrent.tsx @@ -26,6 +26,7 @@ export default function SchedulerCurrent(props: { slotInfo: Match; scheduleInfo: EditedSchedule; firstHour: number; + lastHour: number; currentHour: number; }) { const [slotInfo, setSlotInfo] = useState({ @@ -35,9 +36,9 @@ export default function SchedulerCurrent(props: { const initSlotInfo = () => { const noSlotIndex: number = - parseInt(`${props.currentHour}`) + - parseInt(`${props.scheduleInfo.futurePreview}`) - - parseInt(`${props.scheduleInfo.viewTimePast}`); + props.currentHour + + props.scheduleInfo.futurePreview - + props.scheduleInfo.viewTimePast; const updatedMatchBoards = props.slotInfo.matchBoards.map( (slots, index) => { if ( @@ -50,14 +51,38 @@ export default function SchedulerCurrent(props: { return updatedSlots; } else if ( index < - parseInt(`${props.currentHour}`) - - parseInt(`${props.firstHour}`) + - parseInt(`${props.scheduleInfo.futurePreview}`) + props.currentHour - props.firstHour + props.scheduleInfo.futurePreview ) { const updatedSlots = slots.map((slot) => { return { ...slot, status: 'close' }; }); return updatedSlots; + } else if ( + index > + props.currentHour - + props.firstHour + + props.scheduleInfo.futurePreview + + props.scheduleInfo.viewTimeFuture + ) { + const updatedSlots = slots.map((slot) => { + return { ...slot, status: 'noslot' }; + }); + return updatedSlots; + } else if ( + // props.lastHour - + // props.currentHour + + // props.scheduleInfo.futurePreview < + // props.scheduleInfo.viewTimeFuture && + index === + props.currentHour - + props.firstHour + + props.scheduleInfo.futurePreview + + props.scheduleInfo.viewTimeFuture + ) { + const updatedSlots = slots.map((slot) => { + return { ...slot, status: 'preview' }; + }); + return updatedSlots; } return slots; } diff --git a/components/admin/scheduler/SchedulerMain.tsx b/components/admin/scheduler/SchedulerMain.tsx index 1614c1a8b..93b062f3f 100644 --- a/components/admin/scheduler/SchedulerMain.tsx +++ b/components/admin/scheduler/SchedulerMain.tsx @@ -110,6 +110,7 @@ export default function SchedulerMain() { diff --git a/components/admin/scheduler/SchedulerPreview.tsx b/components/admin/scheduler/SchedulerPreview.tsx index 8a7324e04..5adebd8de 100644 --- a/components/admin/scheduler/SchedulerPreview.tsx +++ b/components/admin/scheduler/SchedulerPreview.tsx @@ -39,45 +39,43 @@ export default function SchedulerPreview(props: { const initSlotInfo = (slots: Slots[][]) => { const scheduleTime: number = - parseInt(`${lastHour}`) - parseInt(`${currentHour}`) < 0 - ? parseInt(`${lastHour}`) - parseInt(`${currentHour}`) + 24 - : parseInt(`${lastHour}`) - parseInt(`${currentHour}`); + lastHour - currentHour < 0 + ? lastHour - currentHour + 24 + : lastHour - currentHour; if ( scheduleTime <= scheduleInfo.viewTimeFuture + scheduleInfo.futurePreview && scheduleInfo.futurePreview >= 0 && - parseInt(`${scheduleInfo.viewTimeFuture}`) - - parseInt(`${scheduleTime}`) + - parseInt(`${scheduleInfo.futurePreview}`) + + scheduleInfo.viewTimeFuture - + scheduleTime + + scheduleInfo.futurePreview + 1 > 0 ) { - const newSlots: Slots[][] = Array( - parseInt(`${scheduleInfo.viewTimeFuture}`) - - parseInt(`${scheduleTime}`) + - parseInt(`${scheduleInfo.futurePreview}`) + - 1 - ) + const countNewSlot: number = + scheduleInfo.viewTimeFuture - + scheduleTime + + scheduleInfo.futurePreview + + 1; + const newSlots: Slots[][] = Array(countNewSlot) .fill(null) .map((_, index: number) => Array(60 / scheduleInfo.gameTime) .fill(null) .map((_, slotIndex: number) => ({ status: - parseInt(`${currentHour}`) + - parseInt(`${scheduleInfo.futurePreview}`) - - parseInt(`${scheduleInfo.viewTimePast}`) > - parseInt(`${lastHour}`) + parseInt(`${index}`) + currentHour + + scheduleInfo.futurePreview - + scheduleInfo.viewTimePast > + lastHour + index ? 'noSlot' - : parseInt(`${currentHour}`) + - parseInt(`${scheduleInfo.futurePreview}`) > - parseInt(`${lastHour}`) + parseInt(`${index}`) + : currentHour + scheduleInfo.futurePreview > lastHour + index ? 'close' : scheduleInfo.futurePreview > 0 && index !== - parseInt(`${scheduleInfo.viewTimeFuture}`) - - parseInt(`${scheduleTime}`) + - parseInt(`${scheduleInfo.futurePreview}`) + scheduleInfo.viewTimeFuture - + scheduleTime + + scheduleInfo.futurePreview ? 'open' : 'preview', time: @@ -129,7 +127,7 @@ export default function SchedulerPreview(props: { className={`${ styles[`minuteSlot${slot.length}`] } //todo slot.length가 1,2,4가 아닐 때 처리 필요 - ${styles[`${item.status}`]}`} + ${styles[`${item.status}`]}`} >
{item.status}
From c957b03eabed229b101989231683d2f60cb94c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EC=9A=B1?= Date: Mon, 27 Feb 2023 12:27:40 +0900 Subject: [PATCH 16/17] =?UTF-8?q?[Fix]=20=ED=83=80=EC=9E=85=EC=97=90?= =?UTF-8?q?=EB=9F=AC=20=EC=88=98=EC=A0=95=20#684?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/admin/scheduler/SchedulerCurrent.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/admin/scheduler/SchedulerCurrent.tsx b/components/admin/scheduler/SchedulerCurrent.tsx index 303ec3ff8..0503a5f00 100644 --- a/components/admin/scheduler/SchedulerCurrent.tsx +++ b/components/admin/scheduler/SchedulerCurrent.tsx @@ -45,7 +45,7 @@ export default function SchedulerCurrent(props: { parseInt(`${props.firstHour}`) + index < /* noSlotIndex < 0 ? noSlotIndex + 24 : */ noSlotIndex //todo: 오후 12시 전/후 확인필요 ) { - const updatedSlots = slots.map((slot) => { + const updatedSlots: Slots[] = slots.map((slot) => { return { ...slot, status: 'noSlot' }; }); return updatedSlots; @@ -53,7 +53,7 @@ export default function SchedulerCurrent(props: { index < props.currentHour - props.firstHour + props.scheduleInfo.futurePreview ) { - const updatedSlots = slots.map((slot) => { + const updatedSlots: Slots[] = slots.map((slot) => { return { ...slot, status: 'close' }; }); return updatedSlots; @@ -64,7 +64,7 @@ export default function SchedulerCurrent(props: { props.scheduleInfo.futurePreview + props.scheduleInfo.viewTimeFuture ) { - const updatedSlots = slots.map((slot) => { + const updatedSlots: Slots[] = slots.map((slot) => { return { ...slot, status: 'noslot' }; }); return updatedSlots; From 1e7915d4d8b31778a9bd0870ec9fd9e0cecf6330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EC=9A=B1?= Date: Mon, 27 Feb 2023 15:15:43 +0900 Subject: [PATCH 17/17] =?UTF-8?q?[Feat]=20current=20=EB=AF=B8=EB=9E=98=20n?= =?UTF-8?q?oSlot=20=EC=82=AD=EC=A0=9C=20#684?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/scheduler/SchedulerCurrent.tsx | 29 ++----------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/components/admin/scheduler/SchedulerCurrent.tsx b/components/admin/scheduler/SchedulerCurrent.tsx index 0503a5f00..0d106546f 100644 --- a/components/admin/scheduler/SchedulerCurrent.tsx +++ b/components/admin/scheduler/SchedulerCurrent.tsx @@ -57,34 +57,9 @@ export default function SchedulerCurrent(props: { return { ...slot, status: 'close' }; }); return updatedSlots; - } else if ( - index > - props.currentHour - - props.firstHour + - props.scheduleInfo.futurePreview + - props.scheduleInfo.viewTimeFuture - ) { - const updatedSlots: Slots[] = slots.map((slot) => { - return { ...slot, status: 'noslot' }; - }); - return updatedSlots; - } else if ( - // props.lastHour - - // props.currentHour + - // props.scheduleInfo.futurePreview < - // props.scheduleInfo.viewTimeFuture && - index === - props.currentHour - - props.firstHour + - props.scheduleInfo.futurePreview + - props.scheduleInfo.viewTimeFuture - ) { - const updatedSlots = slots.map((slot) => { - return { ...slot, status: 'preview' }; - }); - return updatedSlots; + } else { + return slots; } - return slots; } ); setSlotInfo({