Skip to content

Commit

Permalink
add : 교실 이동 현황 보기
Browse files Browse the repository at this point in the history
add : 교실 이동 현황 보기
  • Loading branch information
phyuna0525 authored Apr 21, 2024
2 parents 38f56bd + 44d8494 commit 19a424f
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 12 deletions.
17 changes: 16 additions & 1 deletion src/api/classChange/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMutation, useQuery } from "@tanstack/react-query";
import { instance } from "..";
import { FloorClass } from "../type";
import { FloorClass, changeClass } from "../type";

export const AcceptClassChange = (floor: number) => {
return useQuery<FloorClass[]>({
Expand Down Expand Up @@ -28,3 +28,18 @@ export const AcceptClass = () => {
},
});
};

export const GetFloor = () => {
return useMutation<changeClass[], void, { floor: number }>({
mutationFn: async (param) => {
try {
const response = await instance.get(
`/class-room/floor?floor=${param.floor}&status=OK`
);
return response.data;
} catch (error) {
throw error;
}
},
});
};
11 changes: 11 additions & 0 deletions src/api/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,14 @@ export interface ChangeClub {
user_id: string;
status_list: string[];
}

export interface changeClass {
class_num: number;
classroom_name: string;
floor: number;
grade: number;
id: string;
num: number;
user_id: string;
username: string;
}
4 changes: 3 additions & 1 deletion src/app/afterManage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const AfterManage = () => {
};
});
Post(updatedData);
setMadal(false);
};

const handleAcceptListClick = (id: string, name: string) => {
Expand All @@ -131,6 +132,7 @@ const AfterManage = () => {
};

useEffect(() => {
setClubList([]);
if (getClub) {
setClubList(getClub);
}
Expand Down Expand Up @@ -250,7 +252,7 @@ const AfterManage = () => {
/>
)}
</div>
<div className="absolute bottom-4% w-5/6 left-50%">
<div className="absolute bottom-4% w-5/6">
{edit ? (
selectedTab ? (
<Button
Expand Down
24 changes: 14 additions & 10 deletions src/app/classChange/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const ClassChange = () => {
const { data: AccpetMutate } = AcceptClassChange(selectedFloor);
const { mutate: AccpetList } = AcceptClass();

const router = useRouter();

const Accept = async () => {
setAccept(true);
};
Expand Down Expand Up @@ -108,20 +110,11 @@ const ClassChange = () => {
<BackGround
TabOnclick={() => {}}
TabOK={false}
title="교실이동수락"
title="교실 이동 수락"
subTitle={getFullToday()}
Dropdown={
<div className=" flex justify-between items-center">
<div className="flex gap-5 items-center">
{/* <Button
colorType="ghost"
buttonSize="small"
onClick={() => {
nav.push("/classChange/ok");
}}
>
교실 이동 보기
</Button> */}
<Dropdown type="floor" onChange={handleFloorChange} />
</div>
<div className=" flex gap-2 w-32">
Expand Down Expand Up @@ -186,6 +179,17 @@ const ClassChange = () => {
onConfirm={Acceptconfirm}
/>
)}
<div className=" absolute bottom-4% w-5/6">
<Button
onClick={() => {
router.push("/classChange/status");
}}
colorType="primary"
buttonSize="full"
>
전체 이동자 보기
</Button>
</div>
</BackGround>
);
};
Expand Down
65 changes: 65 additions & 0 deletions src/app/classChange/status/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"use client";
import React, { useEffect } from "react";
import { getFullToday } from "@/util/date";
import { useState } from "react";
import Dropdown from "@/components/dropdown";
import { GetFloor } from "@/api/classChange";
import { getStudentString } from "@/util/util";
import BackGround from "@/components/background";
import ChangeClass from "@/components/classChange";
import { changeClass } from "@/api/type";

const ClassChangeOk = () => {
const [floorData, setFloorData] = useState<changeClass[]>([]);
const { mutate: changelistFloorMutate } = GetFloor();
const [selectedFloor, setSelectedFloor] = useState<number>(2);

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

useEffect(() => {
ChangeClassDataFloor();
}, [selectedFloor]);

const ChangeClassDataFloor = async () => {
try {
if (selectedFloor) {
await changelistFloorMutate(
{ floor: selectedFloor },
{
onSuccess: (data) => {
setFloorData(data);
},
onError: (error) => {
console.log(error);
},
}
);
}
} catch (error) {
console.log(error);
}
};

return (
<BackGround
title="교실이동"
subTitle={getFullToday()}
Dropdown={<Dropdown type="floor" onChange={handleFloorChange} />}
TabOK={false}
TabOnclick={() => {}}
>
{floorData?.map((item, index) => (
<ChangeClass
key={index}
prevClass={`${item.grade}-${item.class_num}`}
nextClass={item.classroom_name}
student={getStudentString(item)}
/>
))}
</BackGround>
);
};

export default ClassChangeOk;

0 comments on commit 19a424f

Please sign in to comment.