From 1caffc508b6f1460c7a7035ef08936411a09cf16 Mon Sep 17 00:00:00 2001 From: kevinkim910408 Date: Sun, 7 May 2023 07:34:44 -0400 Subject: [PATCH 1/9] =?UTF-8?q?fix:=20=EC=A4=91=EB=B3=B5=ED=99=95=EC=9D=B8?= =?UTF-8?q?=20key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Auth/RegisterComponent.tsx | 2 +- src/data/DTO/UserDTO.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Auth/RegisterComponent.tsx b/src/components/Auth/RegisterComponent.tsx index 804fe4f..e2b9310 100644 --- a/src/components/Auth/RegisterComponent.tsx +++ b/src/components/Auth/RegisterComponent.tsx @@ -48,7 +48,7 @@ const RegisterComponent = ({ const signupAPI = usePostSignUp(); const onNameDupCheckHandler = () => { - nameDupCheckAPI.mutate({ nickName }); + nameDupCheckAPI.mutate({ nickname: nickName }); }; const onEmailDupCheckHandler = () => { emailDupCheckAPI.mutate({ email: id }); diff --git a/src/data/DTO/UserDTO.ts b/src/data/DTO/UserDTO.ts index 82bbcdd..bf07d19 100644 --- a/src/data/DTO/UserDTO.ts +++ b/src/data/DTO/UserDTO.ts @@ -9,6 +9,6 @@ export interface UserSignUpDTO extends UserLoginDTO { } export interface DupCheckDTO { - nickName?: string; + nickname?: string; email?: string; } From 779a1732f0a63d4a5568fb53f46d2f7922a52e58 Mon Sep 17 00:00:00 2001 From: kevinkim910408 Date: Sun, 7 May 2023 09:47:40 -0400 Subject: [PATCH 2/9] =?UTF-8?q?fix:=20=EB=84=A4=EB=B9=84=EA=B2=8C=EC=9D=B4?= =?UTF-8?q?=EC=85=98=20bar=20center=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/BottomNav.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/BottomNav.tsx b/src/components/BottomNav.tsx index 555e3c3..f223c67 100644 --- a/src/components/BottomNav.tsx +++ b/src/components/BottomNav.tsx @@ -2,7 +2,7 @@ function BottomNav() { return (
-
+

카테고리

-
+

-
+

톡톡

-
+
Date: Fri, 19 May 2023 10:42:48 -0400 Subject: [PATCH 3/9] feat: delete user API : 403 issue --- src/api/endpoints/UserAPIs.ts | 9 ++++++++- src/app/mypage/page.tsx | 12 +++++++++++- src/data/DTO/UserDTO.ts | 4 ++++ src/hooks/query/userDelete.ts | 17 +++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 src/hooks/query/userDelete.ts diff --git a/src/api/endpoints/UserAPIs.ts b/src/api/endpoints/UserAPIs.ts index 9830a49..75e40bc 100644 --- a/src/api/endpoints/UserAPIs.ts +++ b/src/api/endpoints/UserAPIs.ts @@ -1,4 +1,9 @@ -import { DupCheckDTO, UserLoginDTO, UserSignUpDTO } from "@/data/DTO/UserDTO"; +import { + DupCheckDTO, + UserDeleteDTO, + UserLoginDTO, + UserSignUpDTO, +} from "@/data/DTO/UserDTO"; import api from "../index"; export const UserAPIs = { @@ -8,4 +13,6 @@ export const UserAPIs = { api.post("/member/checkemail", payload), postNickNameDupCheck: (payload: DupCheckDTO) => api.post("/member/checknickname", payload), + deleteUser: (payload: UserDeleteDTO) => + api.delete(`/profile/${payload.memberId}`), }; diff --git a/src/app/mypage/page.tsx b/src/app/mypage/page.tsx index 3b6fe6e..b74cafc 100644 --- a/src/app/mypage/page.tsx +++ b/src/app/mypage/page.tsx @@ -2,8 +2,15 @@ import Image from "next/image"; import Logo_H_W from "@/assets/logo_horizontal_white.svg"; import Arrow_Right from "@/assets/arrow_right.svg"; +import useDeleteUser from "@/hooks/query/userDelete"; const Page = () => { + const deleteUserAPI = useDeleteUser(); + + const deleteUserHandler = () => { + deleteUserAPI.mutate({ memberId: "kjunho.dev@gmail.com" }); + }; + return (
{/* Header */} @@ -32,7 +39,10 @@ const Page = () => { />
-
+
회원탈퇴
{ + const del = await UserAPIs.deleteUser(payload); + return del; +}; + +const useDeleteUser = () => { + return useMutation(__delete, { + onSuccess: (data) => {}, + onError: (error) => {}, + }); +}; + +export default useDeleteUser; From 62b86141fb2994e5fb687aac3f3c92cd5914c632 Mon Sep 17 00:00:00 2001 From: kevinkim910408 Date: Fri, 19 May 2023 11:22:28 -0400 Subject: [PATCH 4/9] =?UTF-8?q?feat:=20=EA=B8=80=EB=A1=9C=EB=B2=8C?= =?UTF-8?q?=EB=AA=A8=EB=8B=AC=20(=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/layout.tsx | 5 +- src/assets/thanks.svg | 9 ++++ src/components/Auth/RegisterComponent.tsx | 26 ++++++++-- src/components/BottomNav.tsx | 6 ++- src/components/Common/Modal.tsx | 58 +++++++++++++++++++++++ src/data/Enum.ts | 2 + 6 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 src/assets/thanks.svg create mode 100644 src/components/Common/Modal.tsx diff --git a/src/app/layout.tsx b/src/app/layout.tsx index e4fc971..f128ee5 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -5,6 +5,7 @@ import "./globals.css"; import Providers from "./Providers"; import BottomNav from "@/components/BottomNav"; import { usePathname } from "next/navigation"; +import { MAX_WIDTH_SIZE } from "@/data/Enum"; export default function RootLayout({ children, @@ -17,7 +18,9 @@ export default function RootLayout({
-
+
{children} {pathname !== "/" && }
diff --git a/src/assets/thanks.svg b/src/assets/thanks.svg new file mode 100644 index 0000000..75a9802 --- /dev/null +++ b/src/assets/thanks.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/components/Auth/RegisterComponent.tsx b/src/components/Auth/RegisterComponent.tsx index e2b9310..99bf4ef 100644 --- a/src/components/Auth/RegisterComponent.tsx +++ b/src/components/Auth/RegisterComponent.tsx @@ -1,4 +1,4 @@ -import React, { use, useCallback, useEffect, useState } from "react"; +import React, { useEffect, useState } from "react"; import Image from "next/image"; import Back from "@/assets/backButton_red.svg"; import { RegisterFormType } from "./AuthTypes"; @@ -13,6 +13,8 @@ import usePostEmailDupCheck from "@/hooks/query/userPostEmailCheck copy"; import usePostImageUpload from "@/hooks/query/commonPostImageUpload"; import usePostSignUp from "@/hooks/query/userPostSignUp"; import { useRouter } from "next/navigation"; +import Modal from "../Common/Modal"; +import Thanks from "@/assets/thanks.svg"; interface RegisterComponentProps { toggleHandler: () => void; @@ -41,12 +43,14 @@ const RegisterComponent = ({ const [previewImage, setPreviewImage] = useState( "https://cdn-icons-png.flaticon.com/512/338/338864.png" ); - const router = useRouter(); + const nameDupCheckAPI = usePostNameDupCheck(); const emailDupCheckAPI = usePostEmailDupCheck(); const imageAPI = usePostImageUpload(); const signupAPI = usePostSignUp(); + const [regiSuccessModal, setRegiSuccessModal] = useState(false); + const onNameDupCheckHandler = () => { nameDupCheckAPI.mutate({ nickname: nickName }); }; @@ -101,12 +105,26 @@ const RegisterComponent = ({ useEffect(() => { if (signupAPI.isSuccess) { - alert("회원가입 성공"); - setToggle(!toggle); + setRegiSuccessModal(true); + // alert("회원가입에 성공"); + // setToggle(!toggle); } }, [signupAPI.isSuccess, toggle, setToggle]); return ( <> + {regiSuccessModal && ( + + )}
{/* 뒤로가기 */}
+
>; + modalSetter: React.Dispatch>; +} + +const Modal = (props: IProps) => { + const router = useRouter(); + const onNavigationHandler = () => { + props.modalSetter((v) => !v); + if (props.btnNav) { + router.push(props.btnNav); + } + if (props.btnSetter) { + props.btnSetter((v) => !v); + } + }; + return ( +
+
+

{props.title}

+ tok tok logo +
+

{props.sub}

+

{props.sub2}

+
+
+

{props.sub3}

+

{props.sub4}

+
+ {props.btnTxt && ( + + )} +
+
+ ); +}; + +export default Modal; diff --git a/src/data/Enum.ts b/src/data/Enum.ts index afdf4dd..f2e906f 100644 --- a/src/data/Enum.ts +++ b/src/data/Enum.ts @@ -2,3 +2,5 @@ export enum ENUM { STATUS_200 = 200, STATUS_400 = 400, } + +export const MAX_WIDTH_SIZE = "420px"; From cbcfbcfed74f153ce548ed7a2e03d7a900ae0743 Mon Sep 17 00:00:00 2001 From: kevinkim910408 Date: Fri, 19 May 2023 11:23:47 -0400 Subject: [PATCH 5/9] =?UTF-8?q?feat:=20alert,=20comment=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Auth/LoginComponent.tsx | 1 - src/components/Auth/RegisterComponent.tsx | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/components/Auth/LoginComponent.tsx b/src/components/Auth/LoginComponent.tsx index ed4e4ca..1d1ba72 100644 --- a/src/components/Auth/LoginComponent.tsx +++ b/src/components/Auth/LoginComponent.tsx @@ -52,7 +52,6 @@ const LoginComponent = ({ useEffect(() => { if (loginAPI.data?.data.statusCode === ENUM.STATUS_200) { - alert("로그인 성공"); router.push("/main"); } }, [loginAPI, router]); diff --git a/src/components/Auth/RegisterComponent.tsx b/src/components/Auth/RegisterComponent.tsx index 99bf4ef..29c902b 100644 --- a/src/components/Auth/RegisterComponent.tsx +++ b/src/components/Auth/RegisterComponent.tsx @@ -106,8 +106,6 @@ const RegisterComponent = ({ useEffect(() => { if (signupAPI.isSuccess) { setRegiSuccessModal(true); - // alert("회원가입에 성공"); - // setToggle(!toggle); } }, [signupAPI.isSuccess, toggle, setToggle]); return ( From 4d408661e15573fe5e715dd29384b4248ff36beb Mon Sep 17 00:00:00 2001 From: kevinkim910408 Date: Fri, 19 May 2023 11:31:02 -0400 Subject: [PATCH 6/9] =?UTF-8?q?feat:=20navbar=EC=97=90=20link=20=EC=97=B0?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/BottomNav.tsx | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/components/BottomNav.tsx b/src/components/BottomNav.tsx index 6062903..f62d072 100644 --- a/src/components/BottomNav.tsx +++ b/src/components/BottomNav.tsx @@ -1,12 +1,22 @@ +"use client"; + import { MAX_WIDTH_SIZE } from "@/data/Enum"; +import { useRouter } from "next/navigation"; function BottomNav() { + const router = useRouter(); + const navigationHandler = (link: string) => { + router.push(link); + }; return (
-
+
navigationHandler("/posts")} + >

카테고리

-
+
navigationHandler("/main")} + >

-
+
navigationHandler("/toktok")} + >

톡톡

-
+
navigationHandler("/mypage")} + > Date: Sun, 21 May 2023 07:49:06 -0400 Subject: [PATCH 7/9] feat: redux persist with saving user email and token --- src/app/main/page.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/main/page.tsx b/src/app/main/page.tsx index 8dd7cff..c5809fe 100644 --- a/src/app/main/page.tsx +++ b/src/app/main/page.tsx @@ -1,11 +1,15 @@ +"use client"; import Image from "next/image"; import Logo_H from "@/assets/logo_horizontal.svg"; import BottomNav from "@/components/BottomNav"; import PostInfoCard from "@/components/Common/PostInfoCard"; import ImageCarousel from "@/components/Main/ImageCarousel"; import TodaysHotItemCarousel from "@/components/Main/TodaysHotItemCarousel"; +import { useAppSelector } from "@/Redux/store"; +import { useSelector } from "react-redux"; const MainPage = () => { + const { token, email } = useAppSelector((state) => state.user); return (
{/* TODO: 컴포넌트 분리 */} From 215b09fb3d7b51e969b8f1eda3459c93e2287215 Mon Sep 17 00:00:00 2001 From: kevinkim910408 Date: Sun, 21 May 2023 07:49:14 -0400 Subject: [PATCH 8/9] feat: persist --- package.json | 2 ++ src/Redux/Features/UserSlice.ts | 28 +++++++++++++++++++++++ src/Redux/Features/exampleSlice.ts | 24 -------------------- src/Redux/Features/index.ts | 6 +++++ src/Redux/store.ts | 31 ++++++++++++++++++++------ src/app/Providers.tsx | 13 ++++++----- src/app/layout.tsx | 2 +- src/components/Auth/LoginComponent.tsx | 5 +++++ src/components/BottomNav.tsx | 2 +- src/hooks/query/userPostLogin.ts | 7 +++++- yarn.lock | 28 ++++++++++++++++++++--- 11 files changed, 106 insertions(+), 42 deletions(-) create mode 100644 src/Redux/Features/UserSlice.ts delete mode 100644 src/Redux/Features/exampleSlice.ts create mode 100644 src/Redux/Features/index.ts diff --git a/package.json b/package.json index 22f84f4..9fb54fa 100644 --- a/package.json +++ b/package.json @@ -24,10 +24,12 @@ "react-dom": "18.2.0", "react-redux": "^8.0.5", "react-slick": "^0.29.0", + "redux-persist": "^6.0.0", "slick-carousel": "^1.8.1", "typescript": "5.0.2" }, "devDependencies": { + "@types/react-redux": "^7.1.25", "autoprefixer": "^10.4.14", "postcss": "^8.4.21", "tailwindcss": "^3.2.7" diff --git a/src/Redux/Features/UserSlice.ts b/src/Redux/Features/UserSlice.ts new file mode 100644 index 0000000..3dc635f --- /dev/null +++ b/src/Redux/Features/UserSlice.ts @@ -0,0 +1,28 @@ +import { createSlice } from "@reduxjs/toolkit"; + +interface UserState { + email: string; + token: string; +} + +const initialState: UserState = { + email: "", + token: "", +}; + +export const userSlice = createSlice({ + name: "userSlicer", + initialState, + reducers: { + __saveEmail: function (state, { type, payload }) { + state.email = payload.email; + }, + __saveToken: function (state, { type, payload }) { + state.token = payload.token; + }, + }, +}); + +export const { __saveEmail, __saveToken } = userSlice.actions; + +export default userSlice.reducer; diff --git a/src/Redux/Features/exampleSlice.ts b/src/Redux/Features/exampleSlice.ts deleted file mode 100644 index f3c219e..0000000 --- a/src/Redux/Features/exampleSlice.ts +++ /dev/null @@ -1,24 +0,0 @@ -'use client'; - -import { createSlice } from '@reduxjs/toolkit'; - -export interface ExampleState { - value: number -} - -const initialState: ExampleState = { - value: 0 -} - -export const exampleSlice = createSlice({ - name: 'example', - initialState, - reducers: { - increment: (state) => { state.value += 1 }, - - } -}) - -export const { increment } = exampleSlice.actions; - -export default exampleSlice.reducer; \ No newline at end of file diff --git a/src/Redux/Features/index.ts b/src/Redux/Features/index.ts new file mode 100644 index 0000000..b72d6ee --- /dev/null +++ b/src/Redux/Features/index.ts @@ -0,0 +1,6 @@ +import { combineReducers } from "@reduxjs/toolkit"; +import UserSlice from "./UserSlice"; + +export const rootReducer = combineReducers({ + user: UserSlice, +}); diff --git a/src/Redux/store.ts b/src/Redux/store.ts index da36acf..f594387 100644 --- a/src/Redux/store.ts +++ b/src/Redux/store.ts @@ -1,11 +1,28 @@ -'use client'; +import { configureStore } from "@reduxjs/toolkit"; +import { useDispatch, useSelector } from "react-redux"; +import { persistReducer } from "redux-persist"; +import { rootReducer } from "./Features"; +import storage from "redux-persist/lib/storage"; -import { configureStore } from '@reduxjs/toolkit'; -import exampleSlice from './Features/exampleSlice'; +const persistConfig = { + key: "root", + storage, + whitelist: ["user"], +}; -export const store = configureStore({reducer:{ - example: exampleSlice -}}) +const persistedReducer = persistReducer(persistConfig, rootReducer); +const store = configureStore({ + reducer: persistedReducer, + middleware: (getDefaultMiddleware) => + getDefaultMiddleware({ + serializableCheck: false, + immutableCheck: false, + }), +}); export type RootState = ReturnType; -export type AppDispatch = typeof store.dispatch; \ No newline at end of file +export type AppDispatch = typeof store.dispatch; +export const useAppDispatch = () => useDispatch(); +export const useAppSelector = (selector: (state: RootState) => T) => + useSelector(selector); +export default store; diff --git a/src/app/Providers.tsx b/src/app/Providers.tsx index 3902a40..7b76cdf 100644 --- a/src/app/Providers.tsx +++ b/src/app/Providers.tsx @@ -1,10 +1,10 @@ -"use client"; - import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; import { Provider } from "react-redux"; import React from "react"; -import { store } from "@/Redux/store"; +import store from "@/Redux/store"; +import { persistStore } from "redux-persist"; +import { PersistGate } from "redux-persist/integration/react"; const queryClient = new QueryClient({ defaultOptions: { @@ -15,11 +15,14 @@ const queryClient = new QueryClient({ }, }); +const persistor = persistStore(store); + const Providers = ({ children }: { children: React.ReactNode }) => { return ( - {children} - + + {children} + ); diff --git a/src/app/layout.tsx b/src/app/layout.tsx index f128ee5..6d1e03d 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -19,7 +19,7 @@ export default function RootLayout({
{children} {pathname !== "/" && } diff --git a/src/components/Auth/LoginComponent.tsx b/src/components/Auth/LoginComponent.tsx index 1d1ba72..2b7d5ee 100644 --- a/src/components/Auth/LoginComponent.tsx +++ b/src/components/Auth/LoginComponent.tsx @@ -6,6 +6,8 @@ import Str from "@/data/string.json"; import usePostLogin from "@/hooks/query/userPostLogin"; import { ENUM } from "@/data/Enum"; import { useRouter } from "next/navigation"; +import { useAppDispatch } from "@/Redux/store"; +import { __saveEmail } from "@/Redux/Features/UserSlice"; interface LoginComponentProps { toggleHandler: () => void; @@ -21,8 +23,10 @@ const LoginComponent = ({ const [isButtonDisabled, setIsButtonDisabled] = useState(true); const loginAPI = usePostLogin(); const router = useRouter(); + const dispatch = useAppDispatch(); const onLoginHandler = () => { + dispatch(__saveEmail({ email: loginForm.id })); loginAPI.mutate({ email: loginForm.id, password: loginForm.pw, @@ -35,6 +39,7 @@ const LoginComponent = ({ }, [loginForm, setLoginForm] ); + const onChangePw = useCallback( (e: React.ChangeEvent) => { setLoginForm({ ...loginForm, pw: e.target.value }); diff --git a/src/components/BottomNav.tsx b/src/components/BottomNav.tsx index f62d072..69dea7f 100644 --- a/src/components/BottomNav.tsx +++ b/src/components/BottomNav.tsx @@ -10,7 +10,7 @@ function BottomNav() { }; return (
{ }; const usePostLogin = () => { + const dispatch = useAppDispatch(); return useMutation(__login, { - onSuccess: (data) => {}, + onSuccess: (data) => { + dispatch(__saveToken({ token: data?.headers.authorization })); + }, onError: (error) => {}, }); }; diff --git a/yarn.lock b/yarn.lock index 4780308..ce8f3e6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,7 +2,14 @@ # yarn lockfile v1 -"@babel/runtime@^7.12.1", "@babel/runtime@^7.20.7", "@babel/runtime@^7.9.2": +"@babel/runtime@^7.12.1": + version "7.21.5" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.21.5.tgz#8492dddda9644ae3bda3b45eabe87382caee7200" + integrity sha512-8jI69toZqqcsnqGGqwGS4Qb1VwLOEp4hz+CXPywcvjs60u3B4Pom/U/7rm4W8tMOYEB+E9wgD0mW1l3r8qlI9Q== + dependencies: + regenerator-runtime "^0.13.11" + +"@babel/runtime@^7.20.7", "@babel/runtime@^7.9.2": version "7.21.0" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.21.0.tgz#5b55c9d394e5fcf304909a8b00c07dc217b56673" integrity sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw== @@ -221,7 +228,7 @@ "@tanstack/query-core" "4.27.0" use-sync-external-store "^1.2.0" -"@types/hoist-non-react-statics@^3.3.1": +"@types/hoist-non-react-statics@^3.3.0", "@types/hoist-non-react-statics@^3.3.1": version "3.3.1" resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f" integrity sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA== @@ -251,6 +258,16 @@ dependencies: "@types/react" "*" +"@types/react-redux@^7.1.25": + version "7.1.25" + resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-7.1.25.tgz#de841631205b24f9dfb4967dd4a7901e048f9a88" + integrity sha512-bAGh4e+w5D8dajd6InASVIyCo4pZLJ66oLb80F9OBLO1gKESbZcRCJpTT6uLXX+HAB57zw1WTdwJdAsewuTweg== + dependencies: + "@types/hoist-non-react-statics" "^3.3.0" + "@types/react" "*" + hoist-non-react-statics "^3.3.0" + redux "^4.0.0" + "@types/react-slick@^0.23.10": version "0.23.10" resolved "https://registry.yarnpkg.com/@types/react-slick/-/react-slick-0.23.10.tgz#56126e6e4e95cdce7771535b2811c2c1931a7caa" @@ -2121,12 +2138,17 @@ readdirp@~3.6.0: dependencies: picomatch "^2.2.1" +redux-persist@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/redux-persist/-/redux-persist-6.0.0.tgz#b4d2972f9859597c130d40d4b146fecdab51b3a8" + integrity sha512-71LLMbUq2r02ng2We9S215LtPu3fY0KgaGE0k8WRgl6RkqxtGfl7HUozz1Dftwsb0D/5mZ8dwAaPbtnzfvbEwQ== + redux-thunk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.4.2.tgz#b9d05d11994b99f7a91ea223e8b04cf0afa5ef3b" integrity sha512-+P3TjtnP0k/FEjcBL5FZpoovtvrTNT/UXd4/sluaSyrURlSlhLSzEdfsTBW7WsKB6yPvgd7q/iZPICFjW4o57Q== -redux@^4.2.0: +redux@^4.0.0, redux@^4.2.0: version "4.2.1" resolved "https://registry.yarnpkg.com/redux/-/redux-4.2.1.tgz#c08f4306826c49b5e9dc901dee0452ea8fce6197" integrity sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w== From effc8db48c9acf512b95efee1844bf1d7a5f5590 Mon Sep 17 00:00:00 2001 From: kevinkim910408 Date: Sun, 21 May 2023 07:51:37 -0400 Subject: [PATCH 9/9] feat: interceptor + token --- src/api/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/api/index.ts b/src/api/index.ts index 64615c8..ae322e5 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,3 +1,4 @@ +import { useAppSelector } from "@/Redux/store"; import axios from "axios"; const api = axios.create({ @@ -7,6 +8,8 @@ const api = axios.create({ // request Interceptor api.interceptors.request.use( (data) => { + const { token } = useAppSelector((state) => state.user); + data.headers!.Authorization = "Bearer " + token; return data; }, () => {}