Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hyuna committed Jun 25, 2024
2 parents a058bc2 + f33de90 commit b39d013
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 81 deletions.
2 changes: 1 addition & 1 deletion src/api/login/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ export const GetTeacherName = () => {
}
},
});
};
};
28 changes: 3 additions & 25 deletions src/app/afterManage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Dropdown from "@/components/dropdown";
import AfterList from "@/components/list/afterManage";
import AfterDelete from "@/components/list/delete";
import Modal from "@/components/modal";
import useAcceptListSelection from "@/hook/handleAcceptListClick";
import { getStudentString, setStudentNum } from "@/util/util";
import { useEffect, useState } from "react";

Expand All @@ -24,14 +25,13 @@ const AfterManage = () => {
const [selectClassTime, setSelectClassTime] = useState<number>(8);
const [selectClub, setSelectClub] = useState<string>("대동여지도");
const [studentData, setStudentData] = useState<AfterStudent[]>();
const [selectedStudents, setSelectedStudents] = useState<string[]>([]);
const [selectedStudentName, setSelectedStudentName] = useState<string[]>([]);
const { data: getClub } = GetClubList(selectClub);
const { mutate: Post } = PostStudent();
const { mutate: changeStatus } = FixStatus();
const { data: getStudent } = GetAfterStudent();
const { mutate: CulbCheck } = CheckStatus();

const { selectedStudents, selectedStudentName, handleAcceptListClick } =
useAcceptListSelection();
const handleSaveClub = async () => {
const updatedData: ChangeClub[] = [];
studentData?.forEach((item) => {
Expand Down Expand Up @@ -116,28 +116,6 @@ const AfterManage = () => {
setMadal(false);
};

const handleAcceptListClick = (id: string, name: string) => {
const selectedIndex = selectedStudents.indexOf(id);
const isSelected = selectedIndex !== -1;
if (isSelected) {
setSelectedStudents((prevSelectedStudents) =>
prevSelectedStudents.filter((studentId) => studentId !== id)
);
setSelectedStudentName((prevSelectedStudentName) =>
prevSelectedStudentName.filter((studentName) => studentName !== name)
);
} else {
setSelectedStudents((prevSelectedStudents) => [
...prevSelectedStudents,
id,
]);
setSelectedStudentName((prevSelectedStudentName) => [
...prevSelectedStudentName,
name,
]);
}
};

useEffect(() => {
setClubList([]);
if (getClub) {
Expand Down
27 changes: 3 additions & 24 deletions src/app/classChange/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import Modal from "@/components/modal";
import { AcceptClass, AcceptClassChange } from "@/api/classChange";
import { FloorClass } from "@/api/type";
import ChangeClass from "@/components/classChange";
import useAcceptListSelection from "@/hook/handleAcceptListClick";

const ClassChange = () => {
const [selectedFloor, setSelectedFloor] = useState<number>(2);
const [data, setData] = useState<FloorClass[]>([]);
const [accept, setAccept] = useState<boolean>(false);
const [refuse, setRefuse] = useState<boolean>(false);
const [selectedStudents, setSelectedStudents] = useState<string[]>([]);
const [selectedStudentName, setSelectedStudentName] = useState<string[]>([]);
const { selectedStudents, selectedStudentName, handleAcceptListClick } =
useAcceptListSelection();

const { data: AccpetMutate } = AcceptClassChange(selectedFloor);
const { mutate: AccpetList } = AcceptClass();
Expand Down Expand Up @@ -46,28 +47,6 @@ const ClassChange = () => {
}
}, [AccpetMutate]);

const handleAcceptListClick = (id: string, name: string) => {
const isStudentSelected = selectedStudents.includes(id);
if (isStudentSelected) {
setSelectedStudents((prevSelectedStudents) =>
prevSelectedStudents.filter((selectedStudent) => selectedStudent !== id)
);
setSelectedStudentName((prevSelectedStudentName) =>
prevSelectedStudentName.filter(
(selectedStudentName) => selectedStudentName !== name
)
);
} else {
setSelectedStudents((prevSelectedStudents) => [
...prevSelectedStudents,
id,
]);
setSelectedStudentName((prevSelectedStudentName) => [
...prevSelectedStudentName,
name,
]);
}
};
const nav = useRouter();

const handleFloorChange = (selectedOption: number) => {
Expand Down
28 changes: 3 additions & 25 deletions src/app/outAccept/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Button from "@/components/button";
import Dropdown from "@/components/dropdown";
import NonReturn from "@/components/list/application";
import Modal from "@/components/modal";
import useAccepListSelection from "@/hook/handleAcceptListClick";
import { getFullToday } from "@/util/date";
import { getStudentString } from "@/util/util";
import React, { useEffect, useState } from "react";
Expand All @@ -15,10 +16,10 @@ const OutAccept = () => {
const [applicationData, setApplicationData] = useState<applicationOK[]>();
const [selectGrade, setSelectGrade] = useState<number>(1);
const [selectClass, setSelectClass] = useState<number>(1);
const [selectedStudents, setSelectedStudents] = useState<string[]>([]);
const [acmodal, setAcModal] = useState<boolean>(false);
const [nomodal, setNomodal] = useState<boolean>(false);
const [selectedStudentName, setSelectedStudentName] = useState<string[]>([]);
const { selectedStudents, selectedStudentName, handleAcceptListClick } =
useAccepListSelection();
const { mutate: outAcceptMutate } = GetClass();
const { mutate: AcceptMutate } = OutAcceptApi();

Expand Down Expand Up @@ -96,29 +97,6 @@ const OutAccept = () => {
}
};

const handleAcceptListClick = (id: string, name: string) => {
const isStudentSelected = selectedStudents.includes(id);
if (isStudentSelected) {
setSelectedStudents((prevSelectedStudents) =>
prevSelectedStudents.filter((selectedStudent) => selectedStudent !== id)
);
setSelectedStudentName((prevSelectedStudentName) =>
prevSelectedStudentName.filter(
(selectedStudentName) => selectedStudentName !== name
)
);
} else {
setSelectedStudents((prevSelectedStudents) => [
...prevSelectedStudents,
id,
]);
setSelectedStudentName((prevSelectedStudentName) => [
...prevSelectedStudentName,
name,
]);
}
};

const Accept = () => {
if (selectedStudents.length === 0) {
alert("외출 수락 할 학생을 선택해주세요");
Expand Down
7 changes: 2 additions & 5 deletions src/components/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ const Button: React.FC<ButtonProp> = ({
}) => {
const getColorClass = () => {
switch (colorType) {
case "primary":
return " rounded-lg bg-primary-200 text-primary-1000 focus:bg-primary-500 focus:border focus:border-primary-800 active:bg-primary-800";

case "secondary":
return " rounded-lg bg-secondary-200 text-secondary-1000 focus:bg-secondary-500 focus:border focus:border-secondary-800 active:bg-secondary-800";
case "primary" || "secondary":
return ` rounded-lg bg-primary-200 text-primary-1000 focus:bg-primary-500 focus:border focus:border-primary-800 active:bg-${colorType}-800`;

case "tertiary":
return " rounded-lg bg-tertiary-500 text-primary-1200 focus:bg-tertiary-500 focus:border focus:border-tertiary-800 active:bg-tertiary-800";
Expand Down
2 changes: 1 addition & 1 deletion src/components/list/afterManage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const AfterList = ({
<div className=" whitespace-nowrap min-w-fit gap-2 items-center flex justify-between w-full rounded-lg">
<div className=" flex whitespace-nowrap gap-2 items-center justify-between">
<div className=" text-sub-title4-M">{name}</div>
{class_name === "" ? (
{class_name === "" || class_name === "null" ? (
""
) : (
<div className=" border border-primary-400 px-2 py-1 rounded-2xl bg-primary-400 text-body3 text-white">
Expand Down
39 changes: 39 additions & 0 deletions src/hook/handleAcceptListClick.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { useState } from "react";

interface AcceptListSelection {
selectedStudents: string[];
selectedStudentName: string[];
handleAcceptListClick: (id: string, name: string) => void;
}

const useAcceptListSelection = (): AcceptListSelection => {
const [selectedStudents, setSelectedStudents] = useState<string[]>([]);
const [selectedStudentName, setSelectedStudentName] = useState<string[]>([]);

const handleAcceptListClick = (id: string, name: string) => {
const isStudentSelected = selectedStudents.includes(id);
if (isStudentSelected) {
setSelectedStudents((prevSelectedStudents) =>
prevSelectedStudents.filter((selectedStudent) => selectedStudent !== id)
);
setSelectedStudentName((prevSelectedStudentName) =>
prevSelectedStudentName.filter(
(selectedStudentName) => selectedStudentName !== name
)
);
} else {
setSelectedStudents((prevSelectedStudents) => [
...prevSelectedStudents,
id,
]);
setSelectedStudentName((prevSelectedStudentName) => [
...prevSelectedStudentName,
name,
]);
}
};

return { selectedStudents, selectedStudentName, handleAcceptListClick };
};

export default useAcceptListSelection;

0 comments on commit b39d013

Please sign in to comment.