Skip to content

Commit

Permalink
chore : 공지 학년 삭제
Browse files Browse the repository at this point in the history
chore : 공지 학년 삭제
  • Loading branch information
phyuna0525 authored Aug 1, 2024
2 parents 635ce8e + 000996a commit 895f18c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 63 deletions.
4 changes: 0 additions & 4 deletions src/apis/notice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,24 @@ interface Getnotice {
title: string;
create_at: string;
teacher: string;
grade: number[];
}

interface DetailNoticeType {
title: string;
content: string;
create_at: string;
teacher: string;
grade: number[];
}

interface post {
title: string;
content: string;
grade: number[];
}

interface ModifyProp {
id: string;
title: string;
content: string;
grade: number[];
}

export const GetNoticeList = () => {
Expand Down
12 changes: 2 additions & 10 deletions src/app/components/common/list/notice/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,10 @@ interface NoticeProp {
title: string;
teacher: string;
createAt: string;
grade: string;
id: string;
}

const NoticeList: React.FC<NoticeProp> = ({
title,
teacher,
createAt,
grade,
id,
}) => {
const NoticeList: React.FC<NoticeProp> = ({ title, teacher, createAt, id }) => {
const router = useRouter();

const MoveDetail = () => {
Expand All @@ -31,8 +24,7 @@ const NoticeList: React.FC<NoticeProp> = ({
<div className=" max-w-96 overflow-hidden whitespace-nowrap text-overflow-ellipsis">
{title}
</div>
<div className=" flex justify-between w-76">
<div>{grade}</div>
<div className=" flex gap-7">
<div>{teacher}</div>
<div>{createAt}</div>
</div>
Expand Down
11 changes: 1 addition & 10 deletions src/app/notice/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ interface DetailNoticeType {
content: string;
create_at: string;
teacher: string;
grade: number[];
}

const DetailNotice: NextPage = () => {
Expand All @@ -40,7 +39,7 @@ const DetailNotice: NextPage = () => {

const deleteNotice = async () => {
try {
const result = await delelteMutate(
await delelteMutate(
{ id: id },
{
onSuccess: () => {
Expand Down Expand Up @@ -87,14 +86,6 @@ const DetailNotice: NextPage = () => {
작성자
<div className=" text-neutral-400">{data?.teacher} 선생님</div>
</div>
<div className=" flex text-Button-L gap-2">
학년
<div className=" text-neutral-400">
{data?.grade.map((grade, index) => (
<span key={index}>{`${Grade([grade])}학년 `}</span>
))}
</div>
</div>
</div>
<div className=" flex flex-col gap-7">
<div className=" text-heading5 text-neutral-100">
Expand Down
35 changes: 5 additions & 30 deletions src/app/notice/modify/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ interface DetailNoticeType {
content: string;
create_at: string;
teacher: string;
grade: number[];
}

const ModifyNotice = () => {
const router = useRouter();
const [title, setTitle] = useState("");
const [content, setContent] = useState("");
const [selectedGrade, setSelectedGrade] = useState<number>(1);
const { mutate: DetailDataMutate } = DetailNoticeData();
const [data, setData] = useState<DetailNoticeType>();
const { mutate: modifyMutate } = ModifyNoticeData();

Expand All @@ -36,32 +34,14 @@ const ModifyNotice = () => {
const idParam = param.get("id");

const id = idParam ? idParam : "";
const { data: DetailDataMutate } = DetailNoticeData(id);

useEffect(() => {
getData();
setData(data);
setTitle(DetailDataMutate?.title || "");
setContent(DetailDataMutate?.content || "");
}, []);

const getData = async () => {
try {
const result = await DetailDataMutate(
{ id: id },
{
onSuccess: (data) => {
setData(data);
setTitle(data.title);
setContent(data.content);
setSelectedGrade(data.grade[0]);
},
onError: (error) => {
console.log(`${error.message} : 에러가 발생했습니다`);
},
}
);
} catch (error) {
console.log(error);
}
};

const handleTitleChange = ({ text, name }: ChangeProps) => {
setTitle(text);
};
Expand All @@ -76,11 +56,10 @@ const ModifyNotice = () => {

const handleSubmit = async () => {
try {
const result = await modifyMutate({
await modifyMutate({
id: id,
title: title,
content: content,
grade: [selectedGrade],
});
alert("공지가 수정되었습니다");
router.back();
Expand Down Expand Up @@ -116,10 +95,6 @@ const ModifyNotice = () => {
name="title"
/>
</div>
<div>
학년
<SelectGrade onSelect={handleGradeSelect} />
</div>
</div>
</div>
</div>
Expand Down
3 changes: 0 additions & 3 deletions src/app/notice/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ interface GetnoticeList {
title: string;
create_at: string;
teacher: string;
grade: number[];
}

const Notice = () => {
Expand Down Expand Up @@ -46,7 +45,6 @@ const Notice = () => {
<div className=" flex text-sub-title2-M px-14 justify-between">
<div className=" text-sub-title2-M">제목</div>
<div className=" flex gap-20">
<div>학년</div>
<div>작성자</div>
<div>작성일</div>
</div>
Expand All @@ -59,7 +57,6 @@ const Notice = () => {
id={item.id}
createAt={item.create_at}
teacher={`${item.teacher} 선생님`}
grade={`${Grade(item.grade)}학년`}
/>
))}
</div>
Expand Down
7 changes: 1 addition & 6 deletions src/app/notice/write/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const WriteNotice = () => {
const { mutate: uploadNotice } = PostNotice();
const [title, setTitle] = useState("");
const [content, setContent] = useState("");
const [selectedGrade, setSelectedGrade] = useState<number>(1);

const ColorType = () => {
if (title === "" || content === "") {
Expand All @@ -31,7 +30,7 @@ const WriteNotice = () => {
if (ColorType() === "primary") {
try {
await uploadNotice(
{ title, content, grade: [selectedGrade] },
{ title, content },
{
onSuccess: () => {
nav.push("/notice");
Expand Down Expand Up @@ -83,10 +82,6 @@ const WriteNotice = () => {
name="title"
/>
</div>
<div>
학년
<SelectGrade onSelect={setSelectedGrade} />
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 895f18c

Please sign in to comment.