From fef556ee584b7222121d70ffcd199c0e7590be5e Mon Sep 17 00:00:00 2001 From: lybell-art Date: Mon, 19 Aug 2024 18:04:04 +0900 Subject: [PATCH] =?UTF-8?q?[modify]=20=EC=84=A0=EC=B0=A9=EC=88=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EB=93=B1=EB=A1=9D=EC=8B=9C=20?= =?UTF-8?q?=EB=8F=99=EC=9D=BC=ED=95=9C=20=EB=82=A0=EC=A7=9C=EC=97=90=20?= =?UTF-8?q?=EB=8B=A4=EB=A5=B8=20=EC=8B=9C=EA=B0=84=EC=9D=84=20=EC=95=88?= =?UTF-8?q?=EB=B1=89=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eventEdit/businessLogic/FcfsData.js | 19 +++++++++++++++++-- .../features/header/Hamburger/Button.jsx | 4 ++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/adminPage/features/eventEdit/businessLogic/FcfsData.js b/src/adminPage/features/eventEdit/businessLogic/FcfsData.js index 49afbea3..c8cc2cfd 100644 --- a/src/adminPage/features/eventEdit/businessLogic/FcfsData.js +++ b/src/adminPage/features/eventEdit/businessLogic/FcfsData.js @@ -94,6 +94,16 @@ function verifyItems(map, { startTime, endTime, prevSnapshot = new Map() }) { return result; } +function hasDuplicatedDate(newDate, map) +{ + if(newDate === undefined) return true; + if(newDate === null) return false; + const dateSet = new Set([...map.values()].map( ({date})=>date?.valueOf() ?? null )); + + if(dateSet.has(newDate.valueOf())) return true; + return false; +} + function getDefaultFcfsArray( startTime, endTime, @@ -194,12 +204,17 @@ class FcfsData { modify(key, data, { startTime, endTime }) { const newData = new FcfsData(this.map); const oldItem = newData.map.get(key); + const verified = verifyItem( - { ...oldItem, ...data }, + {...oldItem, ...data}, { startTime, endTime, prevSnapshot: oldItem }, ); if (verified === null) newData.map.delete(key); - else newData.map.set(key, verified); + else { + if(hasDuplicatedDate(verified.date, this.map)) verified.date = oldItem.date; + + newData.map.set(key, verified); + } return newData; } modifyAll(data, { startTime, endTime }) { diff --git a/src/mainPage/features/header/Hamburger/Button.jsx b/src/mainPage/features/header/Hamburger/Button.jsx index e353734b..f18ed448 100644 --- a/src/mainPage/features/header/Hamburger/Button.jsx +++ b/src/mainPage/features/header/Hamburger/Button.jsx @@ -5,12 +5,12 @@ function HamburgerButton({children}) { const [opened, setOpened] = useState(false); return <> - -
+
{opened && children}