-
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.
* feat: study member api with token - #271 * feat : patch study mandate - #271 * feat : 스터디원 관리 Menu - #271 * feat : search by name * refactor : ParticipantMenu 공통 컴포넌트 적용 - #271 * feat : 실제 스터디 정보와 연결 - #271 * fix : build error - #271 - omit으로 불필요한 props 제거 * fix : StudyMemeber Type - #271 * fix : build error - #271 * fix : import order error - #271
- Loading branch information
1 parent
31b34ac
commit 6ad77f8
Showing
10 changed files
with
181 additions
and
9 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { Study } from '@/types'; | ||
|
||
export interface StudyCardProps extends Study { | ||
export interface StudyCardProps extends Omit<Study, 'studyLeaderId' | 'teamReference'> { | ||
rank: number; | ||
} |
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,79 @@ | ||
import { IconButton, Text } from '@chakra-ui/react'; | ||
import { useState } from 'react'; | ||
import { MdOutlineArrowForwardIos } from 'react-icons/md'; | ||
|
||
import { patchStudyMandate } from '@/app/api/member'; | ||
import { deleteStudyMember, getStudyMembers, postStudyMember } from '@/app/api/study'; | ||
import { getTeamMembers } from '@/app/api/team'; | ||
import ParticipantMenu from '@/components/ParticipantMenu'; | ||
import { StudyParticipantMenuProps } from '@/containers/study/StudyParticipantMenu/types'; | ||
import { useGetFetchWithToken, useMutateWithToken } from '@/hooks/useFetchWithToken'; | ||
import useGetUser from '@/hooks/useGetUser'; | ||
import { Member, StudyMember } from '@/types'; | ||
|
||
const StudyParticipantMenu = ({ studyId, teamId, leaderId }: StudyParticipantMenuProps) => { | ||
const user = useGetUser(); | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
const studyMembers = useGetFetchWithToken(getStudyMembers, [studyId], user)?.map( | ||
(data: StudyMember) => | ||
({ | ||
id: data.memberId, | ||
name: data.name, | ||
imageUrl: data.imageUrl, | ||
}) as Member, | ||
); | ||
const teamMembers = useGetFetchWithToken(getTeamMembers, [teamId], user); | ||
|
||
const leader = studyMembers?.find((member: Member) => member.id === leaderId); | ||
const includeMembers = studyMembers?.filter((member: Member) => member.id !== leaderId); | ||
const excludeMembers = teamMembers?.filter( | ||
(member: Member) => !studyMembers?.find((studyData: Member) => studyData.id === member.id), | ||
); | ||
|
||
const addMember = useMutateWithToken(postStudyMember, user); | ||
const deleteMember = useMutateWithToken(deleteStudyMember, user); | ||
const mandateLeader = useMutateWithToken(patchStudyMandate, user); | ||
|
||
const handleAddMember = (member: Member) => { | ||
addMember(studyId, member.id); | ||
}; | ||
|
||
const handleDeleteMember = (member: Member) => { | ||
deleteMember(studyId, member.id); | ||
}; | ||
|
||
const handleMandateLeader = (member: Member) => { | ||
mandateLeader(studyId, member.id); | ||
}; | ||
|
||
return ( | ||
<ParticipantMenu | ||
gap="3" | ||
w="fit-content" | ||
ml="auto" | ||
isOpen={isOpen} | ||
setIsOpen={setIsOpen} | ||
leader={leader} | ||
includeMembers={includeMembers} | ||
excludeMembers={excludeMembers} | ||
onAdd={handleAddMember} | ||
onRemove={handleDeleteMember} | ||
onMandateLeader={handleMandateLeader} | ||
> | ||
<IconButton | ||
fontSize="16px" | ||
transform={isOpen ? 'rotate(90deg)' : 'rotate(0deg)'} | ||
transition="all 0.2s" | ||
aria-label="" | ||
icon={<MdOutlineArrowForwardIos />} | ||
isRound | ||
size="icon_sm" | ||
variant="icon_orange" | ||
/> | ||
<Text>관리</Text> | ||
</ParticipantMenu> | ||
); | ||
}; | ||
|
||
export default StudyParticipantMenu; |
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,5 @@ | ||
export interface StudyParticipantMenuProps { | ||
studyId: number; | ||
teamId: number; | ||
leaderId: number; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
import { Member } from '@/types'; | ||
|
||
export const studyMember: Member[] = [ | ||
{ id: 21, name: '김철수21', imageUrl: '' }, | ||
{ id: 22, name: '김철수22', imageUrl: '' }, | ||
{ id: 23, name: '김철수23', imageUrl: '' }, | ||
{ id: 24, name: '김철수24', imageUrl: '' }, | ||
{ id: 25, name: '김철수25', imageUrl: '' }, | ||
{ id: 26, name: '김철수26', imageUrl: '' }, | ||
{ id: 27, name: '김철수27', imageUrl: '' }, | ||
{ id: 28, name: '김철수28', imageUrl: '' }, | ||
{ id: 29, name: '김철수29', imageUrl: '' }, | ||
{ id: 10, name: '김철수10', imageUrl: '' }, | ||
{ id: 11, name: '김철수11', imageUrl: '' }, | ||
{ id: 12, name: '김철수12', imageUrl: '' }, | ||
{ id: 13, name: '김철수13', imageUrl: '' }, | ||
{ id: 14, name: '김철수14', imageUrl: '' }, | ||
{ id: 15, name: '김철수15', imageUrl: '' }, | ||
{ id: 16, name: '김철수16', imageUrl: '' }, | ||
{ id: 17, name: '김철수17', imageUrl: '' }, | ||
{ id: 18, name: '김철수18', imageUrl: '' }, | ||
{ id: 19, name: '김철수19', imageUrl: '' }, | ||
{ id: 20, name: '김철수20', imageUrl: '' }, | ||
]; |
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