Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hyuna committed Jul 9, 2024
2 parents be5ff77 + d1a9741 commit 95f7702
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pick",
"version": "0.1.0",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
20 changes: 20 additions & 0 deletions src/api/outList/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,23 @@ export const OutAcceptApi = () => {
},
});
};

export const OutFloorList = () => {
const { handleError } = apiError();
return useMutation<
applicationOK[],
Error,
{ floor: number; status: "OK" | "NO" | "QUIET" }
>({
mutationFn: async (param) => {
try {
const { data } = await instance.get(
`/application/floor?floor=${param.floor}&status=${param.status}`
);
return data;
} catch (error) {
handleError(error);
}
},
});
};
63 changes: 46 additions & 17 deletions src/app/outList/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
"use client";
import { Application, EarlyReturn, ReturnSchool } from "@/api/outList";
import {
Application,
EarlyReturn,
OutFloorList,
ReturnSchool,
} from "@/api/outList";
import { applicationOK } from "@/api/type";
import BackGround from "@/components/background";
import Button from "@/components/button";
import Dropdown from "@/components/dropdown";
import NonReturn from "@/components/list/application";
import Modal from "@/components/modal";
import useAcceptListSelection from "@/hook/handleAcceptListClick";
Expand All @@ -14,15 +21,32 @@ const OutList = () => {
const { selectedStudents, selectedStudentName, handleAcceptListClick } =
useAcceptListSelection();
const [modal, setModal] = useState<boolean>(false);
const [selectedFloor, setSelectedFloor] = useState<number>(5);
const [data, setData] = useState<applicationOK[]>([]);

const { data: applicationOKData } = Application();
const { mutate: floorData } = OutFloorList();
const { data: earlyReturnData } = EarlyReturn();
const { mutate: ReturnApplication } = ReturnSchool();

const GetFloorData = async () => {
await floorData(
{ floor: selectedFloor, status: "OK" },
{
onSuccess: (data) => {
setData(data);
},
}
);
};

const onClickTab = (tab: boolean) => {
setSelectedTab(tab);
};

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

const Return = () => {
ReturnApplication(selectedStudents, {
onSuccess: () => {
Expand All @@ -35,6 +59,10 @@ const OutList = () => {
});
};

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

return (
<BackGround
title="외출자 목록"
Expand All @@ -46,7 +74,9 @@ const OutList = () => {
Dropdown={
selectedTab && (
<div className=" flex justify-between items-center">
<div></div>
<div>
<Dropdown onChange={handleFloorChange} type="floor" />
</div>
<div className=" flex gap-2 w-32">
<Button
colorType="primary"
Expand All @@ -65,20 +95,19 @@ const OutList = () => {
<div className=" overflow-y-scroll gap-4 flex flex-col">
{selectedTab ? (
<>
{Array.isArray(applicationOKData) &&
applicationOKData?.map((item, index) => (
<NonReturn
onClick={() => {
handleAcceptListClick(item.id, item.username);
}}
id={item.id}
type="application"
key={index}
returnTime={item.end_time}
name={getStudentString(item)}
reason={item.reason}
/>
))}
{data?.map((item, index) => (
<NonReturn
onClick={() => {
handleAcceptListClick(item.id, item.username);
}}
id={item.id}
type="application"
key={index}
returnTime={item.end_time}
name={getStudentString(item)}
reason={item.reason}
/>
))}
</>
) : (
earlyReturnData?.map((item, index) => (
Expand Down

0 comments on commit 95f7702

Please sign in to comment.