Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/adminpage/main/_components/AdminMainScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
BarChart3,
LogOut,
Shield,
Bell,
} from "lucide-react";

const MENU_ITEMS = [
Expand All @@ -32,6 +33,15 @@ const MENU_ITEMS = [
active: true,
gradient: "from-[#6366f1] to-[#8b5cf6]",
},
{
id: "notices",
title: "공지사항 관리",
description: "서비스 공지사항을 등록, 수정, 삭제합니다",
icon: Bell,
href: "/adminpage/notices",
active: true,
gradient: "from-[#10b981] to-[#059669]",
},
{
id: "users",
title: "사용자 관리",
Expand Down
63 changes: 63 additions & 0 deletions app/adminpage/notices/_actions/noticeActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"use server";

import { serverApi, isAxiosError } from "@/lib/server-api";
import {
type CreateNoticeBody,
type UpdateNoticeBody,
} from "@/hooks/admin/useAdminNotices";

/**
* 공지사항 등록 Server Action
*/
export async function createNoticeAction(body: CreateNoticeBody) {
try {
const response = await serverApi.post({
path: "/api/v1/admin/notices",
body,
});
return response.data;
} catch (error) {
if (isAxiosError(error)) {
throw error;
}
throw new Error("공지사항 등록 중 알 수 없는 에러가 발생했습니다.");
}
}

/**
* 공지사항 수정 Server Action
*/
export async function updateNoticeAction(
noticeId: number,
body: UpdateNoticeBody,
) {
try {
const response = await serverApi.patch({
path: `/api/v1/admin/notices/${noticeId}`,
body,
});
return response.data;
} catch (error) {
if (isAxiosError(error)) {
throw error;
}
throw new Error("공지사항 수정 중 알 수 없는 에러가 발생했습니다.");
}
}

/**
* 공지사항 삭제 Server Action
*/
export async function deleteNoticeAction(noticeId: number) {
try {
const response = await serverApi.delete({
path: `/api/v1/admin/notices/${noticeId}`,
});
return response.data;
} catch (error) {
if (isAxiosError(error)) {
throw error;
}
throw new Error("공지사항 삭제 중 알 수 없는 에러가 발생했습니다.");
}
}
Loading
Loading