fitur: divisi
Deskripsi: - pengaplikasian api terbaru pada divisi - list divisi - create divisi - detail divisi No Issues
This commit is contained in:
27
src/module/division_new/lib/api_division.ts
Normal file
27
src/module/division_new/lib/api_division.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { IFormFixDivision } from "./type_division";
|
||||
|
||||
export const funGetAllDivision = async (path?: string) => {
|
||||
const response = await fetch(`/api/division${(path) ? path : ''}`, { next: { tags: ['division'] } });
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
export const funGetDivisionById = async (path: string) => {
|
||||
const response = await fetch(`/api/division/${path}`);
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
export const funGetDetailDivisionById = async (path: string, kategori: string) => {
|
||||
const response = await fetch(`/api/division/${path}/detail?cat=${kategori}`);
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
export const funCreateDivision = async (data: IFormFixDivision) => {
|
||||
const response = await fetch("/api/division", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
50
src/module/division_new/lib/type_division.ts
Normal file
50
src/module/division_new/lib/type_division.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
export interface IFormDivision {
|
||||
name: string
|
||||
idGroup: string
|
||||
desc: string
|
||||
}
|
||||
|
||||
export interface IFormMemberDivision {
|
||||
idUser: string,
|
||||
name: string
|
||||
}
|
||||
|
||||
export interface IFormFixDivision {
|
||||
data: IFormDivision,
|
||||
member: IFormMemberDivision[],
|
||||
admin: string[]
|
||||
}
|
||||
|
||||
export interface IDataDivison {
|
||||
id: string,
|
||||
name: string,
|
||||
desc: string,
|
||||
jumlah_member: number
|
||||
}
|
||||
|
||||
export interface IDataJumlahDetailDivision {
|
||||
tugas: number,
|
||||
dokumen: number,
|
||||
diskusi: number,
|
||||
kalender: number
|
||||
}
|
||||
|
||||
export interface IDataTaskOnDetailDivision {
|
||||
id: string,
|
||||
title: string,
|
||||
dateStart: string,
|
||||
dateEnd: string
|
||||
}
|
||||
|
||||
export interface IDataKalenderOnDetailDivision {
|
||||
id: string,
|
||||
name: string,
|
||||
extension: string,
|
||||
}
|
||||
|
||||
export interface IDataDiscussionOnDetailDivision {
|
||||
id: string,
|
||||
title: string,
|
||||
date: string,
|
||||
user: string
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TypeUser } from "@/module/user";
|
||||
import { hookstate } from "@hookstate/core";
|
||||
import { IFormMemberDivision } from "./type_division";
|
||||
|
||||
export const globalMemberDivision = hookstate<TypeUser>([]);
|
||||
export const globalMemberDivision = hookstate<IFormMemberDivision[]>([]);
|
||||
Reference in New Issue
Block a user