diff --git a/src/hooks/useSubmitResult.tsx b/src/hooks/useSubmitResult.tsx index bc9bb71..e2820fc 100644 --- a/src/hooks/useSubmitResult.tsx +++ b/src/hooks/useSubmitResult.tsx @@ -6,7 +6,7 @@ import { useUserInfo } from "@/store/store"; export const useSubmitResult = () => { const [isPending, setIsPending] = useState(false); - const major = useUserInfo((state) => state.major); + const department = useUserInfo((state) => state.department); const navigate = useNavigate(); const [searchParams] = useSearchParams(); @@ -15,7 +15,7 @@ export const useSubmitResult = () => { const mbti = searchParams.get("type"); console.log(searchParams); - api.post("/stats", { department: major, mbti }) + api.post("/stats", { department: department, mbti }) .then(() => { navigate(`/result?type=${mbti}`); }) diff --git a/src/pages/HomePage.tsx b/src/pages/HomePage.tsx index 00f06da..4c308be 100644 --- a/src/pages/HomePage.tsx +++ b/src/pages/HomePage.tsx @@ -33,7 +33,7 @@ export default function HomePage() { const userInfo = useUserInfo((state) => state); const [isOpen, setIsOpen] = useState(false); - const [selectedMajor, setSelectedMajor] = useState(""); + const [selectedDepartment, setSelectedDepartment] = useState(""); const handleSideBar = () => { setIsOpen(!isOpen); @@ -44,7 +44,7 @@ export default function HomePage() { toast.error("이름을 입력해주세용"); return; } - if (!userInfo.major) { + if (!userInfo.department) { toast.error("단과대학을 입력해주세용"); return; } @@ -52,8 +52,8 @@ export default function HomePage() { }; useEffect(() => { - userInfo.setMajor(selectedMajor); - }, [selectedMajor, userInfo.setMajor]); + userInfo.setDepartment(selectedDepartment); + }, [selectedDepartment, userInfo.setDepartment]); return ( @@ -103,8 +103,8 @@ export default function HomePage() { color="primary" width="242px" height="30px" - selectedDepartment={selectedMajor} - setSelectedDepartment={setSelectedMajor} + selectedDepartment={selectedDepartment} + setSelectedDepartment={setSelectedDepartment} /> 개인정보는 외부에 공유되지 않으니 안심하세용 diff --git a/src/store/store.ts b/src/store/store.ts index 562f30d..2409a76 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -2,17 +2,17 @@ import { create } from "zustand"; type UserProps = { name: string; - major: string; + department: string; }; type UserAction = { setName: (name: UserProps["name"]) => void; - setMajor: (major: UserProps["major"]) => void; + setDepartment: (department: UserProps["department"]) => void; }; export const useUserInfo = create()((set) => ({ name: "", - major: "", + department: "", setName: (name) => set(() => ({ name: name })), - setMajor: (major) => set(() => ({ major: major })), + setDepartment: (department) => set(() => ({ department: department })), }));