Skip to content
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

스케줄 박스 에디트, 딜리트 버튼 제거 #284

Merged
merged 3 commits into from
Dec 1, 2023
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
21 changes: 1 addition & 20 deletions src/components/common/scheduleProfileBox/ScheduleProfileBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { ScheduleProfileBoxProps } from '@/components/common/scheduleProfileBox/
const ScheduleProfileBox = ({
mainTitle,
subTitle,
handleEdit,
handleDelete,
handleDetail,
children
}: ScheduleProfileBoxProps) => {
Expand All @@ -14,9 +12,8 @@ const ScheduleProfileBox = ({
className={
'flex flex-col w-[360px] h-[88px] shadow-md pt-[22px] pb-[20px] px-[24px] rounded-[20px] font-nsk cursor-pointer'
}
onClick={(e) => {
onClick={() => {
handleDetail()
e.stopPropagation()
}}>
<div className={'flex flex-row w-full mb-[2px]'}>
<span
Expand All @@ -25,22 +22,6 @@ const ScheduleProfileBox = ({
}>
{mainTitle}
</span>
<div className={'flex flex-row w-[20%]'}>
<div
onClick={(e) => {
handleEdit()
e.stopPropagation()
}}>
<Icon icon={'Edit'} classStyle={'cursor-pointer'} />
</div>
<div
onClick={(e) => {
handleDelete()
e.stopPropagation()
}}>
<Icon icon={'Close'} classStyle={'cursor-pointer'} />
</div>
</div>
</div>
<div className={'flex flex-row '}>
<div className={'flex flex-row w-full items-center'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { ReactNode } from 'react'
export interface ScheduleProfileBoxProps {
mainTitle: string
subTitle: string
handleEdit: () => void
handleDelete: () => void
handleDetail: () => void
children?: ReactNode
}
34 changes: 7 additions & 27 deletions src/components/schedule/scheduleModal/ScheduleModal.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,19 @@
import { useNavigate } from 'react-router-dom'
import { useMutation } from '@tanstack/react-query'
import Profile from '@/components/common/profile/Profile.tsx'
import { queryClient } from '@/libs/api/queryClient.ts'
import { deleteSchedule } from '@/libs/api/schedule/scheduleApi.ts'
import { OverlappingScheduleType } from '@/libs/api/schedule/scheduleType.ts'
import { ScheduleModalProps } from '@/pages/schedule/scheduleType.ts'
import { HandlerScheduleProps } from '@/pages/schedule/scheduleType.ts'

const ScheduleModal = ({
childSchedule,
mainTitle,
modalType,
date,
lessonId,
close
}: ScheduleModalProps) => {
lessonId
}: HandlerScheduleProps) => {
const navigate = useNavigate()
const { mutate } = useMutation({
mutationFn: (scheduleId: number) =>
deleteSchedule({ scheduleId: scheduleId }),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['scheduleId'] })
close()
}
})

const selectChild = (childInfo: OverlappingScheduleType) => {
if (modalType === 'edit') {
navigate(`/schedule/${childInfo.scheduleId}/edit`)
} else if (modalType === 'delete') {
mutate(childInfo.scheduleId)
} else {
navigate(
`/schedule/detail?date=${date}&scheduleId=${childInfo.scheduleId}&lessonId=${lessonId}&child=${childInfo.childId}`
)
}
navigate(
`/schedule/detail?date=${date}&scheduleId=${childInfo.scheduleId}&lessonId=${lessonId}&child=${childInfo.childId}`
)
}

return (
Expand All @@ -45,7 +25,7 @@ const ScheduleModal = ({
className={
'subHead-18 w-full h-[20%] mt-[26px] ml-[36px] text-left mb-[10px]'
}>
{mainTitle}
{'어떤 아이의 스케줄 정보를 확인할까요?'}
</span>
<div
className={
Expand Down
29 changes: 0 additions & 29 deletions src/pages/schedule/Schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ const Schedule = () => {
})
const [modalState, setModalState] = useState<HandlerScheduleProps>({
childSchedule: [],
modalType: '',
mainTitle: '',
date: '',
lessonId: null
})
Expand All @@ -57,15 +55,11 @@ const Schedule = () => {

const handlerScheduleProfileClick = ({
childSchedule,
modalType,
mainTitle,
date,
lessonId
}: HandlerScheduleProps) => {
setModalState(() => ({
childSchedule: childSchedule,
modalType: modalType,
mainTitle: mainTitle,
date: date,
lessonId: lessonId
}))
Expand Down Expand Up @@ -105,29 +99,9 @@ const Schedule = () => {
className={'flex mb-[16px] justify-center items-center'}>
<ScheduleProfileBox
mainTitle={`${schedule.academyName} - ${schedule.lessonName}`}
handleEdit={() =>
handlerScheduleProfileClick({
childSchedule: schedule.overlappingSchedules,
modalType: 'edit',
mainTitle: '어떤 아이의 스케줄을 수정하시겠습니까?',
date: scheduleData.date,
lessonId: schedule.lessonId
})
}
handleDelete={() =>
handlerScheduleProfileClick({
childSchedule: schedule.overlappingSchedules,
modalType: 'delete',
mainTitle: '어떤 아이의 스케줄을 삭제하시겠습니까?',
date: scheduleData.date,
lessonId: schedule.lessonId
})
}
handleDetail={() =>
handlerScheduleProfileClick({
childSchedule: schedule.overlappingSchedules,
modalType: 'detail',
mainTitle: '어떤 아이의 스케줄 정보를 확인할까요?',
date: scheduleData.date,
lessonId: schedule.lessonId
})
Expand Down Expand Up @@ -158,12 +132,9 @@ const Schedule = () => {
/>
<Modal>
<ScheduleModal
mainTitle={modalState.mainTitle}
childSchedule={modalState.childSchedule}
modalType={modalState.modalType}
date={modalState.date}
lessonId={modalState.lessonId}
close={close}
/>
</Modal>
</div>
Expand Down
10 changes: 1 addition & 9 deletions src/pages/schedule/scheduleType.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import { OverlappingScheduleType } from '@/libs/api/schedule/scheduleType.ts'

export interface ScheduleModalType {
modalType: 'delete' | 'edit' | 'detail' | ''
}
export interface HandlerScheduleProps extends ScheduleModalType {
export interface HandlerScheduleProps {
childSchedule: OverlappingScheduleType[]
mainTitle: string
date: string
lessonId: number | null
}

export interface ScheduleModalProps extends HandlerScheduleProps {
close: () => void
}
Loading