-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
close: #165 * ✨ Feat: 로그인 시 내 정보 가져오기 추가 - 세션 스토리지에서 관리 - 로그아웃 시 제거 related to: #165 * ✨ Feat(activity): 게시판 생성시 권한 확인 추가 related to: #165 * 💄 Design(create-board): 게시판 이용자 input label UI 수정 * ✨ Feat(create-board): 권한 없을 때 에러 처리 추가 relatd to: #165
- Loading branch information
Showing
14 changed files
with
112 additions
and
27 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
16 changes: 11 additions & 5 deletions
16
src/app/(main)/activity/[semesterName]/[activityId]/_components/CreateBoardButton/index.tsx
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,16 +1,22 @@ | ||
import Link from 'next/link' | ||
import { usePathname } from 'next/navigation' | ||
import { usePathname, useRouter } from 'next/navigation' | ||
|
||
import { Button } from '@/components/ui/button' | ||
import { useMyInfoStore } from '@/store/myInfo' | ||
|
||
export const CreateBoardButton = () => { | ||
const pathName = usePathname() | ||
const router = useRouter() | ||
const { role } = useMyInfoStore((state) => state.getMyInfo()) | ||
|
||
return ( | ||
<div className="mb-20 flex w-full justify-end"> | ||
<Link href={`${pathName}/create-board`}> | ||
<Button className="max-w-fit">게시판 생성하기</Button> | ||
</Link> | ||
<Button | ||
className="max-w-fit" | ||
onClick={() => router.push(`${pathName}/create-board`)} | ||
disabled={!(role === '해구르르' || role === '팀장')} | ||
> | ||
게시판 생성하기 | ||
</Button> | ||
</div> | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { AUTHORIZATION_API } from '@/service/config' | ||
import { Role } from '@/types/user' | ||
|
||
type MyInfoResponse = { | ||
userId: string | ||
studentNumber: number | ||
userName: string | ||
role: Role | ||
regDate: string | ||
} | ||
|
||
export const getMyInfo = async () => { | ||
const response = await AUTHORIZATION_API.get<MyInfoResponse>('/users/me') | ||
|
||
return response.data | ||
} |
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,8 +1,17 @@ | ||
import { AxiosError } from 'axios' | ||
|
||
import { ACCESS_ERROR_MESSAGE } from '@/constant/errorMessage' | ||
import { AUTHORIZATION_API } from '@/service/config' | ||
import { User } from '@/types/user' | ||
|
||
export const getUsers = async () => { | ||
const response = await AUTHORIZATION_API.get<User[]>('/private/users') | ||
try { | ||
const response = await AUTHORIZATION_API.get<User[]>('/private/users') | ||
|
||
return response.data | ||
return response.data | ||
} catch (error) { | ||
if (error instanceof AxiosError) { | ||
throw new Error(ACCESS_ERROR_MESSAGE.UNAUTHORIZED_ERROR) | ||
} | ||
} | ||
} |
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,31 @@ | ||
import { create } from 'zustand' | ||
import { createJSONStorage, persist } from 'zustand/middleware' | ||
|
||
import { Role } from '@/types/user' | ||
|
||
export type MyInfo = { | ||
userName: string | ||
role?: Role | ||
} | ||
|
||
interface MyInfoProps { | ||
myInfo: MyInfo | ||
setMyInfo: (myInfo: MyInfo) => void | ||
clearMyInfo: () => void | ||
getMyInfo: () => MyInfo | ||
} | ||
|
||
export const useMyInfoStore = create( | ||
persist<MyInfoProps>( | ||
(set, get) => ({ | ||
myInfo: { userName: '', role: undefined }, | ||
setMyInfo: (myInfo) => set({ myInfo }), | ||
clearMyInfo: () => set({ myInfo: { userName: '', role: undefined } }), | ||
getMyInfo: () => get().myInfo, | ||
}), | ||
{ | ||
name: 'my-info', | ||
storage: createJSONStorage(() => sessionStorage), | ||
}, | ||
), | ||
) |
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