diff --git a/apis/calendar.ts b/apis/calendar.ts index 49181e3..2be6699 100644 --- a/apis/calendar.ts +++ b/apis/calendar.ts @@ -7,6 +7,8 @@ interface GetMonthCalendarResponse extends ResponseBody { export interface MonthCalendarProps { programIdx: number; name: string; + category: string | null; + location: string | null; openDate: { year: number; month: number; @@ -38,7 +40,7 @@ interface GetProgramDetailBody { // 챌린지 월별 조회 export const getMonthCalendar = async (): Promise => { - const response = await client.get("/programs"); + const response = await client.get("/programs/list"); // console.log("calenderData", response.data.result); return response.data.result; }; diff --git a/apis/client.ts b/apis/client.ts index 04a1d94..3e200f3 100644 --- a/apis/client.ts +++ b/apis/client.ts @@ -22,6 +22,18 @@ const getTokenFromLocalStorage = () => { return accessToken; }; +export const setIsAdminAtLocalStorage = (is_admin: string) => { + localStorage.setItem("is_admin", is_admin); +}; + +const getIsAdminFromLocalStorage = () => { + const isAdmin = localStorage.getItem("is_admin"); + if (!isAdmin) { + return null; + } + return isAdmin; +}; + const client = axios.create({ baseURL: process.env.NEXT_PUBLIC_API_URL, withCredentials: true, diff --git a/pages/calendar.tsx b/pages/calendar.tsx index b071487..90b856f 100644 --- a/pages/calendar.tsx +++ b/pages/calendar.tsx @@ -11,7 +11,7 @@ interface DropProps { regionDrop: boolean; } -const categories = ["운동", "예술", "학술"]; +const categories = ["운동", "예술", "학술", "기타"]; const locations = ["서울", "경기", "그 외"]; const CalendarPage: NextPage = () => { @@ -32,7 +32,7 @@ const CalendarPage: NextPage = () => {
-
+
{ @@ -41,11 +41,11 @@ const CalendarPage: NextPage = () => { }} /> {isDrop.categoryDrop ? ( -
    +
      {categories.map((option, index) => (
    • {}} > {option} diff --git a/pages/index.tsx b/pages/index.tsx index d5b3001..55531bd 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -10,6 +10,8 @@ import { ToastContainer, Zoom, toast } from "react-toastify"; import Image from "next/image"; import "react-toastify/dist/ReactToastify.css"; import CheckIcon from "@/public/svgs/Check.svg"; +import { atom, useAtomValue } from "jotai"; +import { isAdminAtom } from "@/utils/atom"; const Home: NextPage = () => { const notify = (msg: string) => { @@ -19,6 +21,10 @@ const Home: NextPage = () => { }); }; + //isAdmin + const isAdmin = useAtomValue(isAdminAtom); + console.log("atom: ", isAdmin); + return ( diff --git a/pages/login.tsx b/pages/login.tsx index 6543f99..981c1a4 100644 --- a/pages/login.tsx +++ b/pages/login.tsx @@ -5,8 +5,14 @@ import { useRouter } from "next/router"; import Button from "@/components/Button"; import LogoLetterIcon from "@/public/svgs/LogoLetter.svg"; import { useMutation } from "@tanstack/react-query"; -import { ResponseBody, setTokenFromLocalStorage } from "@/apis/client"; +import { + ResponseBody, + setIsAdminAtLocalStorage, + setTokenFromLocalStorage, +} from "@/apis/client"; import { SignIn } from "@/apis/auth"; +import { atom, useAtom } from "jotai"; +import { isAdminAtom } from "@/utils/atom"; interface userProps { loginId: string; @@ -15,6 +21,7 @@ interface userProps { const Login: NextPage = () => { const router = useRouter(); + const [isAdmin, setIsAdmin] = useAtom(isAdminAtom); const [userInfo, setUserInfo] = useState({ loginId: "", @@ -50,7 +57,11 @@ const Login: NextPage = () => { console.log(data); const accessToken = data.result.accessToken; const refreshToken = data.result.refreshToken; + const isAdmin = data.result.isAdmin; + setIsAdmin(isAdmin); + setIsAdminAtLocalStorage(isAdmin); setTokenFromLocalStorage(accessToken); + router.push("/"); alert("로그인에 성공하였습니다"); },