-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from whatTeamNaeTeam/feat-프로필팀관리
- Loading branch information
Showing
45 changed files
with
1,084 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
what_team_my_team/_services/mutations/useAcceptMemberWithLeader.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
27
what_team_my_team/_services/mutations/useBanMemberFromProject.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
22
what_team_my_team/_services/mutations/useDeleteTeamWithLeader.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
20
what_team_my_team/_services/mutations/useRejectMemberWithLeader.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.