Skip to content

Commit

Permalink
Merge pull request #180 from 98OO/develop
Browse files Browse the repository at this point in the history
main 브랜치 병합
  • Loading branch information
Seol-JY authored Nov 21, 2024
2 parents aa87925 + dffc43f commit fdae1bb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 31 deletions.
7 changes: 7 additions & 0 deletions src/components/common/GNB/GNB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import GNBTeamSpace from '@components/common/GNB/GNBMenu/GNBTeamSpace/GNBTeamSpa
import Heading from '@components/common/Heading/Heading';
import Icon from '@components/common/Icon/Icon';
import useMenu from '@hooks/common/useMenu';
import useRecordTeamSpace from '@hooks/queries/teamspace/useRecordTeamSpace';
import useUserStatusQuery from '@hooks/queries/useUserStatusQuery';
import { StompSubscription } from '@stomp/stompjs';
import useSocketStore from '@stores/socketStore';
Expand All @@ -19,6 +20,7 @@ const GNB = () => {
const lastSeenTeam = userStatus?.participatedTeamspaces.find(
(team) => team.teamspaceId === userStatus?.profile.lastSeenTeamspaceId
);
const { mutateRecordTeamSpace } = useRecordTeamSpace();

const { toggleMenu: handleTeamSpace, showMenu: showTeamSpace } = useMenu();
const { toggleMenu: handleTeamInfo, showMenu: showTeamInfo } = useMenu();
Expand Down Expand Up @@ -96,6 +98,11 @@ const GNB = () => {
};
}, [userStatus, stompClient]);

useEffect(() => {
if (userStatus?.profile.lastSeenTeamspaceId === null && userStatus)
mutateRecordTeamSpace(userStatus.participatedTeamspaces[0].teamspaceId);
}, [userStatus]);

useLayoutEffect(() => {
updatePosition();
window.addEventListener('resize', updatePosition);
Expand Down
21 changes: 15 additions & 6 deletions src/components/common/GNB/GNBMenu/GNBTeamInfo/GNBTeamInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ const GNBTeamInfo = () => {
const lastSeenTeam = userStatus?.participatedTeamspaces.find(
(team) => team.teamspaceId === userStatus?.profile.lastSeenTeamspaceId
);
const teamRole = userStatus?.participatedTeamspaces?.find(
(teamspace) =>
teamspace.teamspaceId === userStatus?.profile.lastSeenTeamspaceId
)?.teamspaceRole;

const { formData, submitting, errors, register, handleSubmit } = useForm({
onSubmit: async () => {
if (userStatus?.profile.lastSeenTeamspaceId !== undefined) {
Expand Down Expand Up @@ -121,12 +126,16 @@ const GNBTeamInfo = () => {
</Flex>
<Divider size='sm' padding={4} />
<Flex paddingLeft='16' paddingRight='16' justify='space-between'>
<S.FooterWrapper onClick={() => navigate(PATH.SETTING)}>
<Icon name='Settings' size='sm' color='iSecondary' />
<Text size='md' weight='medium' color='secondary'>
설정
</Text>
</S.FooterWrapper>
<Flex>
{teamRole === 'LEADER' && (
<S.FooterWrapper onClick={() => navigate(PATH.SETTING)}>
<Icon name='Settings' size='sm' color='iSecondary' />
<Text size='md' weight='medium' color='secondary'>
설정
</Text>
</S.FooterWrapper>
)}
</Flex>
<S.FooterWrapper
onClick={() => mutateTeampSpaceCode(lastSeenTeam.teamspaceId)}>
<Icon name='Link' size='sm' color='iSecondary' />
Expand Down
31 changes: 6 additions & 25 deletions src/components/common/GNB/GNBMenu/GNBTeamSpace/GNBTeamSpace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ const GNBTeamSpace = () => {
const { mutateRecordTeamSpace } = useRecordTeamSpace();
const navigate = useNavigate();

const lastSeenTeam = userStatus?.participatedTeamspaces.find(
(team) => team.teamspaceId === userStatus?.profile.lastSeenTeamspaceId
);
const otherProfiles = userStatus?.participatedTeamspaces.filter(
(teamSpace) => teamSpace.name !== lastSeenTeam?.name
);

const { increaseChatMessageCount, setChatChannelList } = useSocketStore();

const handleTeamChangeClick = (teamSpaceId: number) => {
Expand All @@ -33,7 +26,7 @@ const GNBTeamSpace = () => {

return (
<S.GNBTeamSpaceContainer>
{userStatus && lastSeenTeam && otherProfiles && (
{userStatus && (
<>
<Flex direction='column' gap='4'>
<Flex
Expand All @@ -55,23 +48,7 @@ const GNBTeamSpace = () => {
paddingRight='16'
gap='8'>
<S.TeamSpacesWrapper>
<Profile
key={lastSeenTeam.teamspaceId}
profile={lastSeenTeam.profileImageUrl}
initial={lastSeenTeam.name}
avatarSize='lg'
avatarShape='rect'
title={lastSeenTeam.name}
titleSize='lg'
titleWeight='bold'
text={
lastSeenTeam.teamspaceRole === 'LEADER'
? `팀장 - 총 ${lastSeenTeam.numOfParticipants}명의 멤버`
: '팀원'
}
trailingIcon='Check'
/>
{otherProfiles.map((teamSpace) => (
{userStatus.participatedTeamspaces.map((teamSpace) => (
<Profile
key={teamSpace.teamspaceId}
profile={teamSpace.profileImageUrl}
Expand All @@ -86,6 +63,10 @@ const GNBTeamSpace = () => {
? `팀장 - 총 ${teamSpace.numOfParticipants}명의 멤버`
: '팀원'
}
{...(teamSpace.teamspaceId ===
userStatus.profile.lastSeenTeamspaceId && {
trailingIcon: 'Check',
})}
onClick={() => handleTeamChangeClick(teamSpace.teamspaceId)}
/>
))}
Expand Down
1 change: 1 addition & 0 deletions src/hooks/queries/teamspace/useRecordTeamSpace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const useRecordTeamSpace = () => {
const handleSettingSucess = () => {
queryClient.invalidateQueries({ queryKey: ['userStatus'] });
queryClient.invalidateQueries({ queryKey: ['teamSetting'] });
queryClient.invalidateQueries({ queryKey: ['teamSpaceUsers'] });
queryClient.refetchQueries({ queryKey: ['chatChannel'] });
};

Expand Down

0 comments on commit fdae1bb

Please sign in to comment.