Skip to content

refactor: Add On My Own 아키텍쳐 이주 #227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
import { css } from '@styled-system/css'
import { useEffect, useState } from 'react'
import { UseFormSetValue } from 'react-hook-form'

import * as s from './style.css'

import Dropdown from '@/components/timetable/Dropdown'
import { AddOnMyOwnForm } from '@/components/timetable/LectureBottomSheet/AddOnMyOwn'
import { AddOnMyOwnForm } from '@/domain/Timetable/components/LectureBottomSheet/AddOnMyOwn/types'
import { hSelectors, mSelectors } from '@/lib/constants/timeSelectors'

interface TimeSelector {
type: 'startTime' | 'endTime'
value: string
setValue: UseFormSetValue<AddOnMyOwnForm>
}
const TimeSelector = ({ type, setValue }: TimeSelector) => {
const [curH, setCurH] = useState(0)
const [curM, setCurM] = useState(0)
const TimeSelector = ({ type, value, setValue }: TimeSelector) => {
// Set initial curH and curM from value string
const [hours, minutes] = value.split(':')
const hIndex = hSelectors.findIndex(h => h.startsWith(hours))
const mIndex = mSelectors.findIndex(m => m.startsWith(minutes))

const [curH, setCurH] = useState(hIndex === -1 ? 0 : hIndex)
const [curM, setCurM] = useState(mIndex === -1 ? 0 : mIndex)

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

return (
<div className={css({ display: 'flex', gap: 5 })}>
<div className={s.Wrapper}>
<Dropdown dropdownList={hSelectors} curIndex={curH} setCurIndex={setCurH} isTimeSelector={true} />
<Dropdown dropdownList={mSelectors} curIndex={curM} setCurIndex={setCurM} isTimeSelector={true} />
</div>
Expand Down
10 changes: 10 additions & 0 deletions src/common/components/TimeSelector/style.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { style } from '@vanilla-extract/css'

import { f } from '@/style'

export const Wrapper = style([
f.flex,
{
gap: '1.25rem',
},
])
40 changes: 6 additions & 34 deletions src/components/timetable/Grid/LectureSticker/ScheduledLecture.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { css } from '@styled-system/css'
import { AnimatePresence } from 'framer-motion'
import { useSetAtom } from 'jotai'
import { CircleUser, MapPin } from 'lucide-react'
import { MouseEvent } from 'react'
import { createPortal } from 'react-dom'

import EditSchedule from '@/components/timetable/Modal/EditSchedule'
import EditSchedule from '@/domain/Timetable/components/LectureBottomSheet/EditSchedule'
import { isBottomSheetVisible } from '@/domain/Timetable/store/bottomSheetVisibility'
import { GridType } from '@/types/timetable'
import { getDuration, getStartTime } from '@/util/timetableUtil'
Expand Down Expand Up @@ -54,14 +53,6 @@ const ScheduledLecture = ({
setIsSheetOpened(true)
}

const handleModalOutsideClick = (event: MouseEvent<HTMLDivElement, globalThis.MouseEvent>) => {
// 모달 안쪽을 눌렀을 때도 모달 state가 null 되는 것을 방지
if (event.target === event.currentTarget) {
setIsScheduleEditOpened(false)
setIsSheetOpened(true)
}
}

return (
<>
<div
Expand Down Expand Up @@ -113,30 +104,11 @@ const ScheduledLecture = ({
)}
</div>
</div>
{isScheduleEditOpened &&
createPortal(
<div
className={css({
position: 'fixed',
top: 0,
left: 0,
w: '100vw',
h: '100vh',
bgColor: 'rgba(0, 0, 0, 0.40)',
zIndex: 100,
display: 'flex',
flexDir: 'column',
justifyContent: 'flex-end',
alignItems: 'center',
paddingBottom: '50px',
})}
role="presentation"
onClick={handleModalOutsideClick}
>
<EditSchedule timetableId={timetableId!} data={data} closeScheduleModal={closeScheduleModal} />
</div>,
document.body,
<AnimatePresence>
{isScheduleEditOpened && (
<EditSchedule timetableId={timetableId!} data={data} closeEditSheet={closeScheduleModal} />
)}
</AnimatePresence>
</>
)
}
Expand Down
223 changes: 0 additions & 223 deletions src/components/timetable/LectureBottomSheet/AddOnMyOwn/index.tsx

This file was deleted.

49 changes: 0 additions & 49 deletions src/components/timetable/Modal/EditSchedule.tsx

This file was deleted.

Loading