Skip to content

Commit

Permalink
[modify] 선착순 이벤트 등록시 동일한 날짜에 다른 시간을 안뱉도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
lybell-art committed Aug 19, 2024
1 parent a0c71b1 commit fef556e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
19 changes: 17 additions & 2 deletions src/adminPage/features/eventEdit/businessLogic/FcfsData.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 }) {
Expand Down
4 changes: 2 additions & 2 deletions src/mainPage/features/header/Hamburger/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ function HamburgerButton({children})
{
const [opened, setOpened] = useState(false);
return <>
<button className="flex md:hidden justify-center items-center size-8 z-10" aria-label="open-menu" onClick={ ()=>setOpened((state)=>!state) }>
<button className="flex md:hidden justify-center items-center size-6 z-10" aria-label="open-menu" onClick={ ()=>setOpened((state)=>!state) }>
<div className={style.hamburger} data-opened={opened} >
<div></div>
</div>
</button>
<div className="fixed -z-10 w-full top-0 left-0 bg-white flex md:hidden flex-col justify-center items-center gap-2">
<div className="fixed -z-10 w-full top-0 left-0 bg-white flex md:hidden flex-col justify-center items-center gap-2">
<div className="w-full mt-16 shadow-xl">{opened && children}</div>
</div>
</>
Expand Down

0 comments on commit fef556e

Please sign in to comment.