feat : update announcement

This commit is contained in:
lukman
2024-08-13 13:35:59 +08:00
parent 334f94cb39
commit 7ffc642feb
6 changed files with 167 additions and 70 deletions

View File

@@ -1,3 +1,5 @@
import { ICreateData } from "./type_announcement";
export const funGetAllAnnouncement = async (path?: string) => {
const response = await fetch(`/api/announcement${(path) ? path : ''}`, { next: { tags: ['announcement'] } });
return await response.json().catch(() => null);
@@ -6,4 +8,15 @@ export const funGetAllAnnouncement = async (path?: string) => {
export const funGetAnnouncementById = async (path: string) => {
const response = await fetch(`/api/announcement/${path}`);
return await response.json().catch(() => null);
}
export const funCreateAnnouncement = async (data: ICreateData) => {
const response = await fetch("/api/announcement", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
});
return await response.json().catch(() => null);
}