Skip to content

Commit

Permalink
refactor: major -> deparment로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
2NNS-V committed Sep 11, 2024
1 parent ebe8efa commit 2c6413c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/hooks/useSubmitResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useUserInfo } from "@/store/store";

export const useSubmitResult = () => {
const [isPending, setIsPending] = useState<boolean>(false);
const major = useUserInfo((state) => state.major);
const department = useUserInfo((state) => state.department);

const navigate = useNavigate();
const [searchParams] = useSearchParams();
Expand All @@ -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}`);
})
Expand Down
12 changes: 6 additions & 6 deletions src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function HomePage() {
const userInfo = useUserInfo((state) => state);

const [isOpen, setIsOpen] = useState<boolean>(false);
const [selectedMajor, setSelectedMajor] = useState<string>("");
const [selectedDepartment, setSelectedDepartment] = useState<string>("");

const handleSideBar = () => {
setIsOpen(!isOpen);
Expand All @@ -44,16 +44,16 @@ export default function HomePage() {
toast.error("이름을 입력해주세용");
return;
}
if (!userInfo.major) {
if (!userInfo.department) {
toast.error("단과대학을 입력해주세용");
return;
}
navigate("/select");
};

useEffect(() => {
userInfo.setMajor(selectedMajor);
}, [selectedMajor, userInfo.setMajor]);
userInfo.setDepartment(selectedDepartment);
}, [selectedDepartment, userInfo.setDepartment]);

return (
<HomePageWrapper>
Expand Down Expand Up @@ -103,8 +103,8 @@ export default function HomePage() {
color="primary"
width="242px"
height="30px"
selectedDepartment={selectedMajor}
setSelectedDepartment={setSelectedMajor}
selectedDepartment={selectedDepartment}
setSelectedDepartment={setSelectedDepartment}
/>
<Text size="xs" color="#6E6E6E">
개인정보는 외부에 공유되지 않으니 안심하세용
Expand Down
8 changes: 4 additions & 4 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserProps & UserAction>()((set) => ({
name: "",
major: "",
department: "",
setName: (name) => set(() => ({ name: name })),
setMajor: (major) => set(() => ({ major: major })),
setDepartment: (department) => set(() => ({ department: department })),
}));

0 comments on commit 2c6413c

Please sign in to comment.