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

Feature/#304 팀페이지 권한 수정 #306

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/app/team/[teamId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ const Page = ({ params }: { params: { teamId: number } }) => {
const myTeam = useAtomValue(myTeamAtom);
const [isMyTeam, setIsMyTeam] = useState<boolean>(false);
useEffect(() => {
if (myTeam.teams !== undefined) {
const res = myTeam.teams.filter((teamId) => teamId === params.teamId);
if (myTeam !== undefined) {
const res = myTeam.filter((teamId) => teamId === Number(params.teamId));
setIsMyTeam(res.length === 1);
}
}, [myTeam, params.teamId]);
Expand Down
4 changes: 1 addition & 3 deletions src/atom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export const defaultUserAtom = {

export const userAtom = atomWithStorage('user', defaultUserAtom as UserAtomType);

export const myTeamAtom = atomWithStorage<{ teams: number[] }>('myTeam', {
teams: [],
});
export const myTeamAtom = atomWithStorage('myTeam', []);

export const loginBackPathAtom = atomWithStorage('loginBackPath', '/');
12 changes: 10 additions & 2 deletions src/components/Sidebar/SidebarContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import { Avatar, Button, Flex, IconButton, Text } from '@chakra-ui/react';
import { useSetAtom } from 'jotai';
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { BiBell, BiUser } from 'react-icons/bi';
import { BsPlus, BsGrid } from 'react-icons/bs';
import { MdOutlineLogout } from 'react-icons/md';

import { useGetSideBarInfoQuery } from '@/app/api/member';
import { defaultUserAtom, userAtom } from '@/atom';
import { defaultUserAtom, myTeamAtom, userAtom } from '@/atom';
import TeamModal from '@/containers/team/TeamModal';
import useGetUser from '@/hooks/useGetUser';

Expand All @@ -20,8 +20,16 @@ const SidebarContent = ({ isOpen, setIsOpen }: SidebarContentProps) => {
const [isTeamModalOpen, setIsTeamModalOpen] = useState<boolean>(false);
const user = useGetUser();
const setUser = useSetAtom(userAtom);
const setMyTeams = useSetAtom(myTeamAtom);
const { data: sidebarInfo } = useGetSideBarInfoQuery();

useEffect(() => {
const myTeams = sidebarInfo?.body.myTeamsAndStudies
? sidebarInfo.body.myTeamsAndStudies.map((team: { teamId: number }) => team.teamId)
: [];
setMyTeams(myTeams);
}, [setMyTeams, sidebarInfo]);

return (
<>
<Flex pos="sticky" top="0" left="0" direction="column" h="100vh" px={isOpen ? '4' : '2'} py="4" bg="green">
Expand Down