Skip to content

Commit

Permalink
Merge branch 'dev' into bug/186-child-edit
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene028 committed Dec 2, 2023
2 parents d802bda + c44a0b9 commit 1743fcc
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 147 deletions.
2 changes: 1 addition & 1 deletion src/components/common/informationBox/InformationBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const InformationBox = ({
'p-[14px] w-[345px] h-[120px] font-nsk overflow-hidden rounded-[10px] bg-white-0'
}>
<div className={'w-full h-full flex items-center'}>
<Profile imageSize={'M'} canEdit={true} imageUrl={imageUrl} />
<Profile imageSize={'M'} canEdit={false} imageUrl={imageUrl} />
<div
className={
'relative w-[240px] h-full pl-[17px] flex flex-col justify-center gap-[5px]'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ const meta: Meta<typeof ScheduleProfileBox> = {
description: '메인 타이틀을 입력해주세요!!',
control: { type: 'text' },
required: true
},
handleEdit: {
description: '에디트 함수를 입력해주세요',
control: { type: 'function' },
required: true
},
handleDelete: {
description: '삭제 함수를 입력해주세요',
control: { type: 'function' },
required: true
}
}
}
Expand All @@ -29,7 +19,7 @@ type Story = StoryObj<typeof ScheduleProfileBox>
export const ProfileScheduleBox: Story = {
args: {
mainTitle: '메인 타이틀 입니다.',
handleEdit: () => alert('에디트 함수를 넣어주세요'),
handleDelete: () => alert('삭제 함수를 넣어주새요')
subTitle: '서브 타이틀 입니다.',
handleDetail: () => console.log('test')
}
}
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
2 changes: 1 addition & 1 deletion src/libs/api/schedule/scheduleType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface ScheduleType {
lessonId: number
academyName: string
lessonName: string
endTIme: string
endTime: string
overlappingSchedules: OverlappingScheduleType[]
}

Expand Down
17 changes: 14 additions & 3 deletions src/pages/likeAcademy/LikeAcademy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const LikeAcademy = () => {
<Spacing size={90} />
<SettingPage isOpen={toggleOpen} />
<div className={'overflow-auto h-[600px]'}>
{likeAcademies?.likeAcademyInfos &&
{likeAcademies?.likeAcademyInfos.length ? (
likeAcademies.likeAcademyInfos?.map(
({ likeId, academyId, academyName, expectedFee }, index) => (
<li
Expand All @@ -72,7 +72,12 @@ const LikeAcademy = () => {
}
/>
<div className={'ml-[50px] my-[5px]'}>
<p className={'subHead-18'}>{academyName}</p>
<p
className={
'subHead-18 w-[80%] text-ellipsis overflow-hidden whitespace-nowrap'
}>
{academyName}
</p>
<p>
{'예상 교육비'}
<span
Expand Down Expand Up @@ -102,7 +107,13 @@ const LikeAcademy = () => {
/>
</li>
)
)}
)
) : (
<div className={'flex justify-center items-center'}>
<Spacing size={600} />
<p className={'body-18-gray'}>{'찜한 학원이 아직 없습니다'}</p>
</div>
)}

<div
className={
Expand Down
2 changes: 1 addition & 1 deletion src/pages/login/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { getItem } from '@/libs/utils/storage'
const LoginPage = () => {
const navigate = useNavigate()
useEffect(() => {
if (getItem('token')) navigate('/')
if (getItem('token').length > 0) navigate('/')
}, [])
useEffect(() => {
const req = async () => {
Expand Down
34 changes: 16 additions & 18 deletions src/pages/map/MapPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,23 @@ const MapPage = () => {
return (
<div className={'bg-white-100 w-full h-full relative overflow-hidden'}>
<SettingPage isOpen={toggleOpen} />
<div>
<Spacing size={80} />
<MapSearchBar />
<NaverMap
academyList={
academyList?.academiesByLocationResponse ||
academyFilterList?.academyFilterResponses ||
[]
}
<Spacing size={80} />
<MapSearchBar />
<NaverMap
academyList={
academyList?.academiesByLocationResponse ||
academyFilterList?.academyFilterResponses ||
[]
}
/>
{selectAcademy.isBottomSheet && (
<BottomSheet
title={selectAcademy.academy.academyName}
address={selectAcademy.academy.address}
number={selectAcademy.academy.contact}
academyId={selectAcademy.academy.academyId}
/>
{selectAcademy.isBottomSheet && (
<BottomSheet
title={selectAcademy.academy.academyName}
address={selectAcademy.academy.address}
number={selectAcademy.academy.contact}
academyId={selectAcademy.academy.academyId}
/>
)}
</div>
)}
</div>
)
}
Expand Down
43 changes: 20 additions & 23 deletions src/pages/mypage/MyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,28 @@ const MyPage = () => {
}
/>
</div>
<div className={'flex overflow-x-scroll'}>
<div className={'flex overflow-x-scroll flex-start'}>
{data?.childInformationResponses.length === 0 ? (
<p>{'🥲아직 아이를 등록하지 않으셨습니다...'}</p>
) : (
<ul className={'list-none flex-shrink-0'}>
{data?.childInformationResponses.map((childInfo) => (
<li key={childInfo.childId} className={'px-10'}>
<Profile
imageSize={'M'}
imageUrl={childInfo.childProfileImageUrl}
canEdit={true}
onClick={() =>
navigate(`/edit/${childInfo.childId}`, {
state: { childId: childInfo.childId }
})
}
/>
</li>
))}
<ul className={'list-none flex-shrink-0 flex flex-start'}>
{data?.childInformationResponses.map(
({ childId, childName, childProfileImageUrl }) => (
<li key={childId} className={'px-2'}>
<Profile
imageSize={'M'}
imageUrl={childProfileImageUrl}
imageLabel={childName}
canEdit={true}
onClick={() =>
navigate(`/edit/${childId}`, {
state: childId
})
}
/>
</li>
)
)}
</ul>
)}
</div>
Expand Down Expand Up @@ -123,13 +126,7 @@ const MyPage = () => {
/>
<Button
label={'예'}
onClick={() => {
withdrawUserApi()
setToast({
comment: '회원 탈퇴가 완료되었어요.',
type: 'success'
})
}}
onClick={() => withdrawUserApi()}
buttonType={'Plain-red'}
/>
</div>
Expand Down
36 changes: 6 additions & 30 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,35 +99,15 @@ 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
})
}
subTitle={`${convertTo12HourFormat(
schedule.endTIme
schedule.endTime
)} 에 종료`}>
{schedule.overlappingSchedules.map((child, index) => (
<div className={'mx-[3px]'} key={`${index}-profile`}>
Expand All @@ -148,6 +122,11 @@ const Schedule = () => {
))}
</>
))}
{!scheduleData && (
<span className={'mt-[20px] body-16 text-gray-600 text-center'}>
{'생성된 스케줄이 없습니다. 스케줄을 생성해주세요!'}
</span>
)}
</div>
<Icon
icon={'Add'}
Expand All @@ -158,12 +137,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
Loading

0 comments on commit 1743fcc

Please sign in to comment.