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);
}

View File

@@ -1,33 +1,46 @@
export interface IListDataAnnouncement {
id: string,
title: string,
desc: string,
createdAt: string
id: string,
title: string,
desc: string,
createdAt: string
}
export interface IRootAllAnnouncement {
announcement: IAnnouncement
allAnnouncementMember: IAllAnnouncementMember[]
}
export interface IAnnouncement {
id: string
title: string
desc: string
}
export interface IAllAnnouncementMember {
idAnnouncement: string
idGroup: string
idDivision: string
group: string
}
announcement: IAnnouncement
allAnnouncementMember: IAllAnnouncementMember[]
}
export interface GroupData {
export interface IAnnouncement {
id: string
title: string
desc: string
}
export interface IAllAnnouncementMember {
idAnnouncement: string
idGroup: string
idDivision: string
group: string
}
export interface GroupData {
id: string;
name: string;
Division: {
id: string;
name: string;
id: string;
name: string;
}[];
}
}
export interface ICreateData {
title: string
desc: string
}
export interface IGroupData {
idAnnouncement: string
idGroup: string
idDivision: string
isActive: boolean
}