Skip to content

Commit

Permalink
chore : 전공동아리 정보 추가 및 자습감독 수정
Browse files Browse the repository at this point in the history
chore : 전공동아리 정보 추가 및 자습감독 수정
  • Loading branch information
phyuna0525 authored Jun 26, 2024
2 parents dad451d + dfaa3e6 commit d24096a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 113 deletions.
13 changes: 0 additions & 13 deletions src/apis/changeTeacher/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,3 @@ export const SelectTeacher = (date: string) => {
},
});
};

export const ChangeTeachers = () => {
const { handleError } = apiError();
return useMutation<void, Error, postTeacherProp>({
mutationFn: async (param) => {
try {
await instance.patch(`self-study/modify`, param);
} catch (error) {
handleError(error);
}
},
});
};
10 changes: 5 additions & 5 deletions src/app/components/common/dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ const Dropdown: React.FC<DropProps> = ({ type, onChange }) => {
];

const clubOptions = [
{ value: "자습", label: "3-1교실(자습)" },
{ value: "자습3", label: "3-1교실(자습)" },
{ value: "대동여지도", label: "세미나실 2-1(대동여지도)" },
{ value: "DMS", label: "세미나실 2-2(DMS)" },
{ value: "gram", label: "세미나실 2-3(gram)" },
{ value: "Liear", label: "세미나실 2-4(Liear)" },
{ value: "gram1", label: "3-2교실(gram)" },
{ value: "gram-2", label: "3-2교실(gram)" },
{ value: "EXIT", label: "소개1실(EXIT)" },
{ value: "Lift", label: "소개2실(Lift)" },
{ value: "DMS3학년", label: "소개 3실(DMS 3학년)" },
{ value: "자습", label: "2-1교실(자습)" },
{ value: "DMS-2", label: "소개3실(DMS 3학년)" },
{ value: "자습2", label: "2-1교실(자습)" },
{ value: "Log", label: "세미나실 3-1(Log)" },
{ value: "은하", label: "세미나실 3-2(은하)" },
{ value: "PiCK", label: "세미나실 3-3(PiCK)" },
Expand All @@ -123,7 +123,7 @@ const Dropdown: React.FC<DropProps> = ({ type, onChange }) => {
{ value: "TeamQSS", label: "세미나실 4-1(TeamQSS)" },
{ value: "NoNamed", label: "세미나실 4-2(NoNamed)" },
{ value: "Modeep", label: "세미나실 4-3(Modeep)" },
{ value: "자습", label: "1-1교실(자습)" },
{ value: "자습1", label: "1-1교실(자습)" },
];

const options =
Expand Down
58 changes: 1 addition & 57 deletions src/app/components/common/list/out/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
"use client";

import React, { useState } from "react";
import { useRouter } from "next/navigation";
import Button from "../../Button";
import Modal from "../../modal/page";
import { ReturnSchool } from "@/apis/outList/list";

interface OutProps {
student: string;
Expand All @@ -13,67 +9,15 @@ interface OutProps {
}

const Out: React.FC<OutProps> = ({ student, returnTime, id }) => {
const router = useRouter();
const { mutate: returnSchoolMutate } = ReturnSchool();

const returnStudent = () => {
setModal(true);
};

const confirmReturn = async () => {
try {
const result = await returnSchoolMutate(
{ id: id },
{
onSuccess: () => {
location.reload();
alert("복귀에 성공하셨습니다");
},
onError: () => {
console.log("에러발생");
},
}
);
} catch (error) {
console.error(error);
}
setModal(false);
};

const closeModal = () => {
setModal(false);
};

const [modal, setModal] = useState<boolean>(false);

return (
<>
<div className="rounded-lg flex justify-between items-center bg-white py-6 px-4 w-120">
<div className="rounded-lg flex justify-between items-center bg-white py-5 px-4 w-120 border hover:border-primary-400">
<div className="flex items-center gap-3">
<div className=" text-Button-L">{student}</div>
<div className=" text-caption1 text-neutral-400">
{returnTime} 복귀예정
</div>
</div>
<div className="flex gap-2 w-20">
<Button
colorType="primary"
buttonSize="extraSmall"
onClick={returnStudent}
>
복귀
</Button>
</div>
{modal && (
<Modal
heading1={`${student} 학생의`}
heading2="외출을 끝내시겠습니까?"
type="button"
buttonMessage="확인"
onCancel={closeModal}
onConfirm={confirmReturn}
/>
)}
</div>
</>
);
Expand Down
40 changes: 2 additions & 38 deletions src/app/components/common/modal/selfStudyTeacher.tsx/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
import React, { useEffect, useState } from "react";
import moment from "moment";
import Button from "../../Button";
import {
ChangeTeachers,
PostTeacher,
SelectTeacher,
} from "@/apis/changeTeacher";
import { PostTeacher, SelectTeacher } from "@/apis/changeTeacher";
import AutoInput from "../../input/auto/page";

export interface ChangeProps {
Expand Down Expand Up @@ -44,40 +40,9 @@ const SelfStudyModal: React.FC<ModalProps> = ({
const [teachers, setTeachers] = useState<string[]>([]);

const { mutate: postTeacherMutate } = PostTeacher();
const { mutate: ChangeMutate } = ChangeTeachers();
const date = moment(initialDate).format("YYYY-MM-DD");
const { data: SelectSelfList } = SelectTeacher(date);

const Change = async () => {
try {
const ChangeData: postTeacherProp = {
date: moment(initialDate).format("YYYY-MM-DD"),
teacher: [
{
floor: secondData.floor,
teacher: secondData.teacher || teachers[0] || "",
},
{
floor: thirdData.floor,
teacher: thirdData.teacher || teachers[1] || "",
},
{
floor: fourthData.floor,
teacher: fourthData.teacher || teachers[2] || "",
},
],
};
await ChangeMutate(ChangeData, {
onSuccess: () => {
location.reload();
alert("자습감독이 수정되었습니다");
},
});
} catch (error) {
console.error(error);
}
};

useEffect(() => {
if (SelectSelfList) {
setData(SelectSelfList);
Expand All @@ -101,7 +66,7 @@ const SelfStudyModal: React.FC<ModalProps> = ({
}, [data]);

const Post = () => {
teachers.length === 0 ? submitTeachers() : Change();
submitTeachers();
};

const submitTeachers = async () => {
Expand All @@ -118,7 +83,6 @@ const SelfStudyModal: React.FC<ModalProps> = ({
await postTeacherMutate(postData, {
onSuccess: () => {
location.reload();
alert("자습감독이 등록되었습니다");
},
});
} catch (error) {
Expand Down

0 comments on commit d24096a

Please sign in to comment.