Skip to content

Commit

Permalink
fix : 드롭다운 기본값
Browse files Browse the repository at this point in the history
fix : 드롭다운 기본값
  • Loading branch information
phyuna0525 authored Apr 23, 2024
2 parents 183eade + 7228ee6 commit ae63702
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/api/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export const GetName = () => {
queryFn: async () => {
const result = await instance.get("/admin/my-name");
localStorage.setItem("name", result.data.name);
localStorage.setItem("grade", JSON.stringify(result.data.grade));
localStorage.setItem("class_num", JSON.stringify(result.data.class_num));
return result.data.name;
},
});
Expand Down
6 changes: 5 additions & 1 deletion src/app/afterManage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,14 @@ const AfterManage = () => {
출결 저장하기
</Button>
)
) : (
) : selectedTab ? (
<Button colorType="ghost" buttonSize="full" onClick={onClickSave}>
출결 체크하기
</Button>
) : (
<Button colorType="ghost" buttonSize="full" onClick={handleSaveClub}>
출결 저장하기
</Button>
)}
</div>
</BackGround>
Expand Down
6 changes: 3 additions & 3 deletions src/app/main/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use client";
import Header from "@/components/header";
import Button from "./button";
import Button from "../../components/main/button";
import { useEffect, useState } from "react";
import CheckPage from "./checkPage";
import CheckPage from "../../components/main/checkPage";
import { GetName, GetTodaydirector } from "@/api/main";
import { getToday, getWeekDay } from "@/util/date";
import AfterManageImg from "@/assets/svg/aferManege.svg";
Expand All @@ -25,7 +25,7 @@ const Main = () => {
<div className="bg-primary-1200 flex flex-col gap-9 items-center px-6 h-dvh pt-7">
<div className="flex w-full justify-between">
<Button src="/outAccept" name="외출 수락" img={outingImg} />
<Button src="/afterManage" name="방과후 관리" img={AfterManageImg} />
<Button src="/afterManage" name="방과후 출결" img={AfterManageImg} />
<Button src="/attendanceCheck" name="출석 체크" img={attendanceImg} />
<Button src="/classChange" name="교실 이동" img={moveClassImg} />
</div>
Expand Down
9 changes: 9 additions & 0 deletions src/app/outAccept/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ const OutAccept = () => {
AcceptDataList();
}, [selectGrade, selectClass]);

useEffect(() => {
const grade = parseInt(localStorage.getItem("grade") || "1", 10);
const class_num = parseInt(localStorage.getItem("class_num") || "1", 10);
const setgrade = grade === 0 ? 1 : grade;
const setclass_num = class_num === 0 ? 1 : class_num;
setSelectGrade(setgrade);
setSelectClass(setclass_num);
}, []);

const handleGradeChange = (selectedOption: number) => {
if (selectedOption === 5) {
setSelectGrade(5);
Expand Down
12 changes: 12 additions & 0 deletions src/components/dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ const Dropdown: React.FC<DropdownProp> = ({ type, onChange }) => {
));
};

useEffect(() => {
const grade = parseInt(localStorage.getItem("grade") || "1", 10);
const class_num = parseInt(localStorage.getItem("class_num") || "1", 10);
const setgrade = grade === 0 ? 1 : grade;
const setclass_num = class_num === 0 ? 1 : class_num;
if (type === "all") {
setSelectedAllOption(setgrade);
}
setSelectedGradeOption(setgrade);
setSelectedClassOption(setclass_num);
}, []);

const floorOptions = [
{ value: 2, label: "2층" },
{ value: 3, label: "3층" },
Expand Down
2 changes: 1 addition & 1 deletion src/app/main/button.tsx → src/components/main/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Image from "next/image";
import Link from "next/link";

interface buttonProps {
name: "외출 수락" | "방과후 관리" | "출석 체크" | "교실 이동";
name: "외출 수락" | "방과후 출결" | "출석 체크" | "교실 이동";
img: string;
src: string;
}
Expand Down
File renamed without changes.

0 comments on commit ae63702

Please sign in to comment.