Skip to content

Commit

Permalink
chore : 드롭다운 수정
Browse files Browse the repository at this point in the history
chore : 드롭다운 수정
  • Loading branch information
phyuna0525 authored Jul 7, 2024
2 parents c5adc82 + edf1dbf commit 6253678
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
8 changes: 6 additions & 2 deletions src/app/outAccept/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,12 @@ const OutAccept = () => {
Dropdown={
<div className=" flex w-full justify-between min-w-fit items-center gap-1">
<div className=" flex gap-2">
<Dropdown type="all" onChange={handleGradeChange} />
<Dropdown type="class" onChange={handleClassChange} />
<Dropdown type="all" onChange={handleGradeChange} homeRoom={true} />
<Dropdown
type="class"
onChange={handleClassChange}
homeRoom={true}
/>
</div>
<div className=" flex gap-2 w-32">
<Button
Expand Down
21 changes: 12 additions & 9 deletions src/components/dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import downarrow from "@/assets/svg/downarrow.svg";

interface DropdownProp {
type: "grade" | "class" | "floor" | "classTime" | "club" | "all";
homeRoom?: boolean;
onChange: (selectedOption: any, type: string) => void;
}

const Dropdown: React.FC<DropdownProp> = ({ type, onChange }) => {
const Dropdown: React.FC<DropdownProp> = ({ type, onChange, homeRoom }) => {
const [selectedGradeOption, setSelectedGradeOption] = useState<number>(1);
const [selectedClassOption, setSelectedClassOption] = useState<number>(1);
const [selectedFloorOption, setSelectedFloorOption] = useState<number>(5);
Expand Down Expand Up @@ -81,15 +82,17 @@ 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 ? 5 : grade;
const setclass_num = class_num === 0 ? 1 : class_num;
if (type === "all") {
setSelectedAllOption(setgrade);
if (homeRoom) {
const grade = parseInt(localStorage.getItem("grade") || "1", 10);
const class_num = parseInt(localStorage.getItem("class_num") || "1", 10);
const setgrade = grade === 0 ? 5 : grade;
const setclass_num = class_num === 0 ? 1 : class_num;
if (type === "all") {
setSelectedAllOption(setgrade);
}
setSelectedGradeOption(setgrade);
setSelectedClassOption(setclass_num);
}
setSelectedGradeOption(setgrade);
setSelectedClassOption(setclass_num);
}, []);

const floorOptions = [
Expand Down

0 comments on commit 6253678

Please sign in to comment.