Skip to content

Commit

Permalink
Merge branch 'develop' into chore/resultLoading
Browse files Browse the repository at this point in the history
  • Loading branch information
toothlessdev authored Sep 11, 2024
2 parents 6ca3ec9 + d67bce9 commit 4f8c2c6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 52 deletions.
36 changes: 0 additions & 36 deletions src/hooks/useAxios.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/hooks/useSubmitResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export const useSubmitResult = () => {
});
}, []);

return <></>;
return null;
};
2 changes: 1 addition & 1 deletion src/pages/AnalyticsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface top10Response {
top: [string, number][];
}

const renderData = (data: top10Response | null, isPending: boolean, isError: any) => {
const renderData = (data: top10Response | null, isPending: boolean, isError: boolean) => {
if (isPending) return <Text size="m">로딩중...</Text>;
if (isError) return <Text size="m">오류가 발생했습니다.</Text>;
if (!data) {
Expand Down
13 changes: 7 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>(userInfo.department);

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 @@ -98,13 +98,14 @@ export default function HomePage() {
height="45px"
placeholder="이름을 입력하세용"
onChange={(e) => userInfo.setName(e.currentTarget.value)}
defaultValue={userInfo.name}
/>
<DropDown
color="primary"
width="242px"
height="45px"
selectedDepartment={selectedMajor}
setSelectedDepartment={setSelectedMajor}
selectedDepartment={selectedDepartment}
setSelectedDepartment={setSelectedDepartment}
/>
<Text size="xs" color="#6E6E6E">
개인정보는 외부에 공유되지 않으니 안심하세용
Expand Down
26 changes: 18 additions & 8 deletions src/store/store.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
import { create } from "zustand";

import { persist } from "zustand/middleware";

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: "",
setName: (name) => set(() => ({ name: name })),
setMajor: (major) => set(() => ({ major: major })),
}));
export const useUserInfo = create<UserProps & UserAction>()(
persist(
(set) => ({
name: "",
department: "",
setName: (name) => set(() => ({ name: name })),
setDepartment: (department) => set(() => ({ department: department })),
}),
{
name: "user-storage",
getStorage: () => localStorage,
},
),
);

0 comments on commit 4f8c2c6

Please sign in to comment.