Skip to content

Commit

Permalink
feat :: 유저 정보 Context 구성
Browse files Browse the repository at this point in the history
  • Loading branch information
KANGYONGSU23 committed Dec 14, 2023
1 parent c7f5e9e commit 7730b8a
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 25 deletions.
3 changes: 3 additions & 0 deletions src/apis/students/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ export const useMyProfile = () => {
},
{
refetchOnWindowFocus: false,
onSuccess: ()=>{

}
}
);
};
19 changes: 11 additions & 8 deletions src/components/Provider.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"use client";

import UserProfileProvider from "@/context/provider/UserContextProvider";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ToastContainer } from "@team-return/design-system";
import { CookiesProvider } from "react-cookie";
import SignupContextProvider from "./account/singup/ContextProvider";
import ModalContextProvider from "./modal/ModalContextProvider";
import ModalContextProvider from "../context/provider/ModalContextProvider";
import SignupContextProvider from "../context/provider/SignupContextProvider";

interface PropsType {
children: React.ReactNode;
Expand All @@ -15,12 +16,14 @@ export default function Provider({ children }: PropsType) {
return (
<QueryClientProvider client={queryClient}>
<CookiesProvider>
<ModalContextProvider>
<SignupContextProvider>
<ToastContainer />
{children}
</SignupContextProvider>
</ModalContextProvider>
<UserProfileProvider>
<ModalContextProvider>
<SignupContextProvider>
<ToastContainer />
{children}
</SignupContextProvider>
</ModalContextProvider>
</UserProfileProvider>
</CookiesProvider>
</QueryClientProvider>
);
Expand Down
14 changes: 0 additions & 14 deletions src/components/account/singup/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@ export interface IsHiddenProps {
passwordCheck: Boolean;
}

interface PropsType {
inputStates: SignupType;
setInputsStates?: React.Dispatch<React.SetStateAction<SignupType>>;
handleChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
isHidden: IsHiddenProps;
setIsHidden: React.Dispatch<React.SetStateAction<IsHiddenProps>>;
SandAuthCodeAPI?: UseMutateFunction<
any,
AxiosError<unknown, any>,
SendAuthCodeType,
unknown
>;
}

export interface FirstInputsPropsType {
inputStates: SignupType;
handleChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
Expand Down
3 changes: 1 addition & 2 deletions src/context/ModalContext.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";

import { SignupType } from "@/components/account/singup/type";
import { ChangeEvent, createContext, Dispatch, SetStateAction } from "react";
import { createContext, Dispatch, SetStateAction } from "react";

interface ModalContextType {
isOpen: boolean;
Expand Down
19 changes: 19 additions & 0 deletions src/context/UserContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use client";

import { MyProfileProps } from "@/apis/students/type";
import { createContext } from "react";

interface UserProfileContextType {
userProfile: MyProfileProps;
setUserProfile: React.Dispatch<React.SetStateAction<MyProfileProps>>;
}

export const UserProfileContext = createContext<UserProfileContextType>({
userProfile: {
student_name: "",
student_gcn: "",
department: "SOFTWARE_DEVELOP",
profile_image_url: "",
},
setUserProfile: () => {},
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SignupContext } from "@/context/SignupContext";
import useForm from "@/hook/useForm";
import { ReactNode } from "react";
import { SignupType } from "./type";
import { SignupType } from "../../components/account/singup/type";

export default function SignupContextProvider({
children,
Expand Down
22 changes: 22 additions & 0 deletions src/context/provider/UserContextProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { MyProfileProps } from "@/apis/students/type";
import { ModalContext } from "@/context/ModalContext";
import { ReactNode, useState } from "react";
import { UserProfileContext } from "../UserContext";

export default function UserProfileProvider({
children,
}: {
children: React.ReactNode;
}) {
const [userProfile, setUserProfile] = useState<MyProfileProps>({
student_name: "",
student_gcn: "",
department: "SOFTWARE_DEVELOP",
profile_image_url: "",
});
return (
<UserProfileContext.Provider value={{ userProfile, setUserProfile }}>
{children}
</UserProfileContext.Provider>
);
}

0 comments on commit 7730b8a

Please sign in to comment.