Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hyuna committed Sep 25, 2024
2 parents a4343c3 + 897778f commit 4e3a452
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/api/classChange/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const AcceptClass = () => {
try {
await instance.patch(`/class-room/status`, {
status: param.status,
ids: param.id,
id_list: param.id,
});
} catch (error) {
handleError(error);
Expand Down
2 changes: 1 addition & 1 deletion src/api/outList/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const OutAcceptApi = () => {
const response = await instance.patch(`${param.type}/status`, {
type: param.type,
status: param.status,
ids: param.ids,
id_list: param.id_list,
});
return response.data;
} catch (error) {
Expand Down
16 changes: 8 additions & 8 deletions src/api/type.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface applicationOK {
user_id: string;
username: string;
user_name: string;
start: string;
id: string;
end: string;
Expand All @@ -13,7 +13,7 @@ export interface applicationOK {

export interface earlyReturnHome {
id: string;
username: string;
user_name: string;
start_time: string;
grade: number;
class_num: number;
Expand All @@ -24,7 +24,7 @@ export interface earlyReturnHome {
export interface Accept {
type: string;
status: "OK" | "NO";
ids: string[];
id_list: string[];
}

export interface ClassProp {
Expand All @@ -35,7 +35,7 @@ export interface ClassProp {

export interface ClubList {
id: string;
username: string;
user_name: string;
grade: number;
class_num: number;
num: number;
Expand Down Expand Up @@ -63,7 +63,7 @@ export interface FloorClass {
move: string;
num: number;
start_period: number;
username: string;
user_name: string;
}

export interface CountOutListType {
Expand All @@ -76,14 +76,14 @@ export interface Type {
grade: number;
class_num: number;
num: number;
name: string;
user_name: string;
}
export interface AfterStudent {
id: string;
grade: number;
class_num: number;
num: number;
name: string;
user_name: string;
classroom_name: string;
status: string;
}
Expand All @@ -102,5 +102,5 @@ export interface changeClass {
num: number;
move: string;
user_id: string;
username: string;
user_name: string;
}
4 changes: 2 additions & 2 deletions src/app/afterManage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const AfterManage = () => {
key={index}
id={item.id}
state={item.status}
name={`${setStudentNum(item)} ${item.name}`}
name={`${setStudentNum(item)} ${item.user_name}`}
class_name={item.classroom_name}
/>
);
Expand All @@ -150,7 +150,7 @@ const AfterManage = () => {
) : (
<>
{getStudent?.map((item, index) => (
<AfterDelete student={item.name} key={index} id={item.id} />
<AfterDelete student={item.user_name} key={index} id={item.id} />
))}
</>
)}
Expand Down
17 changes: 3 additions & 14 deletions src/app/classChange/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@
import { getFullToday } from "@/util/date";
import BackGround from "@/components/background";
import Dropdown from "@/components/dropdown";
import { useEffect, useState } from "react";
import { useState } from "react";
import Button from "@/components/button";
import { useRouter } from "next/navigation";
import { getStudentString } from "@/util/util";
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>(5);
const [data, setData] = useState<FloorClass[]>([]);
const [accept, setAccept] = useState<boolean>(false);
const [refuse, setRefuse] = useState<boolean>(false);
const { selectedStudents, selectedStudentName, handleAcceptListClick } =
Expand All @@ -41,16 +39,7 @@ const ClassChange = () => {
}
};

useEffect(() => {
if (AccpetMutate) {
setData(AccpetMutate);
}
}, [AccpetMutate]);

const nav = useRouter();

const handleFloorChange = (selectedOption: number) => {
setData([]);
setSelectedFloor(selectedOption);
};

Expand Down Expand Up @@ -139,11 +128,11 @@ const ClassChange = () => {
}
>
<div className=" flex flex-col h-60dvh overflow-y-scroll gap-4">
{data?.map((item, index) => (
{AccpetMutate?.map((item, index) => (
<ChangeClass
type="accept"
key={index}
onClick={() => handleAcceptListClick(item.user_id, item.username)}
onClick={() => handleAcceptListClick(item.id, item.user_name)}
prevClass={item.move}
nextClass={`${item.classroom_name}`}
student={getStudentString(item)}
Expand Down
8 changes: 4 additions & 4 deletions src/app/outAccept/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const OutAccept = () => {
{
type: reqOption,
status: "NO",
ids: selectedStudents,
id_list: selectedStudents,
},
{
onSuccess: () => {
Expand Down Expand Up @@ -155,7 +155,7 @@ const OutAccept = () => {
{
type: reqOption,
status: "OK",
ids: selectedStudents,
id_list: selectedStudents,
},
{
onSuccess: () => {
Expand Down Expand Up @@ -221,7 +221,7 @@ const OutAccept = () => {
key={index}
returnTime={`${item.start}~${item.end}`}
name={getStudentString(item)}
onClick={() => handleAcceptListClick(item.id, item.username)}
onClick={() => handleAcceptListClick(item.id, item.user_name)}
reason={item.reason}
/>
))
Expand All @@ -232,7 +232,7 @@ const OutAccept = () => {
key={index}
returnTime={`${item.start}~ `}
name={getStudentString(item)}
onClick={() => handleAcceptListClick(item.id, item.username)}
onClick={() => handleAcceptListClick(item.id, item.user_name)}
reason={item.reason}
/>
))}
Expand Down
2 changes: 1 addition & 1 deletion src/app/outList/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const OutList = () => {
{data?.map((item, index) => (
<NonReturn
onClick={() => {
handleAcceptListClick(item.id, item.username);
handleAcceptListClick(item.id, item.user_name);
}}
id={item.id}
type="application"
Expand Down
4 changes: 3 additions & 1 deletion src/components/input/auto.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ const AutoInput: React.FC<AutoInputProps> = ({
}, [GetStudentMutate]);

useEffect(() => {
const students = data?.map((item) => `${setStudentNum(item)} ${item.name}`);
const students = data?.map(
(item) => `${setStudentNum(item)} ${item.user_name}`
);
setStudent(students);
}, [data]);

Expand Down
12 changes: 6 additions & 6 deletions src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface Student {
grade: number;
class_num: number;
num: number;
username: string;
user_name: string;
}

interface studentNum {
Expand All @@ -23,10 +23,10 @@ export const getStudentString = ({
grade,
class_num,
num,
username,
user_name,
}: Student) => {
const change = num.toString().length === 1 ? `0${num}` : `${num}`;
return `${grade}${class_num}${change} ${username}`;
return `${grade}${class_num}${change} ${user_name}`;
};

export const setStudentNum = ({ grade, class_num, num }: studentNum) => {
Expand All @@ -53,6 +53,6 @@ export const ChangeOut = (type: "APPLICATION" | "EARLY_RETURN") => {
};

enum a {
APPLICATION="외출",
EARLY_RETURN="조기귀가"
}
APPLICATION = "외출",
EARLY_RETURN = "조기귀가",
}

0 comments on commit 4e3a452

Please sign in to comment.