From a64dcd0f95a1048c898ebcc3cf9acbb77dfadb1f Mon Sep 17 00:00:00 2001 From: yeonddori Date: Sun, 12 Jan 2025 18:46:20 +0900 Subject: [PATCH 01/12] =?UTF-8?q?feat:=20=ED=8C=80=20=ED=83=88=ED=87=B4=20?= =?UTF-8?q?api=20=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #380 --- src/app/api/team.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/app/api/team.ts b/src/app/api/team.ts index 68a62061..8e22ae1b 100644 --- a/src/app/api/team.ts +++ b/src/app/api/team.ts @@ -93,6 +93,14 @@ const deleteTeamMember = (token: string, teamId: number, memberId: number) => }, }); +const leaveTeam = (token: string, teamId: number) => + teamFetcher(`/teams/${teamId}/members`, { + method: 'DELETE', + headers: { + Authorization: `Bearer ${token}`, + }, + }); + const mandateTeamLeader = (token: string, teamId: number, memberId: number) => teamFetcher(`/teams/${teamId}/mandate/${memberId}`, { method: 'PATCH', @@ -115,6 +123,7 @@ export { getTeams, getMyTeams, deleteTeamMember, + leaveTeam, mandateTeamLeader, getTeamMembers, }; From 279f54846f0ce983a0a4d729cc90412cb80f9336 Mon Sep 17 00:00:00 2001 From: yeonddori Date: Sun, 12 Jan 2025 19:23:14 +0900 Subject: [PATCH 02/12] =?UTF-8?q?feat:=20=ED=8C=80=20=EC=82=AD=EC=A0=9C/?= =?UTF-8?q?=ED=83=88=ED=87=B4=20=EB=AA=A8=EB=8B=AC=20=ED=86=B5=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #380 --- src/containers/team/DeleteTeamModal/index.tsx | 41 ----------------- src/containers/team/DeleteTeamModal/type.ts | 6 --- src/containers/team/TeamActionModal/index.tsx | 44 +++++++++++++++++++ src/containers/team/TeamActionModal/type.ts | 7 +++ 4 files changed, 51 insertions(+), 47 deletions(-) delete mode 100644 src/containers/team/DeleteTeamModal/index.tsx delete mode 100644 src/containers/team/DeleteTeamModal/type.ts create mode 100644 src/containers/team/TeamActionModal/index.tsx create mode 100644 src/containers/team/TeamActionModal/type.ts diff --git a/src/containers/team/DeleteTeamModal/index.tsx b/src/containers/team/DeleteTeamModal/index.tsx deleted file mode 100644 index 046f3116..00000000 --- a/src/containers/team/DeleteTeamModal/index.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import { Text } from '@chakra-ui/react'; -import { useRouter } from 'next/navigation'; - -import { deleteTeam as deleteTeamApi } from '@/app/api/team'; -import ConfirmModal from '@/components/Modal/ConfirmModal'; -import { useMutateWithToken } from '@/hooks/useFetchWithToken'; -import useRefetchSideBar from '@/hooks/useRefetchSideBar'; - -import { DeleteTeamModalProps } from './type'; - -const DeleteTeamModal = ({ id, name, isOpen, onClose }: DeleteTeamModalProps) => { - const deleteTeam = useMutateWithToken(deleteTeamApi); - const refetchSidebar = useRefetchSideBar(); - const router = useRouter(); - - const handleDeleteTeamButtonClick = () => { - deleteTeam(id).then(() => { - refetchSidebar(); - onClose(); - router.replace('/'); - }); - }; - - return ( - handleDeleteTeamButtonClick()} - > - - 삭제된 팀은 되돌릴 수 없습니다. -
- {name} 팀을 삭제하시겠습니까? -
-
- ); -}; - -export default DeleteTeamModal; diff --git a/src/containers/team/DeleteTeamModal/type.ts b/src/containers/team/DeleteTeamModal/type.ts deleted file mode 100644 index 47cef8fa..00000000 --- a/src/containers/team/DeleteTeamModal/type.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Team } from '@/types'; - -export interface DeleteTeamModalProps extends Pick { - isOpen: boolean; - onClose: () => void; -} diff --git a/src/containers/team/TeamActionModal/index.tsx b/src/containers/team/TeamActionModal/index.tsx new file mode 100644 index 00000000..3e010adf --- /dev/null +++ b/src/containers/team/TeamActionModal/index.tsx @@ -0,0 +1,44 @@ +import { Text } from '@chakra-ui/react'; +import { useRouter } from 'next/navigation'; + +import { deleteTeam as deleteTeamApi, leaveTeam as leaveTeamApi } from '@/app/api/team'; +import ConfirmModal from '@/components/Modal/ConfirmModal'; +import { useMutateWithToken } from '@/hooks/useFetchWithToken'; +import useRefetchSideBar from '@/hooks/useRefetchSideBar'; + +import { TeamActionModalProps } from './type'; + +const TeamActionModal = ({ id, name, isOpen, onClose, actionType }: TeamActionModalProps) => { + const deleteTeam = useMutateWithToken(deleteTeamApi); + const leaveTeam = useMutateWithToken(leaveTeamApi); + const refetchSidebar = useRefetchSideBar(); + const router = useRouter(); + + const action = actionType === 'delete' ? deleteTeam : leaveTeam; + + const handleActionButtonClick = () => { + action(id).then(() => { + refetchSidebar(); + onClose(); + router.replace('/'); + }); + }; + + return ( + handleActionButtonClick()} + > + + {actionType === 'delete' ? `삭제된 팀은 되돌릴 수 없습니다.` : `팀에서 탈퇴하면 다시 되돌릴 수 없습니다.`} +
+ {name} 팀을 {actionType === 'delete' ? '삭제' : '탈퇴'}하시겠습니까? +
+
+ ); +}; + +export default TeamActionModal; diff --git a/src/containers/team/TeamActionModal/type.ts b/src/containers/team/TeamActionModal/type.ts new file mode 100644 index 00000000..53f2c0f0 --- /dev/null +++ b/src/containers/team/TeamActionModal/type.ts @@ -0,0 +1,7 @@ +import { Team } from '@/types'; + +export interface TeamActionModalProps extends Pick { + isOpen: boolean; + onClose: () => void; + actionType: 'delete' | 'leave'; +} From 4bee29f81008858700381088a1dbfcbd01629da8 Mon Sep 17 00:00:00 2001 From: yeonddori Date: Sun, 12 Jan 2025 19:25:16 +0900 Subject: [PATCH 03/12] =?UTF-8?q?feat:=20TeamControlPanel=20=EB=A6=AC?= =?UTF-8?q?=EB=8D=94=20=EB=B0=8F=20=ED=8C=80=EC=9B=90=20=EC=97=AC=EB=B6=80?= =?UTF-8?q?=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EB=B2=84=ED=8A=BC=20=ED=91=9C?= =?UTF-8?q?=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 팀원 탈퇴 버튼 추가 #380 --- src/app/team/[teamId]/page.tsx | 2 +- .../team/TeamControlPanel/index.tsx | 93 ++++++++++++------- src/containers/team/TeamControlPanel/types.ts | 2 + 3 files changed, 65 insertions(+), 32 deletions(-) diff --git a/src/app/team/[teamId]/page.tsx b/src/app/team/[teamId]/page.tsx index 5c1ef608..69f1ff3f 100644 --- a/src/app/team/[teamId]/page.tsx +++ b/src/app/team/[teamId]/page.tsx @@ -199,7 +199,7 @@ const Page = ({ params }: { params: { teamId: number } }) => { )} - {isTeamLeader && } + diff --git a/src/containers/team/TeamControlPanel/index.tsx b/src/containers/team/TeamControlPanel/index.tsx index 8cdc4ca5..82c46a0f 100644 --- a/src/containers/team/TeamControlPanel/index.tsx +++ b/src/containers/team/TeamControlPanel/index.tsx @@ -2,52 +2,83 @@ import { Button, Flex } from '@chakra-ui/react'; import { useState } from 'react'; import { TeamControlPanelProps } from './types'; -import DeleteTeamModal from '../DeleteTeamModal'; +import TeamActionModal from '../TeamActionModal'; import TeamModal from '../TeamModal'; -const TeamControlPanel = ({ teamInfo }: TeamControlPanelProps) => { +const TeamControlPanel = ({ isTeamLeader, isMyTeam, teamInfo }: TeamControlPanelProps) => { const [isEditModalOpen, setIsEditModalOpen] = useState(false); const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); + const [isLeaveModalOpen, setIsLeaveModalOpen] = useState(false); return ( - - + {isTeamLeader && ( + <> + + + + )} + {!isTeamLeader && isMyTeam && ( + + )} {isEditModalOpen && ( setIsEditModalOpen(false)} /> )} {isDeleteModalOpen && ( - setIsDeleteModalOpen(false)} + actionType="delete" + /> + )} + {isLeaveModalOpen && ( + setIsLeaveModalOpen(false)} + actionType="leave" /> )} diff --git a/src/containers/team/TeamControlPanel/types.ts b/src/containers/team/TeamControlPanel/types.ts index 13f73659..2bcbdd85 100644 --- a/src/containers/team/TeamControlPanel/types.ts +++ b/src/containers/team/TeamControlPanel/types.ts @@ -1,5 +1,7 @@ import { TeamDetail } from '@/types'; export interface TeamControlPanelProps { + isTeamLeader: boolean; + isMyTeam: boolean; teamInfo: TeamDetail; } From b55233dc6629bd3e3462c19c5ca015196702c993 Mon Sep 17 00:00:00 2001 From: yeonddori Date: Sun, 12 Jan 2025 19:42:50 +0900 Subject: [PATCH 04/12] =?UTF-8?q?feat:=20=EC=8A=A4=ED=84=B0=EB=94=94=20?= =?UTF-8?q?=ED=83=88=ED=87=B4=20=EB=AA=A8=EB=8B=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #380 --- .../study/Modal/LeaveStudyModal/index.tsx | 43 +++++++++++++++++++ src/containers/study/Modal/types.ts | 6 +++ 2 files changed, 49 insertions(+) create mode 100644 src/containers/study/Modal/LeaveStudyModal/index.tsx diff --git a/src/containers/study/Modal/LeaveStudyModal/index.tsx b/src/containers/study/Modal/LeaveStudyModal/index.tsx new file mode 100644 index 00000000..a2af42d9 --- /dev/null +++ b/src/containers/study/Modal/LeaveStudyModal/index.tsx @@ -0,0 +1,43 @@ +import { Text } from '@chakra-ui/react'; +import { useRouter } from 'next/navigation'; + +import { leaveStudy } from '@/app/api/study'; +import ConfirmModal from '@/components/Modal/ConfirmModal'; +import { useMutateWithToken } from '@/hooks/useFetchWithToken'; +import useRefetchSideBar from '@/hooks/useRefetchSideBar'; + +import { LeaveStudyModalProps } from '../types'; + +const LeaveStudyModal = ({ id, name, teamId, isOpen, setIsOpen }: LeaveStudyModalProps) => { + const leaveStudyAction = useMutateWithToken(leaveStudy); + const refetchSidebar = useRefetchSideBar(); + const router = useRouter(); + + const handleClickLeave = () => { + leaveStudyAction(id).then((res) => { + if (res.ok) { + refetchSidebar(); + setIsOpen(false); + router.replace(`/team/${teamId}/studies`); + } + }); + }; + + return ( + setIsOpen(false)} + title="스터디 탈퇴" + confirmButtonText="탈퇴" + onConfirmButtonClick={handleClickLeave} + > + + 스터디에서 탈퇴하면 다시 되돌릴 수 없습니다. +
+ {`"${name}"에서 탈퇴하시겠습니까?`} +
+
+ ); +}; + +export default LeaveStudyModal; diff --git a/src/containers/study/Modal/types.ts b/src/containers/study/Modal/types.ts index 26845b08..5fb2ed05 100644 --- a/src/containers/study/Modal/types.ts +++ b/src/containers/study/Modal/types.ts @@ -10,3 +10,9 @@ export interface DeleteStudyModalProps extends Pick { teamId: number; setIsOpen: React.Dispatch>; } + +export interface LeaveStudyModalProps extends Pick { + isOpen: boolean; + teamId: number; + setIsOpen: React.Dispatch>; +} From 2af6aee2ff39af277d665bdfb64bc56c1249daaf Mon Sep 17 00:00:00 2001 From: yeonddori Date: Sun, 12 Jan 2025 19:56:05 +0900 Subject: [PATCH 05/12] =?UTF-8?q?feat:=20=EC=8A=A4=ED=84=B0=EB=94=94=20?= =?UTF-8?q?=ED=83=88=ED=87=B4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #380 --- .../team/[teamId]/study/[studyId]/page.tsx | 12 +- .../study/StudyControlPanel/index.tsx | 112 +++++++++++------- .../study/StudyControlPanel/types.ts | 2 + 3 files changed, 82 insertions(+), 44 deletions(-) diff --git a/src/app/team/[teamId]/study/[studyId]/page.tsx b/src/app/team/[teamId]/study/[studyId]/page.tsx index 1e7a3b49..f1eff89c 100644 --- a/src/app/team/[teamId]/study/[studyId]/page.tsx +++ b/src/app/team/[teamId]/study/[studyId]/page.tsx @@ -25,12 +25,14 @@ import { useGetFetchWithToken } from '@/hooks/useFetchWithToken'; import useGetMyTeam from '@/hooks/useGetMyTeam'; import useGetUser from '@/hooks/useGetUser'; import { DocumentList, ParticipantType, Study, StudyMember } from '@/types'; +import LeaveStudyModal from '@/containers/study/Modal/LeaveStudyModal'; const Page = ({ params }: { params: { teamId: number; studyId: number } }) => { const [studyData, setStudyData] = useState(); const [isEditModalOpen, setIsEditModalOpen] = useState(false); const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); const [isTerminateModalOpen, setIsTerminateModalOpen] = useState(false); + const [isLeaveModalOpen, setIsLeaveModalOpen] = useState(false); const [documentArray, setDocumentArray] = useState([]); const [isCreateDocumentModalOpen, setIsCreateDocumentModalOpen] = useState(false); const categoryData: CreateDocument = { groupId: params.studyId, groupType: 'studies' }; @@ -97,9 +99,11 @@ const Page = ({ params }: { params: { teamId: number; studyId: number } }) => {
{studyData && studyData?.status !== 'ENDED' && user && user.memberId === studyData?.studyLeaderId && ( )} @@ -199,7 +203,13 @@ const Page = ({ params }: { params: { teamId: number; studyId: number } }) => { isOpen={isDeleteModalOpen} setIsOpen={setIsDeleteModalOpen} /> - + setIsCreateDocumentModalOpen(false)} diff --git a/src/containers/study/StudyControlPanel/index.tsx b/src/containers/study/StudyControlPanel/index.tsx index 259c7a89..07a3a81d 100644 --- a/src/containers/study/StudyControlPanel/index.tsx +++ b/src/containers/study/StudyControlPanel/index.tsx @@ -2,51 +2,77 @@ import { Button, Flex } from '@chakra-ui/react'; import { StudyControlPanelProps } from './types'; -const StudyControlPanel = ({ editModalOpen, terminateModalOpen, deleteModalOpen }: StudyControlPanelProps) => { +const StudyControlPanel = ({ + isStudyLeader, + editModalOpen, + terminateModalOpen, + deleteModalOpen, + leaveModalOpen, +}: StudyControlPanelProps) => { return ( - - - + {isStudyLeader && ( + <> + + + + + )} + {!isStudyLeader && ( + + )} ); }; diff --git a/src/containers/study/StudyControlPanel/types.ts b/src/containers/study/StudyControlPanel/types.ts index d20a1714..89abe1e2 100644 --- a/src/containers/study/StudyControlPanel/types.ts +++ b/src/containers/study/StudyControlPanel/types.ts @@ -1,5 +1,7 @@ export interface StudyControlPanelProps { + isStudyLeader: boolean; editModalOpen: React.Dispatch>; terminateModalOpen: React.Dispatch>; deleteModalOpen: React.Dispatch>; + leaveModalOpen: React.Dispatch>; } From 352b206b8ff59812d0d9a547d4837761ac970b4c Mon Sep 17 00:00:00 2001 From: yeonddori Date: Sun, 12 Jan 2025 19:56:50 +0900 Subject: [PATCH 06/12] =?UTF-8?q?fix:=20router=20=EA=B2=BD=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - api 불러오는 이름 수정 #380 --- src/containers/study/Modal/LeaveStudyModal/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/containers/study/Modal/LeaveStudyModal/index.tsx b/src/containers/study/Modal/LeaveStudyModal/index.tsx index a2af42d9..cbc8c466 100644 --- a/src/containers/study/Modal/LeaveStudyModal/index.tsx +++ b/src/containers/study/Modal/LeaveStudyModal/index.tsx @@ -1,7 +1,7 @@ import { Text } from '@chakra-ui/react'; import { useRouter } from 'next/navigation'; -import { leaveStudy } from '@/app/api/study'; +import { leaveStudy as leaveStudyApi } from '@/app/api/study'; import ConfirmModal from '@/components/Modal/ConfirmModal'; import { useMutateWithToken } from '@/hooks/useFetchWithToken'; import useRefetchSideBar from '@/hooks/useRefetchSideBar'; @@ -9,16 +9,16 @@ import useRefetchSideBar from '@/hooks/useRefetchSideBar'; import { LeaveStudyModalProps } from '../types'; const LeaveStudyModal = ({ id, name, teamId, isOpen, setIsOpen }: LeaveStudyModalProps) => { - const leaveStudyAction = useMutateWithToken(leaveStudy); + const leaveStudy = useMutateWithToken(leaveStudyApi); const refetchSidebar = useRefetchSideBar(); const router = useRouter(); const handleClickLeave = () => { - leaveStudyAction(id).then((res) => { + leaveStudy(id).then((res) => { if (res.ok) { refetchSidebar(); setIsOpen(false); - router.replace(`/team/${teamId}/studies`); + router.replace(`/team/${teamId}`); } }); }; From fc1eb3ace6e9cf1cdb578eee55b6a4dd92e959f8 Mon Sep 17 00:00:00 2001 From: yeonddori Date: Sun, 12 Jan 2025 20:06:59 +0900 Subject: [PATCH 07/12] =?UTF-8?q?refactor:=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EA=B2=BD=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #380 --- src/components/Sidebar/SidebarContent/index.tsx | 2 +- src/containers/team/{ => Modal}/TeamActionModal/index.tsx | 2 +- src/containers/team/{ => Modal}/TeamModal/index.tsx | 2 +- src/containers/team/{TeamActionModal => Modal}/type.ts | 6 ++++++ src/containers/team/TeamControlPanel/index.tsx | 4 ++-- src/containers/team/TeamModal/type.ts | 7 ------- 6 files changed, 11 insertions(+), 12 deletions(-) rename src/containers/team/{ => Modal}/TeamActionModal/index.tsx (96%) rename src/containers/team/{ => Modal}/TeamModal/index.tsx (99%) rename src/containers/team/{TeamActionModal => Modal}/type.ts (65%) delete mode 100644 src/containers/team/TeamModal/type.ts diff --git a/src/components/Sidebar/SidebarContent/index.tsx b/src/components/Sidebar/SidebarContent/index.tsx index 6ff28eb4..1b8397f7 100644 --- a/src/components/Sidebar/SidebarContent/index.tsx +++ b/src/components/Sidebar/SidebarContent/index.tsx @@ -11,7 +11,7 @@ import { MdOutlineLogout } from 'react-icons/md'; import { useGetSideBarInfoQuery } from '@/app/api/member'; import { defaultUserAtom, myTeamAtom, userAtom } from '@/atom'; import GoogleLoginButton from '@/containers/main/GoogleLoginButton'; -import TeamModal from '@/containers/team/TeamModal'; +import TeamModal from '@/containers/team/Modal/TeamModal'; import useGetUser from '@/hooks/useGetUser'; import SidebarIconButton from '../Button/SidebarIconButton'; diff --git a/src/containers/team/TeamActionModal/index.tsx b/src/containers/team/Modal/TeamActionModal/index.tsx similarity index 96% rename from src/containers/team/TeamActionModal/index.tsx rename to src/containers/team/Modal/TeamActionModal/index.tsx index 3e010adf..4a284ea1 100644 --- a/src/containers/team/TeamActionModal/index.tsx +++ b/src/containers/team/Modal/TeamActionModal/index.tsx @@ -6,7 +6,7 @@ import ConfirmModal from '@/components/Modal/ConfirmModal'; import { useMutateWithToken } from '@/hooks/useFetchWithToken'; import useRefetchSideBar from '@/hooks/useRefetchSideBar'; -import { TeamActionModalProps } from './type'; +import { TeamActionModalProps } from '../type'; const TeamActionModal = ({ id, name, isOpen, onClose, actionType }: TeamActionModalProps) => { const deleteTeam = useMutateWithToken(deleteTeamApi); diff --git a/src/containers/team/TeamModal/index.tsx b/src/containers/team/Modal/TeamModal/index.tsx similarity index 99% rename from src/containers/team/TeamModal/index.tsx rename to src/containers/team/Modal/TeamModal/index.tsx index b7938aac..1ba0a660 100644 --- a/src/containers/team/TeamModal/index.tsx +++ b/src/containers/team/Modal/TeamModal/index.tsx @@ -12,7 +12,7 @@ import { useMutateWithToken } from '@/hooks/useFetchWithToken'; import useRefetchSideBar from '@/hooks/useRefetchSideBar'; import useRefetchTeamInfo from '@/hooks/useRefetchTeamInfo'; -import { TeamModalProps } from './type'; +import { TeamModalProps } from '../type'; const AlertContent = ({ message }: { message: string }) => { return ( diff --git a/src/containers/team/TeamActionModal/type.ts b/src/containers/team/Modal/type.ts similarity index 65% rename from src/containers/team/TeamActionModal/type.ts rename to src/containers/team/Modal/type.ts index 53f2c0f0..011215e2 100644 --- a/src/containers/team/TeamActionModal/type.ts +++ b/src/containers/team/Modal/type.ts @@ -1,5 +1,11 @@ import { Team } from '@/types'; +export interface TeamModalProps { + teamInfo?: Team; + isOpen: boolean; + onClose: () => void; +} + export interface TeamActionModalProps extends Pick { isOpen: boolean; onClose: () => void; diff --git a/src/containers/team/TeamControlPanel/index.tsx b/src/containers/team/TeamControlPanel/index.tsx index 82c46a0f..babd772d 100644 --- a/src/containers/team/TeamControlPanel/index.tsx +++ b/src/containers/team/TeamControlPanel/index.tsx @@ -2,8 +2,8 @@ import { Button, Flex } from '@chakra-ui/react'; import { useState } from 'react'; import { TeamControlPanelProps } from './types'; -import TeamActionModal from '../TeamActionModal'; -import TeamModal from '../TeamModal'; +import TeamActionModal from '../Modal/TeamActionModal'; +import TeamModal from '../Modal/TeamModal'; const TeamControlPanel = ({ isTeamLeader, isMyTeam, teamInfo }: TeamControlPanelProps) => { const [isEditModalOpen, setIsEditModalOpen] = useState(false); diff --git a/src/containers/team/TeamModal/type.ts b/src/containers/team/TeamModal/type.ts deleted file mode 100644 index 528229eb..00000000 --- a/src/containers/team/TeamModal/type.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Team } from '@/types'; - -export interface TeamModalProps { - teamInfo?: Team; - isOpen: boolean; - onClose: () => void; -} From d1130b7cfec257c0bfcf6784760ebdafc814b088 Mon Sep 17 00:00:00 2001 From: yeonddori Date: Sun, 12 Jan 2025 20:14:27 +0900 Subject: [PATCH 08/12] =?UTF-8?q?refactor:=20=ED=8C=80=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EB=AA=A8=EB=8B=AC=EA=B3=BC=20=ED=83=88=ED=87=B4=20?= =?UTF-8?q?=EB=AA=A8=EB=8B=AC=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #380 --- .../team/Modal/DeleteTeamModal/index.tsx | 41 +++++++++++++++++ .../team/Modal/LeaveTeamModal/index.tsx | 41 +++++++++++++++++ .../team/Modal/TeamActionModal/index.tsx | 44 ------------------- src/containers/team/Modal/type.ts | 8 +++- .../team/TeamControlPanel/index.tsx | 9 ++-- 5 files changed, 92 insertions(+), 51 deletions(-) create mode 100644 src/containers/team/Modal/DeleteTeamModal/index.tsx create mode 100644 src/containers/team/Modal/LeaveTeamModal/index.tsx delete mode 100644 src/containers/team/Modal/TeamActionModal/index.tsx diff --git a/src/containers/team/Modal/DeleteTeamModal/index.tsx b/src/containers/team/Modal/DeleteTeamModal/index.tsx new file mode 100644 index 00000000..074e578d --- /dev/null +++ b/src/containers/team/Modal/DeleteTeamModal/index.tsx @@ -0,0 +1,41 @@ +import { Text } from '@chakra-ui/react'; +import { useRouter } from 'next/navigation'; + +import { deleteTeam as deleteTeamApi } from '@/app/api/team'; +import ConfirmModal from '@/components/Modal/ConfirmModal'; +import { useMutateWithToken } from '@/hooks/useFetchWithToken'; +import useRefetchSideBar from '@/hooks/useRefetchSideBar'; + +import { DeleteTeamModalProps } from '../type'; + +const DeleteTeamModal = ({ id, name, isOpen, onClose }: DeleteTeamModalProps) => { + const deleteTeam = useMutateWithToken(deleteTeamApi); + const refetchSidebar = useRefetchSideBar(); + const router = useRouter(); + + const handleDeleteTeamButtonClick = () => { + deleteTeam(id).then(() => { + refetchSidebar(); + onClose(); + router.replace('/'); + }); + }; + + return ( + handleDeleteTeamButtonClick()} + > + + 삭제된 팀은 되돌릴 수 없습니다. +
+ {name} 팀을 삭제하시겠습니까? +
+
+ ); +}; + +export default DeleteTeamModal; diff --git a/src/containers/team/Modal/LeaveTeamModal/index.tsx b/src/containers/team/Modal/LeaveTeamModal/index.tsx new file mode 100644 index 00000000..aad5cc08 --- /dev/null +++ b/src/containers/team/Modal/LeaveTeamModal/index.tsx @@ -0,0 +1,41 @@ +import { Text } from '@chakra-ui/react'; +import { useRouter } from 'next/navigation'; + +import { leaveTeam as leaveTeamApi } from '@/app/api/team'; +import ConfirmModal from '@/components/Modal/ConfirmModal'; +import { useMutateWithToken } from '@/hooks/useFetchWithToken'; +import useRefetchSideBar from '@/hooks/useRefetchSideBar'; + +import { LeaveTeamModalProps } from '../type'; + +const LeaveTeamModal = ({ id, name, isOpen, onClose }: LeaveTeamModalProps) => { + const leaveTeam = useMutateWithToken(leaveTeamApi); + const refetchSidebar = useRefetchSideBar(); + const router = useRouter(); + + const handleLeaveTeamButtonClick = () => { + leaveTeam(id).then(() => { + refetchSidebar(); + onClose(); + router.replace('/'); + }); + }; + + return ( + handleLeaveTeamButtonClick()} + > + + 팀에서 탈퇴하면 다시 되돌릴 수 없습니다. +
+ {name} 팀에서 탈퇴하시겠습니까? +
+
+ ); +}; + +export default LeaveTeamModal; diff --git a/src/containers/team/Modal/TeamActionModal/index.tsx b/src/containers/team/Modal/TeamActionModal/index.tsx deleted file mode 100644 index 4a284ea1..00000000 --- a/src/containers/team/Modal/TeamActionModal/index.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import { Text } from '@chakra-ui/react'; -import { useRouter } from 'next/navigation'; - -import { deleteTeam as deleteTeamApi, leaveTeam as leaveTeamApi } from '@/app/api/team'; -import ConfirmModal from '@/components/Modal/ConfirmModal'; -import { useMutateWithToken } from '@/hooks/useFetchWithToken'; -import useRefetchSideBar from '@/hooks/useRefetchSideBar'; - -import { TeamActionModalProps } from '../type'; - -const TeamActionModal = ({ id, name, isOpen, onClose, actionType }: TeamActionModalProps) => { - const deleteTeam = useMutateWithToken(deleteTeamApi); - const leaveTeam = useMutateWithToken(leaveTeamApi); - const refetchSidebar = useRefetchSideBar(); - const router = useRouter(); - - const action = actionType === 'delete' ? deleteTeam : leaveTeam; - - const handleActionButtonClick = () => { - action(id).then(() => { - refetchSidebar(); - onClose(); - router.replace('/'); - }); - }; - - return ( - handleActionButtonClick()} - > - - {actionType === 'delete' ? `삭제된 팀은 되돌릴 수 없습니다.` : `팀에서 탈퇴하면 다시 되돌릴 수 없습니다.`} -
- {name} 팀을 {actionType === 'delete' ? '삭제' : '탈퇴'}하시겠습니까? -
-
- ); -}; - -export default TeamActionModal; diff --git a/src/containers/team/Modal/type.ts b/src/containers/team/Modal/type.ts index 011215e2..94dceb9a 100644 --- a/src/containers/team/Modal/type.ts +++ b/src/containers/team/Modal/type.ts @@ -6,8 +6,12 @@ export interface TeamModalProps { onClose: () => void; } -export interface TeamActionModalProps extends Pick { +export interface DeleteTeamModalProps extends Pick { + isOpen: boolean; + onClose: () => void; +} + +export interface LeaveTeamModalProps extends Pick { isOpen: boolean; onClose: () => void; - actionType: 'delete' | 'leave'; } diff --git a/src/containers/team/TeamControlPanel/index.tsx b/src/containers/team/TeamControlPanel/index.tsx index babd772d..0c47ab7e 100644 --- a/src/containers/team/TeamControlPanel/index.tsx +++ b/src/containers/team/TeamControlPanel/index.tsx @@ -2,8 +2,9 @@ import { Button, Flex } from '@chakra-ui/react'; import { useState } from 'react'; import { TeamControlPanelProps } from './types'; -import TeamActionModal from '../Modal/TeamActionModal'; import TeamModal from '../Modal/TeamModal'; +import DeleteTeamModal from '../Modal/DeleteTeamModal'; +import LeaveTeamModal from '../Modal/LeaveTeamModal'; const TeamControlPanel = ({ isTeamLeader, isMyTeam, teamInfo }: TeamControlPanelProps) => { const [isEditModalOpen, setIsEditModalOpen] = useState(false); @@ -64,21 +65,19 @@ const TeamControlPanel = ({ isTeamLeader, isMyTeam, teamInfo }: TeamControlPanel setIsEditModalOpen(false)} /> )} {isDeleteModalOpen && ( - setIsDeleteModalOpen(false)} - actionType="delete" /> )} {isLeaveModalOpen && ( - setIsLeaveModalOpen(false)} - actionType="leave" /> )} From 83f0499493ed634a1b8e4a2ef9f0cbbbb8f40b0d Mon Sep 17 00:00:00 2001 From: yeonddori Date: Sun, 12 Jan 2025 20:37:08 +0900 Subject: [PATCH 09/12] =?UTF-8?q?fix:=20build=20error=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #380 --- src/app/team/[teamId]/study/[studyId]/page.tsx | 2 +- src/containers/team/TeamControlPanel/index.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/team/[teamId]/study/[studyId]/page.tsx b/src/app/team/[teamId]/study/[studyId]/page.tsx index f1eff89c..e64b105f 100644 --- a/src/app/team/[teamId]/study/[studyId]/page.tsx +++ b/src/app/team/[teamId]/study/[studyId]/page.tsx @@ -15,6 +15,7 @@ import CreateDocumentModal from '@/containers/study/CreateDocumentModal'; import { CreateDocument } from '@/containers/study/CreateDocumentModal/type'; import CurriculumCard from '@/containers/study/CurriculumCard'; import DeleteStudyModal from '@/containers/study/Modal/DeleteStudyModal'; +import LeaveStudyModal from '@/containers/study/Modal/LeaveStudyModal'; import StudyModal from '@/containers/study/Modal/StudyModal'; import TerminateStudyModal from '@/containers/study/Modal/TerminateStudyModal'; import Participant from '@/containers/study/Participant'; @@ -25,7 +26,6 @@ import { useGetFetchWithToken } from '@/hooks/useFetchWithToken'; import useGetMyTeam from '@/hooks/useGetMyTeam'; import useGetUser from '@/hooks/useGetUser'; import { DocumentList, ParticipantType, Study, StudyMember } from '@/types'; -import LeaveStudyModal from '@/containers/study/Modal/LeaveStudyModal'; const Page = ({ params }: { params: { teamId: number; studyId: number } }) => { const [studyData, setStudyData] = useState(); diff --git a/src/containers/team/TeamControlPanel/index.tsx b/src/containers/team/TeamControlPanel/index.tsx index 0c47ab7e..a48cbcdb 100644 --- a/src/containers/team/TeamControlPanel/index.tsx +++ b/src/containers/team/TeamControlPanel/index.tsx @@ -2,9 +2,9 @@ import { Button, Flex } from '@chakra-ui/react'; import { useState } from 'react'; import { TeamControlPanelProps } from './types'; -import TeamModal from '../Modal/TeamModal'; import DeleteTeamModal from '../Modal/DeleteTeamModal'; import LeaveTeamModal from '../Modal/LeaveTeamModal'; +import TeamModal from '../Modal/TeamModal'; const TeamControlPanel = ({ isTeamLeader, isMyTeam, teamInfo }: TeamControlPanelProps) => { const [isEditModalOpen, setIsEditModalOpen] = useState(false); From 525e6bbf9707bc328e310dc1d0422fdfd8225f2d Mon Sep 17 00:00:00 2001 From: yeonddori Date: Sun, 26 Jan 2025 20:13:22 +0900 Subject: [PATCH 10/12] =?UTF-8?q?fix:=20=ED=8C=80=EC=9B=90=EC=9D=B4=20?= =?UTF-8?q?=ED=83=88=ED=87=B4=20=EB=B2=84=ED=8A=BC=EC=9D=B4=20=EB=B3=B4?= =?UTF-8?q?=EC=9D=B4=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #380 --- src/app/team/[teamId]/study/[studyId]/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/team/[teamId]/study/[studyId]/page.tsx b/src/app/team/[teamId]/study/[studyId]/page.tsx index e64b105f..f78a0b19 100644 --- a/src/app/team/[teamId]/study/[studyId]/page.tsx +++ b/src/app/team/[teamId]/study/[studyId]/page.tsx @@ -97,7 +97,7 @@ const Page = ({ params }: { params: { teamId: number; studyId: number } }) => { )} - {studyData && studyData?.status !== 'ENDED' && user && user.memberId === studyData?.studyLeaderId && ( + {studyData && studyData?.status !== 'ENDED' && user && ( Date: Sun, 26 Jan 2025 20:15:02 +0900 Subject: [PATCH 11/12] =?UTF-8?q?design:=20=ED=83=88=ED=87=B4=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20=EC=83=89=EC=83=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #380 --- src/containers/study/StudyControlPanel/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/containers/study/StudyControlPanel/index.tsx b/src/containers/study/StudyControlPanel/index.tsx index 07a3a81d..4a687c50 100644 --- a/src/containers/study/StudyControlPanel/index.tsx +++ b/src/containers/study/StudyControlPanel/index.tsx @@ -62,10 +62,10 @@ const StudyControlPanel = ({ w="fit-content" px="4" py="1" - color="black" - bg="white" + color="white" + bg="orange" shadow="md" - _hover={{ bg: 'white' }} + _hover={{ bg: 'orange' }} aria-label="" onClick={() => leaveModalOpen(true)} size="xs" From 4b334cd5fbce5748349a1382dbb981148923a72c Mon Sep 17 00:00:00 2001 From: yeonddori Date: Sun, 26 Jan 2025 20:24:15 +0900 Subject: [PATCH 12/12] =?UTF-8?q?fix:=20=EC=8A=A4=ED=84=B0=EB=94=94?= =?UTF-8?q?=EC=9B=90=EC=9D=B4=20=EC=95=84=EB=8B=8C=20=ED=8C=80=EC=9B=90?= =?UTF-8?q?=EC=97=90=EA=B2=8C=20=ED=83=88=ED=87=B4=20=EB=B2=84=ED=8A=BC?= =?UTF-8?q?=EC=9D=B4=20=EB=85=B8=EC=B6=9C=EB=90=98=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #380 --- src/app/team/[teamId]/study/[studyId]/page.tsx | 1 + src/containers/study/StudyControlPanel/index.tsx | 3 ++- src/containers/study/StudyControlPanel/types.ts | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/team/[teamId]/study/[studyId]/page.tsx b/src/app/team/[teamId]/study/[studyId]/page.tsx index f78a0b19..7115dac9 100644 --- a/src/app/team/[teamId]/study/[studyId]/page.tsx +++ b/src/app/team/[teamId]/study/[studyId]/page.tsx @@ -100,6 +100,7 @@ const Page = ({ params }: { params: { teamId: number; studyId: number } }) => { {studyData && studyData?.status !== 'ENDED' && user && ( data.memberId === user.memberId)} editModalOpen={setIsEditModalOpen} terminateModalOpen={setIsTerminateModalOpen} deleteModalOpen={setIsDeleteModalOpen} diff --git a/src/containers/study/StudyControlPanel/index.tsx b/src/containers/study/StudyControlPanel/index.tsx index 4a687c50..84d270df 100644 --- a/src/containers/study/StudyControlPanel/index.tsx +++ b/src/containers/study/StudyControlPanel/index.tsx @@ -4,6 +4,7 @@ import { StudyControlPanelProps } from './types'; const StudyControlPanel = ({ isStudyLeader, + isStudyMember, editModalOpen, terminateModalOpen, deleteModalOpen, @@ -57,7 +58,7 @@ const StudyControlPanel = ({ )} - {!isStudyLeader && ( + {!isStudyLeader && isStudyMember && (