Skip to content

Commit 7192932

Browse files
authored
Merge pull request #227 from DevKor-github/#168/fix-add-my-own
refactor: Add On My Own 아키텍쳐 이주
2 parents c7899a4 + 2db1f3e commit 7192932

File tree

30 files changed

+392
-348
lines changed

30 files changed

+392
-348
lines changed

src/components/timetable/LectureBottomSheet/AddOnMyOwn/TimeSelector.tsx renamed to src/common/components/TimeSelector/index.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
import { css } from '@styled-system/css'
21
import { useEffect, useState } from 'react'
32
import { UseFormSetValue } from 'react-hook-form'
43

4+
import * as s from './style.css'
5+
56
import Dropdown from '@/components/timetable/Dropdown'
6-
import { AddOnMyOwnForm } from '@/components/timetable/LectureBottomSheet/AddOnMyOwn'
7+
import { AddOnMyOwnForm } from '@/domain/Timetable/components/LectureBottomSheet/AddOnMyOwn/types'
78
import { hSelectors, mSelectors } from '@/lib/constants/timeSelectors'
89

910
interface TimeSelector {
1011
type: 'startTime' | 'endTime'
12+
value: string
1113
setValue: UseFormSetValue<AddOnMyOwnForm>
1214
}
13-
const TimeSelector = ({ type, setValue }: TimeSelector) => {
14-
const [curH, setCurH] = useState(0)
15-
const [curM, setCurM] = useState(0)
15+
const TimeSelector = ({ type, value, setValue }: TimeSelector) => {
16+
// Set initial curH and curM from value string
17+
const [hours, minutes] = value.split(':')
18+
const hIndex = hSelectors.findIndex(h => h.startsWith(hours))
19+
const mIndex = mSelectors.findIndex(m => m.startsWith(minutes))
20+
21+
const [curH, setCurH] = useState(hIndex === -1 ? 0 : hIndex)
22+
const [curM, setCurM] = useState(mIndex === -1 ? 0 : mIndex)
1623

1724
useEffect(() => {
1825
setValue(type, `${hSelectors[curH].slice(0, 2)}:${mSelectors[curM].slice(0, 2)}:00`)
1926
}, [curH, curM, setValue, type])
2027

2128
return (
22-
<div className={css({ display: 'flex', gap: 5 })}>
29+
<div className={s.Wrapper}>
2330
<Dropdown dropdownList={hSelectors} curIndex={curH} setCurIndex={setCurH} isTimeSelector={true} />
2431
<Dropdown dropdownList={mSelectors} curIndex={curM} setCurIndex={setCurM} isTimeSelector={true} />
2532
</div>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { style } from '@vanilla-extract/css'
2+
3+
import { f } from '@/style'
4+
5+
export const Wrapper = style([
6+
f.flex,
7+
{
8+
gap: '1.25rem',
9+
},
10+
])

src/components/timetable/Grid/LectureSticker/ScheduledLecture.tsx

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { css } from '@styled-system/css'
2+
import { AnimatePresence } from 'framer-motion'
23
import { useSetAtom } from 'jotai'
34
import { CircleUser, MapPin } from 'lucide-react'
4-
import { MouseEvent } from 'react'
5-
import { createPortal } from 'react-dom'
65

7-
import EditSchedule from '@/components/timetable/Modal/EditSchedule'
6+
import EditSchedule from '@/domain/Timetable/components/LectureBottomSheet/EditSchedule'
87
import { isBottomSheetVisible } from '@/domain/Timetable/store/bottomSheetVisibility'
98
import { GridType } from '@/types/timetable'
109
import { getDuration, getStartTime } from '@/util/timetableUtil'
@@ -54,14 +53,6 @@ const ScheduledLecture = ({
5453
setIsSheetOpened(true)
5554
}
5655

57-
const handleModalOutsideClick = (event: MouseEvent<HTMLDivElement, globalThis.MouseEvent>) => {
58-
// 모달 안쪽을 눌렀을 때도 모달 state가 null 되는 것을 방지
59-
if (event.target === event.currentTarget) {
60-
setIsScheduleEditOpened(false)
61-
setIsSheetOpened(true)
62-
}
63-
}
64-
6556
return (
6657
<>
6758
<div
@@ -113,30 +104,11 @@ const ScheduledLecture = ({
113104
)}
114105
</div>
115106
</div>
116-
{isScheduleEditOpened &&
117-
createPortal(
118-
<div
119-
className={css({
120-
position: 'fixed',
121-
top: 0,
122-
left: 0,
123-
w: '100vw',
124-
h: '100vh',
125-
bgColor: 'rgba(0, 0, 0, 0.40)',
126-
zIndex: 100,
127-
display: 'flex',
128-
flexDir: 'column',
129-
justifyContent: 'flex-end',
130-
alignItems: 'center',
131-
paddingBottom: '50px',
132-
})}
133-
role="presentation"
134-
onClick={handleModalOutsideClick}
135-
>
136-
<EditSchedule timetableId={timetableId!} data={data} closeScheduleModal={closeScheduleModal} />
137-
</div>,
138-
document.body,
107+
<AnimatePresence>
108+
{isScheduleEditOpened && (
109+
<EditSchedule timetableId={timetableId!} data={data} closeEditSheet={closeScheduleModal} />
139110
)}
111+
</AnimatePresence>
140112
</>
141113
)
142114
}

src/components/timetable/LectureBottomSheet/AddOnMyOwn/index.tsx

Lines changed: 0 additions & 223 deletions
This file was deleted.

src/components/timetable/Modal/EditSchedule.tsx

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)