From e3ddc7c6484610dcd5a12bf541ed13688ccd6ba2 Mon Sep 17 00:00:00 2001 From: hafnium1923 Date: Wed, 19 Jul 2023 16:20:07 +0900 Subject: [PATCH 01/17] =?UTF-8?q?refactor:=20=EA=B8=B0=EA=B0=84=20?= =?UTF-8?q?=EC=9D=BC=EC=A0=95=20=EC=A1=B0=ED=9A=8C=20query=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/App.tsx | 4 ++-- .../hooks/queries/{useSchedules.ts => useFetchSchedules.ts} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename frontend/src/hooks/queries/{useSchedules.ts => useFetchSchedules.ts} (89%) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 1c832daac..ca449c2de 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,9 +1,9 @@ import { styled } from 'styled-components'; import Calendar from '~/components/Calendar/Calendar'; -import { useSchedules } from '~/hooks/queries/useSchedules'; +import { useFetchSchedules } from '~/hooks/queries/useFetchSchedules'; const App = () => { - const { schedules } = useSchedules(1, 2023, 7); + const { schedules } = useFetchSchedules(1, 2023, 7); if (schedules === undefined) { return null; diff --git a/frontend/src/hooks/queries/useSchedules.ts b/frontend/src/hooks/queries/useFetchSchedules.ts similarity index 89% rename from frontend/src/hooks/queries/useSchedules.ts rename to frontend/src/hooks/queries/useFetchSchedules.ts index b8ca24334..a90e7341c 100644 --- a/frontend/src/hooks/queries/useSchedules.ts +++ b/frontend/src/hooks/queries/useFetchSchedules.ts @@ -1,7 +1,7 @@ import { useQuery } from '@tanstack/react-query'; import { fetchSchedules } from '~/apis/schedule'; -export const useSchedules = ( +export const useFetchSchedules = ( teamPlaceId: number, year: number, month: number, From 61aa58fbcced17e898e48e02a3ef554329ff3a17 Mon Sep 17 00:00:00 2001 From: hafnium1923 Date: Thu, 20 Jul 2023 10:40:20 +0900 Subject: [PATCH 02/17] =?UTF-8?q?feat:=20=EC=9D=BC=EC=A0=95=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C,=20=EC=82=AD=EC=A0=9C=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/apis/schedule.ts | 12 ++++++++++++ .../src/hooks/queries/useDeleteSchedule.ts | 18 ++++++++++++++++++ frontend/src/hooks/queries/useFetchSchedule.ts | 13 +++++++++++++ frontend/src/mocks/fixtures/schedules.ts | 4 ++-- 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 frontend/src/hooks/queries/useDeleteSchedule.ts create mode 100644 frontend/src/hooks/queries/useFetchSchedule.ts diff --git a/frontend/src/apis/schedule.ts b/frontend/src/apis/schedule.ts index 6e6df444b..d26eb1729 100644 --- a/frontend/src/apis/schedule.ts +++ b/frontend/src/apis/schedule.ts @@ -10,3 +10,15 @@ export const fetchSchedules = ( `/api/team-place/${teamPlaceId}/calendar/schedules?year=${year}&month=${month}`, ); }; + +export const fetchScheduleById = (teamPlaceId: number, scheduleId: number) => { + return http.get( + `/api/team-place/${teamPlaceId}/calendar/schedules/${scheduleId}`, + ); +}; + +export const deleteSchedule = (teamPlaceId: number, scheduleId: number) => { + return http.delete( + `/api/team-place/${teamPlaceId}/calendar/schedules/${scheduleId}`, + ); +}; diff --git a/frontend/src/hooks/queries/useDeleteSchedule.ts b/frontend/src/hooks/queries/useDeleteSchedule.ts new file mode 100644 index 000000000..8632d23ec --- /dev/null +++ b/frontend/src/hooks/queries/useDeleteSchedule.ts @@ -0,0 +1,18 @@ +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import { deleteSchedule } from '~/apis/schedule'; + +export const useDeleteSchedule = (teamPlaceId: number, scheduleId: number) => { + const queryClient = useQueryClient(); + + const { mutate } = useMutation( + () => deleteSchedule(teamPlaceId, scheduleId), + { + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['schedules'] }); + queryClient.invalidateQueries({ queryKey: ['schedule'] }); + }, + }, + ); + + return { mutateScheduleDelete: mutate }; +}; diff --git a/frontend/src/hooks/queries/useFetchSchedule.ts b/frontend/src/hooks/queries/useFetchSchedule.ts new file mode 100644 index 000000000..494fc87bb --- /dev/null +++ b/frontend/src/hooks/queries/useFetchSchedule.ts @@ -0,0 +1,13 @@ +import { useQuery } from '@tanstack/react-query'; +import { fetchScheduleById } from '~/apis/schedule'; + +export const useFetchScheduleById = ( + teamPlaceId: number, + scheduleId: number, +) => { + const { data: scheduleById } = useQuery(['schedule', scheduleId], () => + fetchScheduleById(teamPlaceId, scheduleId), + ); + + return { scheduleById }; +}; diff --git a/frontend/src/mocks/fixtures/schedules.ts b/frontend/src/mocks/fixtures/schedules.ts index 17f23d54d..587ee4dc4 100644 --- a/frontend/src/mocks/fixtures/schedules.ts +++ b/frontend/src/mocks/fixtures/schedules.ts @@ -39,13 +39,13 @@ export const schedules: Schedule[] = [ }, { id: 6, - title: 'test5', + title: 'test6', startDateTime: '2023-07-31 05:00', endDateTime: '2023-08-02 05:00', }, { id: 7, - title: 'test5', + title: 'test7', startDateTime: '2023-06-30 05:00', endDateTime: '2023-07-02 05:00', }, From e0d4c92e79f9e92b1f88735af25967f45255a84d Mon Sep 17 00:00:00 2001 From: hafnium1923 Date: Thu, 20 Jul 2023 10:41:09 +0900 Subject: [PATCH 03/17] =?UTF-8?q?refactor:=20=EC=8A=A4=EC=BC=80=EC=A4=84?= =?UTF-8?q?=EB=AA=A8=EB=8B=AC=20=EC=8A=A4=ED=83=80=EC=9D=BC=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...edule.styled.ts => ScheduleModal.styled.ts} | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) rename frontend/src/components/ScheduleModal/{Schedule.styled.ts => ScheduleModal.styled.ts} (95%) diff --git a/frontend/src/components/ScheduleModal/Schedule.styled.ts b/frontend/src/components/ScheduleModal/ScheduleModal.styled.ts similarity index 95% rename from frontend/src/components/ScheduleModal/Schedule.styled.ts rename to frontend/src/components/ScheduleModal/ScheduleModal.styled.ts index 906cc784b..790f28ca8 100644 --- a/frontend/src/components/ScheduleModal/Schedule.styled.ts +++ b/frontend/src/components/ScheduleModal/ScheduleModal.styled.ts @@ -45,14 +45,6 @@ export const TeamColor = styled.div` background-color: ${({ theme }) => theme.color.PRIMARY}; `; -export const TeamName = css` - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - - max-width: 200px; -`; - export const MenuWrapper = styled.div` display: flex; align-items: center; @@ -64,7 +56,15 @@ export const PeriodWrapper = styled.div` gap: 2px; `; -export const Button = css` +export const teamName = css` + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + + max-width: 200px; +`; + +export const closeButton = css` display: flex; justify-content: center; align-items: center; From b825c33b7debc6e3e539c7875f18e6e6eba2f81e Mon Sep 17 00:00:00 2001 From: hafnium1923 Date: Thu, 20 Jul 2023 10:43:46 +0900 Subject: [PATCH 04/17] =?UTF-8?q?refactor:=20=EC=8A=A4=EC=BC=80=EC=A4=84?= =?UTF-8?q?=EB=B0=94=EC=97=90=20=EC=9D=BC=EC=A0=95=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EB=AA=A8=EB=8B=AC=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ScheduleBar/ScheduleBar.stories.tsx | 4 ++++ .../components/ScheduleBar/ScheduleBar.styled.ts | 6 ++++-- .../src/components/ScheduleBar/ScheduleBar.tsx | 16 +++++++--------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/ScheduleBar/ScheduleBar.stories.tsx b/frontend/src/components/ScheduleBar/ScheduleBar.stories.tsx index aebcfeb7a..f550bc891 100644 --- a/frontend/src/components/ScheduleBar/ScheduleBar.stories.tsx +++ b/frontend/src/components/ScheduleBar/ScheduleBar.stories.tsx @@ -20,5 +20,9 @@ export const Default: Story = { column: 2, duration: 3, level: 0, + // eslint-disable-next-line + //@ts-ignore + ref: null, + handleClick: () => console.log('click'), }, }; diff --git a/frontend/src/components/ScheduleBar/ScheduleBar.styled.ts b/frontend/src/components/ScheduleBar/ScheduleBar.styled.ts index 5a660c5d1..a387810a0 100644 --- a/frontend/src/components/ScheduleBar/ScheduleBar.styled.ts +++ b/frontend/src/components/ScheduleBar/ScheduleBar.styled.ts @@ -1,7 +1,7 @@ import { styled } from 'styled-components'; -import type { ScheduleBarProps } from '~/components/ScheduleBar/ScheduleBar'; +import type { ScheduleBar } from '~/components/ScheduleBar/ScheduleBar'; -export const Wrapper = styled.div` +export const Wrapper = styled.div` position: absolute; top: ${({ level }) => level * 18 + 36}px; @@ -10,4 +10,6 @@ export const Wrapper = styled.div` height: 16px; background-color: ${({ color }) => color}; + + cursor: pointer; `; diff --git a/frontend/src/components/ScheduleBar/ScheduleBar.tsx b/frontend/src/components/ScheduleBar/ScheduleBar.tsx index b87ada07e..5e35384a3 100644 --- a/frontend/src/components/ScheduleBar/ScheduleBar.tsx +++ b/frontend/src/components/ScheduleBar/ScheduleBar.tsx @@ -1,6 +1,6 @@ import * as S from './ScheduleBar.styled'; -export interface ScheduleBarProps { +export interface ScheduleBar { id: string; scheduleId: number; title: string; @@ -11,16 +11,14 @@ export interface ScheduleBarProps { color?: string; } -const ScheduleBar = (props: ScheduleBarProps) => { - const { color = 'red', title, ...rest } = props; +interface ScheduleBarProps extends ScheduleBar { + handleClick: () => void; +} +const ScheduleBar = (props: ScheduleBarProps) => { + const { color = 'red', title, handleClick, ...rest } = props; return ( - alert(title)} - /> + ); }; From 7825f9f4a51dc7d2cd7290a59f641e4f32a8f007 Mon Sep 17 00:00:00 2001 From: hafnium1923 Date: Thu, 20 Jul 2023 10:44:22 +0900 Subject: [PATCH 05/17] =?UTF-8?q?refactor:=20=EC=8A=A4=EC=BC=80=EC=A4=84?= =?UTF-8?q?=EB=B0=94=20ref=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/ScheduleBar/ScheduleBar.stories.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/frontend/src/components/ScheduleBar/ScheduleBar.stories.tsx b/frontend/src/components/ScheduleBar/ScheduleBar.stories.tsx index f550bc891..02ab6a864 100644 --- a/frontend/src/components/ScheduleBar/ScheduleBar.stories.tsx +++ b/frontend/src/components/ScheduleBar/ScheduleBar.stories.tsx @@ -20,9 +20,6 @@ export const Default: Story = { column: 2, duration: 3, level: 0, - // eslint-disable-next-line - //@ts-ignore - ref: null, handleClick: () => console.log('click'), }, }; From 37e7dc76d85b24289ad568a02161c28e687880a7 Mon Sep 17 00:00:00 2001 From: hafnium1923 Date: Thu, 20 Jul 2023 10:46:24 +0900 Subject: [PATCH 06/17] =?UTF-8?q?refactor:=20=EC=9D=BC=EC=A0=95=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=EB=AA=A8=EB=8B=AC=20=EC=83=81=ED=83=9C=EA=B0=92?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=84=98=EA=B2=A8=EB=B0=9B=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ScheduleModal/ScheduleModal.stories.tsx | 35 +++++++++++-- .../ScheduleModal/ScheduleModal.tsx | 50 +++++++++++-------- frontend/src/types/schedule.ts | 11 +++- 3 files changed, 69 insertions(+), 27 deletions(-) diff --git a/frontend/src/components/ScheduleModal/ScheduleModal.stories.tsx b/frontend/src/components/ScheduleModal/ScheduleModal.stories.tsx index 4388f9361..12e1f3370 100644 --- a/frontend/src/components/ScheduleModal/ScheduleModal.stories.tsx +++ b/frontend/src/components/ScheduleModal/ScheduleModal.stories.tsx @@ -40,14 +40,39 @@ export const Default: Story = { ); })} - + { + alert('click'); + }} + /> ); }, args: { - id: 1, - // eslint-disable-next-line - //@ts-ignore - targetRef: null, + schedule: { + id: 0, + title: 'test0', + startDateTime: '2023-07-13 00:00', + endDateTime: '2023-07-14 23:59', + }, + position: { + row: 0, + column: 0, + level: 0, + }, + handleScheduleDelete: () => { + alert('click'); + }, }, }; diff --git a/frontend/src/components/ScheduleModal/ScheduleModal.tsx b/frontend/src/components/ScheduleModal/ScheduleModal.tsx index 510a5442a..45b98d531 100644 --- a/frontend/src/components/ScheduleModal/ScheduleModal.tsx +++ b/frontend/src/components/ScheduleModal/ScheduleModal.tsx @@ -2,22 +2,37 @@ import type { CSSProperties } from 'react'; import Modal from '~/components/common/Modal/Modal'; import Text from '~/components/common/Text/Text'; import { useModal } from '~/hooks/useModal'; -import * as S from './Schedule.styled'; +import * as S from './ScheduleModal.styled'; import { CloseIcon, DeleteIcon, EditIcon } from '~/assets/svg'; import Button from '~/components/common/Button/Button'; +import { formatDateTime } from '~/utils/formatDateTime'; +import type { Schedule, SchedulePosition } from '~/types/schedule'; interface ScheduleModalProps { - id: number; - targetRef: React.RefObject; + schedule: Schedule; + position: SchedulePosition; + handleScheduleDelete: () => void; } const ScheduleModal = (props: ScheduleModalProps) => { - const { targetRef } = props; + const { schedule, handleScheduleDelete, position } = props; const { closeModal } = useModal(); + const { id, title, startDateTime, endDateTime } = schedule; + + console.log(position); const modalLocation: CSSProperties = { position: 'absolute', - top: `${targetRef.current?.getBoundingClientRect().bottom}px`, - left: `${targetRef.current?.getBoundingClientRect().left}px`, + top: + position.row < 3 + ? `${(position.row + 1) * 120 + position.level * 18 + 60}px` + : 'none', + bottom: + position.row >= 3 + ? `${(6 - position.row) * 120 - position.level * 18}px` + : 'none', + left: position.column < 3 ? `${(position.column * 100) / 7}%` : 'none', + right: + position.column >= 3 ? `${((6 - position.column) * 100) / 7}%` : 'none', }; return ( @@ -27,22 +42,15 @@ const ScheduleModal = (props: ScheduleModalProps) => { -

- - 현대사회와 범죄 5조현대사회와 범죄 5조현대사회와 - 범죄5조현대사회와 범죄 5조현대사회와 범죄 5조 - -

+
+ 현대사회와 범죄 5조 +
-
- 1차 데모데이 + {title} - 07월 13일 15:00 + {formatDateTime(startDateTime)} ~ - 07월 13일 19:00 + {formatDateTime(endDateTime)} - -