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

[#49][#55][#56] 팀 관리 관련 #57

Merged
merged 47 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
31e6722
Init: 팀관리 온보딩페이지
03hoho03 Aug 12, 2024
7f31a72
Feat: 팀 관리 팀 목록 페이지
03hoho03 Aug 12, 2024
1bd7c1c
Feat: 팀
03hoho03 Aug 12, 2024
dd2a69f
Feat: 팀 목록 container
03hoho03 Aug 12, 2024
f09f374
Refact: 팀 관리 링크 변경
03hoho03 Aug 12, 2024
612cad3
Feat: 팀 관리 팀 목록 api
03hoho03 Aug 12, 2024
93216b3
Feat: 팀 관리 팀 목록 관련 mock
03hoho03 Aug 12, 2024
621539f
Refact: 팀 관리 팀 리스트 컴포넌트 이름변경 적용
03hoho03 Aug 12, 2024
9741161
Rename: dynamic route foler 이름 변경
03hoho03 Aug 12, 2024
c1d428a
Style: lint 적용
03hoho03 Aug 14, 2024
e571246
Design:border-radius 둥근 사각형 추가
03hoho03 Aug 14, 2024
0059d10
Design: 기본 넓이 삭제
03hoho03 Aug 14, 2024
a4cfe05
Feat: 팀 관리 디테일 mock 데이터
03hoho03 Aug 14, 2024
f11087a
Feat: 팀 관리 디테일 mock handler
03hoho03 Aug 14, 2024
bb5e750
Feat: 팀장이 프로젝트에서 유저를 밴하는 api
03hoho03 Aug 21, 2024
1914409
Minor: baseUrl export
03hoho03 Aug 21, 2024
01d189d
Minor: 팀관리 링크변경
03hoho03 Aug 26, 2024
ed249fd
Feat: 팀 삭제 api(팀 리더용)
03hoho03 Aug 26, 2024
af8cb2a
Feat: 팀 탈퇴 api
03hoho03 Aug 26, 2024
a986e48
Feat: 팀 리더 체크용 api
03hoho03 Aug 26, 2024
b08fa93
Feat: 팀 관리 디테일 api
03hoho03 Aug 26, 2024
2b2283d
Feat: 삭제 및 탈퇴 dialog atom 추가
03hoho03 Aug 26, 2024
3a4660c
Remove: 폴더이동
03hoho03 Aug 26, 2024
f53499a
Minor: 사이드메뉴 폴더이동 경로 적용
03hoho03 Aug 26, 2024
d565907
Feat: 팀 삭제 확인 모달
03hoho03 Aug 27, 2024
5968919
Feat: 팀 탈퇴 확인 모달
03hoho03 Aug 27, 2024
73b3ed4
Feat: 팀 관리 상세페이지 상단 네비게이션
03hoho03 Aug 27, 2024
3cd27e7
Feat: 팀 관리 상세 layout
03hoho03 Aug 27, 2024
beeaa86
Feat: 팀 참가 승인 대기 인원 mock data
03hoho03 Aug 27, 2024
f62c0ce
Feat: 팀 참가 승인 대기 mock handler
03hoho03 Aug 27, 2024
a776918
Feat: 미승인 멤버 승인 api by 팀리더
03hoho03 Aug 27, 2024
89be120
Feat: 미승인 멤버 거절 by 팀 리더
03hoho03 Aug 27, 2024
710ee21
Feat: 미승인 멤버 목록 api
03hoho03 Aug 27, 2024
0155c12
Feat: 팀 관리 redirect 추가
03hoho03 Aug 27, 2024
5f005db
Asset: 팀원 없음 이미지
03hoho03 Aug 27, 2024
10c31ec
Feat: 멤버 컴포넌트 스토리
03hoho03 Aug 27, 2024
890b756
Remove: manage 페이지 삭제
03hoho03 Aug 27, 2024
54d8a84
Feat: 팀 멤버 페이지
03hoho03 Aug 27, 2024
3824bd4
Feat: 팀원 승인 페이지
03hoho03 Aug 27, 2024
d9e7b09
Feat: 멤버 미승인 목록 리스트 컴포넌트
03hoho03 Aug 27, 2024
ff6d5bc
Feat: 미승인 멤버 container
03hoho03 Aug 27, 2024
803019c
Feat: 팀 멤버 container
03hoho03 Aug 27, 2024
749cd2f
Feat: 팀 멤버 list component
03hoho03 Aug 27, 2024
d063eef
Feat: 팀 멤버 item component
03hoho03 Aug 27, 2024
0b69c89
Refact: MemberList 관련 MemberContainer로 이동
03hoho03 Aug 27, 2024
d23e5f3
Fix: import 수정
03hoho03 Aug 27, 2024
f33ec37
Fix: 누락된 args 추가
03hoho03 Aug 27, 2024
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
16 changes: 3 additions & 13 deletions what_team_my_team/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
import React from 'react'
import { Preview } from '@storybook/react'
import '../styles/global.css'
import Layout from '../app/layout'
import {fn} from '@storybook/test'
import { fn } from '@storybook/test'

const preview: Preview = {
parameters: {
actions: { handleClick: fn()},
actions: { handleClick: fn() },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
nextjs: {
appDirectory: true
appDirectory: true,
},
},
}

// export const decorators = [
// (Story) => {
// return React.createElement(Layout,{
// children:React.createElement(Story)
// })
// }
// ]

export default preview
2 changes: 1 addition & 1 deletion what_team_my_team/_components/ProfileMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const ProfileMenu = ({ user }: ProfileMenuProps) => {
},
{
label: '팀관리',
href: `/profile/${user?.id}/team`,
href: `/profile/${user?.id}/teamManage`,
onClick: handleItemClick,
},
]
Expand Down
1 change: 1 addition & 0 deletions what_team_my_team/_components/ui/Avatar/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const AvatarRootVariants = cva(`inline-flex items-center justify-center`, {
},
rounded: {
full: 'rounded-full',
rect: 'rounded-xl',
},
},
defaultVariants: {
Expand Down
1 change: 0 additions & 1 deletion what_team_my_team/_components/ui/DropdownMenu/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const DropdownMenuContent = React.forwardRef<
<DropdownMenuPrimitive.Content
className={cn(
DropdownMenuContentVariants({ colorType, animate, size }),
'w-48 md:w-56',
className,
)}
{...props}
Expand Down
2 changes: 1 addition & 1 deletion what_team_my_team/_lib/axios.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios'

const baseURL =
export const baseURL =
process.env.NEXT_PUBLIC_API_MOCKING === 'enabled'
? process.env.NEXT_PUBLIC_MOCK_BASE_URL
: process.env.NEXT_PUBLIC_BASE_URL
Expand Down
66 changes: 66 additions & 0 deletions what_team_my_team/_mocks/datas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,69 @@ const entireTeamData = {
})),
}

const myTeamData = {
team: [
{
id: 45,
title: '왜적 장호정을 물리쳐라잇',
leader_info: {
name: '강태원',
id: 1112,
image_url: 'https://avatars.githubusercontent.com/u/71972587?v=4',
is_leader: true,
},
member_count: 1,
},
{
id: 44,
title: '왜적 장호정을 물리쳐라',
leader_info: {
name: '김연재',
id: 1112,
image_url: 'https://avatars.githubusercontent.com/u/71972587?v=4',
is_leader: true,
},
member_count: 1,
},
],
}

const myTeamDetailData = {
title: '왜적 장호정을 물리쳐라잇',
leader_info: {
name: '일이삼',
student_num: '201811318',
id: 1112,
image_url: 'https://avatars.githubusercontent.com/u/71972587?v=4',
position: '백엔드',
category: '팀장',
},
members_info: Array.from({ length: 6 }, (_, idx) => ({
name: '장호정',
student_num: '2020131313',
id: idx,
image_url: 'https://avatars.githubusercontent.com/u/71972587?v=4',
position: '백엔드',
category: '게임 기획',
})),
member_count: 2,
team_id: 49,
}
const notApprovedMemberData = Array.from({ length: 4 }, (_, idx) => ({
id: idx,
team_id: 36,
created_at: '2024-04-26T02:24:42.910791',
bio: '열심히 하겠습니다!!',
tech: '웹',
user_info: {
id: 127,
name: '이경자',
image_url:
'https://wtnt-bucket.s3.ap-northeast-2.amazonaws.com/default/thumnail.jpg',
position: '디자이너',
},
}))

export {
AssignData,
EntireData,
Expand All @@ -249,4 +312,7 @@ export {
MainPageProjectListData,
assignTeamListData,
entireTeamData,
myTeamData,
myTeamDetailData,
notApprovedMemberData,
}
12 changes: 12 additions & 0 deletions what_team_my_team/_mocks/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import {
MainPageProjectListData,
entireTeamData,
assignTeamListData,
myTeamData,
myTeamDetailData,
notApprovedMemberData,
} from './datas'

export const handlers = [
Expand Down Expand Up @@ -44,9 +47,18 @@ export const handlers = [
return HttpResponse.json(AccomplishedData)
}
}),
http.get(`*/user/profile/team-manage/detail/*`, () => {
return HttpResponse.json(myTeamDetailData)
}),
http.get(`*/user/profile/team-manage/*`, () => {
return HttpResponse.json(myTeamData)
}),
http.get(`*/user/profile/*`, () => {
return HttpResponse.json(ProfileData)
}),
http.get(`*/apply/*`, () => {
return HttpResponse.json(notApprovedMemberData)
}),
http.get(`*/team/detail/*`, () => {
return HttpResponse.json(ProjectDetailData)
}),
Expand Down
20 changes: 20 additions & 0 deletions what_team_my_team/_services/mutations/useAcceptMemberWithLeader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import axiosInstance from '@/_lib/axios'
import { useMutation } from '@tanstack/react-query'

export const acceptMemberWithLeaderApi = async ({
requestId,
}: {
requestId: number
}) => {
const response = await axiosInstance.patch(`/apply/${requestId}`)

return response.data
}

export const useAcceptMemberWithLeader = () => {
const acceptMemberWithLeaderMutation = useMutation({
mutationFn: acceptMemberWithLeaderApi,
})

return acceptMemberWithLeaderMutation
}
27 changes: 27 additions & 0 deletions what_team_my_team/_services/mutations/useBanMemberFromProject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import axiosInstance from '@/_lib/axios'
import { useMutation } from '@tanstack/react-query'

const banMemberFromProject = async ({
teamId,
userId,
}: {
teamId: string
userId: number
}) => {
const body = {
ban_user: userId,
}

const response = await axiosInstance.delete(
`/user/profile/team-manage/detail/${teamId}`,
{ data: body },
)

return response.data
}

export const useBanMemberFromProject = () => {
const mutation = useMutation({ mutationFn: banMemberFromProject })

return mutation
}
22 changes: 22 additions & 0 deletions what_team_my_team/_services/mutations/useDeleteTeamWithLeader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import axiosInstance from '@/_lib/axios'
import { useMutation } from '@tanstack/react-query'

export const deleteTeamWithLeaderApi = async ({
teamId,
}: {
teamId: string
}) => {
const response = await axiosInstance.delete(
`/user/profile/team-manage/${teamId}`,
)

return response.data
}

export const useDeleteTeamWithLeader = () => {
const deleteTeamWithLeaderMutation = useMutation({
mutationFn: deleteTeamWithLeaderApi,
})

return deleteTeamWithLeaderMutation
}
16 changes: 16 additions & 0 deletions what_team_my_team/_services/mutations/useLeaveTeam.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import axiosInstance from '@/_lib/axios'
import { useMutation } from '@tanstack/react-query'

export const leaveTeamApi = async ({ teamId }: { teamId: string }) => {
const response = await axiosInstance.patch(
`/user/profile/team-manage/${teamId}`,
)

return response.data
}

export const useLeaveTeam = () => {
const leaveTeamMutation = useMutation({ mutationFn: leaveTeamApi })

return leaveTeamMutation
}
20 changes: 20 additions & 0 deletions what_team_my_team/_services/mutations/useRejectMemberWithLeader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import axiosInstance from '@/_lib/axios'
import { useMutation } from '@tanstack/react-query'

export const rejectMemberWithLeaderApi = async ({
requestId,
}: {
requestId: number
}) => {
const response = await axiosInstance.delete(`/apply/${requestId}`)

return response.data
}

export const useRejectMemberWithLeader = () => {
const rejectMemberWithLeaderMutation = useMutation({
mutationFn: rejectMemberWithLeaderApi,
})

return rejectMemberWithLeaderMutation
}
37 changes: 37 additions & 0 deletions what_team_my_team/_services/queries/useCheckLeader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import axiosInstance from '@/_lib/axios'
import {
ConvertSnakeToCamel,
convertSnakeToCamel,
} from '@/_utils/convertSnakeToCamel'
import { useQuery } from '@tanstack/react-query'
import { AxiosError } from 'axios'

export interface CheckLeaderApiResponse {
is_leader: boolean
}

export const checkLeaderApi = async ({ teamId }: { teamId: string }) => {
const response = await axiosInstance.get(`/team/check-leader/${teamId}`)

return response.data
}

const IS_LEADER_KEY = 'is-leader'

export const useCheckLeader = ({ teamId }: { teamId: string }) => {
const query = useQuery<
CheckLeaderApiResponse,
AxiosError,
ConvertSnakeToCamel<CheckLeaderApiResponse>
>({
queryKey: [IS_LEADER_KEY, teamId],
queryFn: () => checkLeaderApi({ teamId }),
select: (data) => {
const convertedData = convertSnakeToCamel(data)

return convertedData
},
})

return query
}
50 changes: 50 additions & 0 deletions what_team_my_team/_services/queries/useMyTeam.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import axiosInstance from '@/_lib/axios'
import {
convertSnakeToCamel,
ConvertSnakeToCamel,
} from '@/_utils/convertSnakeToCamel'
import { useQuery } from '@tanstack/react-query'
import { AxiosError } from 'axios'

export type Team = {
id: number
title: string
member_count: number
leader_info: {
name: string
id: number
image_url: string
is_leader: boolean
}
}
export type TeamCamel = ConvertSnakeToCamel<Team>

const getManageTeamApi = async ({ userId }: { userId: string }) => {
const response = await axiosInstance.get(
`/user/profile/team-manage/${userId}`,
)

return response.data
}

const MANAGE_MY_TEAM_KEY = 'team-manage'

const useMyTeam = ({ userId }: { userId: string }) => {
const query = useQuery<
{ team: Team[] },
AxiosError,
ConvertSnakeToCamel<{ team: Team[] }>
>({
queryFn: () => getManageTeamApi({ userId }),
queryKey: [MANAGE_MY_TEAM_KEY, userId],
select: (data) => {
const camelData = convertSnakeToCamel(data)

return camelData
},
})

return query
}

export default useMyTeam
Loading
Loading