Merge pull request #100 from bipproduction/amalia/8-agustus-24
upd: api group
This commit is contained in:
@@ -1,6 +0,0 @@
|
|||||||
import { apiGroup } from "@/module/group";
|
|
||||||
import { NextRequest } from "next/server";
|
|
||||||
|
|
||||||
export async function GET(req: NextRequest) {
|
|
||||||
return apiGroup(req, "GET")
|
|
||||||
}
|
|
||||||
@@ -5,17 +5,13 @@ import { FaCheck } from "react-icons/fa6";
|
|||||||
import { WARNA } from "../fun/WARNA";
|
import { WARNA } from "../fun/WARNA";
|
||||||
import LayoutNavbarNew from "../layout/layout_navbar_new";
|
import LayoutNavbarNew from "../layout/layout_navbar_new";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { API_ADDRESS } from "../bin/api_address";
|
import { funGetAllGroup, IDataGroup } from "@/module/group";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
interface dataGroup {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function ViewFilter({ linkFilter }: { linkFilter: string }) {
|
export default function ViewFilter({ linkFilter }: { linkFilter: string }) {
|
||||||
const [selectedFilter, setSelectedFilter] = useState<string | null>(null);
|
const [selectedFilter, setSelectedFilter] = useState<string | null>(null);
|
||||||
const [checked, setChecked] = useState<dataGroup[]>([]);
|
const [checked, setChecked] = useState<IDataGroup[]>([]);
|
||||||
const [searchParams, setSearchParams] = useState({ groupId: '' });
|
const [searchParams, setSearchParams] = useState({ groupId: '' });
|
||||||
|
|
||||||
const handleFilterClick = (id: string) => {
|
const handleFilterClick = (id: string) => {
|
||||||
@@ -24,12 +20,15 @@ export default function ViewFilter({linkFilter}: {linkFilter: string}) {
|
|||||||
|
|
||||||
async function getAllGroupFilter() {
|
async function getAllGroupFilter() {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${API_ADDRESS.apiGetAllGroup}&active=true&groupId=${searchParams.groupId}`);
|
const response = await funGetAllGroup('?active=true')
|
||||||
const data = await response.json();
|
if (response.success) {
|
||||||
console.log("mana data", response);
|
setChecked(response.data);
|
||||||
setChecked(data);
|
} else {
|
||||||
|
toast.error(response.message);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
toast.error("Gagal mendapatkan grup, coba lagi nanti");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +38,7 @@ export default function ViewFilter({linkFilter}: {linkFilter: string}) {
|
|||||||
}
|
}
|
||||||
}, [selectedFilter]);
|
}, [selectedFilter]);
|
||||||
|
|
||||||
useEffect(() => {
|
useShallowEffect(() => {
|
||||||
getAllGroupFilter();
|
getAllGroupFilter();
|
||||||
}, [searchParams.groupId]);
|
}, [searchParams.groupId]);
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import CreateAdminDivision from "./create_admin_division";
|
|||||||
import CreateUsers from "./create_users";
|
import CreateUsers from "./create_users";
|
||||||
import NavbarCreateUsers from "./ui/navbar_create_users";
|
import NavbarCreateUsers from "./ui/navbar_create_users";
|
||||||
import NavbarAdminDivision from "./ui/navbar_admin_division";
|
import NavbarAdminDivision from "./ui/navbar_admin_division";
|
||||||
import { IDataGroup } from "@/module/group";
|
import { funGetAllGroup, IDataGroup } from "@/module/group";
|
||||||
|
|
||||||
export default function CreateDivision() {
|
export default function CreateDivision() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -40,9 +40,12 @@ export default function CreateDivision() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function loadData() {
|
async function loadData() {
|
||||||
const loadGroup = await fetch(API_ADDRESS.apiGetAllGroup + '&active=true');
|
const loadGroup = await funGetAllGroup('?active=true')
|
||||||
const dataGroup = await loadGroup.json();
|
if (loadGroup.success) {
|
||||||
setDataGroup(dataGroup);
|
setDataGroup(loadGroup.data);
|
||||||
|
} else {
|
||||||
|
toast.error(loadGroup.message);
|
||||||
|
}
|
||||||
|
|
||||||
const loadUser = await funGetUserByCookies();
|
const loadUser = await funGetUserByCookies();
|
||||||
setRoleUser(loadUser.idUserRole)
|
setRoleUser(loadUser.idUserRole)
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
import { NextRequest } from "next/server";
|
|
||||||
import { API_INDEX_GROUP } from "./api_index";
|
|
||||||
|
|
||||||
type Method = "GET" | "POST";
|
|
||||||
export async function apiGroup(req: NextRequest, method: Method) {
|
|
||||||
const { searchParams } = new URL(req.url);
|
|
||||||
const path = searchParams.get("path");
|
|
||||||
const act = API_INDEX_GROUP.find((v) => v.path === path && v.method === method);
|
|
||||||
if (!path)
|
|
||||||
return Response.json({ success: false, message: "page not found" }, { status: 404 });
|
|
||||||
if (act) return act.bin(req);
|
|
||||||
|
|
||||||
return Response.json({ success: false, message: "404" });
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
import { getOneGroup } from "./get/getOneGroup";
|
|
||||||
import { listGroups } from "./get/listGroup";
|
|
||||||
|
|
||||||
export const API_INDEX_GROUP = [
|
|
||||||
{
|
|
||||||
path: "get-all-group",
|
|
||||||
method: "GET",
|
|
||||||
bin: listGroups,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "get-one-group",
|
|
||||||
method: "GET",
|
|
||||||
bin: getOneGroup,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
import { prisma } from "@/module/_global";
|
|
||||||
import { NextRequest } from "next/server";
|
|
||||||
|
|
||||||
export async function getOneGroup(req: NextRequest): Promise<Response> {
|
|
||||||
try {
|
|
||||||
const searchParams = req.nextUrl.searchParams
|
|
||||||
const groupId = searchParams.get('groupId');
|
|
||||||
const getOne = await prisma.group.findUnique({
|
|
||||||
where: {
|
|
||||||
id: String(groupId),
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
name: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!getOne) {
|
|
||||||
return Response.json(
|
|
||||||
{ message: "Grup tidak ditemukan", success: false },
|
|
||||||
{ status: 404 }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Response.json(getOne);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
return Response.json(
|
|
||||||
{ message: "Internal Server Error", success: false },
|
|
||||||
{ status: 500 }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
import { prisma } from "@/module/_global";
|
|
||||||
import { funGetUserByCookies } from "@/module/auth";
|
|
||||||
import { NextRequest } from "next/server";
|
|
||||||
|
|
||||||
export async function listGroups(req: NextRequest): Promise<Response> {
|
|
||||||
try {
|
|
||||||
const user = await funGetUserByCookies()
|
|
||||||
const searchParams = req.nextUrl.searchParams
|
|
||||||
const villaId = user.idVillage
|
|
||||||
const active = searchParams.get('active');
|
|
||||||
const name = searchParams.get('name');
|
|
||||||
const groups = await prisma.group.findMany({
|
|
||||||
where: {
|
|
||||||
isActive: (active == "true" ? true : false),
|
|
||||||
idVillage: String(villaId),
|
|
||||||
name: {
|
|
||||||
contains: (name == undefined || name == null) ? "" : name,
|
|
||||||
mode: "insensitive"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
name: true,
|
|
||||||
isActive: true
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return Response.json(groups);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
import { IDataGroup, IFormGroup, IStatusGroup } from './lib/type_group';
|
import { IDataGroup, IFormGroup, IStatusGroup } from './lib/type_group';
|
||||||
import { apiGroup } from "./api/api_group";
|
|
||||||
import { funCreateGroup, funEditGroup, funEditStatusGroup, funGetAllGroup, funGetGroupById } from './lib/api_group';
|
import { funCreateGroup, funEditGroup, funEditStatusGroup, funGetAllGroup, funGetGroupById } from './lib/api_group';
|
||||||
import NavbarGroup from './ui/navbar_group';
|
import NavbarGroup from './ui/navbar_group';
|
||||||
import TabListGroup from './ui/tab_list_group';
|
import TabListGroup from './ui/tab_list_group';
|
||||||
|
|
||||||
export { apiGroup };
|
|
||||||
export type { IDataGroup, IFormGroup, IStatusGroup }
|
export type { IDataGroup, IFormGroup, IStatusGroup }
|
||||||
export { funGetAllGroup, funGetGroupById, funCreateGroup, funEditStatusGroup, funEditGroup }
|
export { funGetAllGroup, funGetGroupById, funCreateGroup, funEditStatusGroup, funEditGroup }
|
||||||
export { NavbarGroup }
|
export { NavbarGroup }
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import React, { useEffect, useState } from "react";
|
|||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import { FaPencil, FaToggleOff } from "react-icons/fa6";
|
import { FaPencil, FaToggleOff } from "react-icons/fa6";
|
||||||
import { IoAddCircle, IoCloseCircleOutline } from "react-icons/io5";
|
import { IoAddCircle, IoCloseCircleOutline } from "react-icons/io5";
|
||||||
import { funEditGroup, funEditStatusGroup } from "../lib/api_group";
|
import { funEditGroup, funEditStatusGroup, funGetGroupById } from "../lib/api_group";
|
||||||
|
|
||||||
export default function EditDrawerGroup({ onUpdated, id, isActive, }: { onUpdated: (val: boolean) => void; id: string; isActive: boolean; }) {
|
export default function EditDrawerGroup({ onUpdated, id, isActive, }: { onUpdated: (val: boolean) => void; id: string; isActive: boolean; }) {
|
||||||
const [openDrawerGroup, setOpenDrawerGroup] = useState(false);
|
const [openDrawerGroup, setOpenDrawerGroup] = useState(false);
|
||||||
@@ -27,11 +27,17 @@ export default function EditDrawerGroup({ onUpdated, id, isActive, }: { onUpdate
|
|||||||
|
|
||||||
async function getOneGroup() {
|
async function getOneGroup() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${API_ADDRESS.apiGetOneGroup}&groupId=${id}`);
|
const res = await funGetGroupById(id);
|
||||||
const data = await res.json();
|
console.log("amalia", res)
|
||||||
setName(data.name);
|
if (res.success) {
|
||||||
|
setName(res.data.name);
|
||||||
|
} else {
|
||||||
|
toast.error(res.message);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
toast.error("Gagal mendapatkan grup, coba lagi nanti");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
import { API_ADDRESS, LayoutDrawer, WARNA } from "@/module/_global"
|
import { API_ADDRESS, LayoutDrawer, WARNA } from "@/module/_global"
|
||||||
import LayoutModal from "@/module/_global/layout/layout_modal"
|
import LayoutModal from "@/module/_global/layout/layout_modal"
|
||||||
|
import { funGetAllGroup, IDataGroup } from "@/module/group"
|
||||||
import { Box, Stack, SimpleGrid, Flex, Text, Select, TextInput, Button } from "@mantine/core"
|
import { Box, Stack, SimpleGrid, Flex, Text, Select, TextInput, Button } from "@mantine/core"
|
||||||
import { useShallowEffect } from "@mantine/hooks"
|
import { useShallowEffect } from "@mantine/hooks"
|
||||||
import { useEffect, useState } from "react"
|
import { useEffect, useState } from "react"
|
||||||
import toast from "react-hot-toast"
|
import toast from "react-hot-toast"
|
||||||
import { FaPencil, FaToggleOff } from "react-icons/fa6"
|
import { FaPencil, FaToggleOff } from "react-icons/fa6"
|
||||||
|
|
||||||
type dataGroup = {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
idGroup: string
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function DrawerDetailPosition({ onUpdated, id, isActive }: {
|
export default function DrawerDetailPosition({ onUpdated, id, isActive }: {
|
||||||
onUpdated: (val: boolean) => void, id: string | null, isActive: boolean | null;
|
onUpdated: (val: boolean) => void, id: string | null, isActive: boolean | null;
|
||||||
}) {
|
}) {
|
||||||
@@ -22,7 +17,7 @@ export default function DrawerDetailPosition({ onUpdated, id, isActive }: {
|
|||||||
name: "",
|
name: "",
|
||||||
idGroup: ""
|
idGroup: ""
|
||||||
})
|
})
|
||||||
const [listGroup, setListGorup] = useState<dataGroup[]>([])
|
const [listGroup, setListGorup] = useState<IDataGroup[]>([])
|
||||||
|
|
||||||
function onCLose() {
|
function onCLose() {
|
||||||
onUpdated(true)
|
onUpdated(true)
|
||||||
@@ -31,11 +26,15 @@ export default function DrawerDetailPosition({ onUpdated, id, isActive }: {
|
|||||||
|
|
||||||
async function getAllGroup() {
|
async function getAllGroup() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${API_ADDRESS.apiGetAllGroup}&villageId=121212&active=true`)
|
const response = await funGetAllGroup('?active=true')
|
||||||
const data = await res.json()
|
if (response.success) {
|
||||||
setListGorup(data)
|
setListGorup(response.data);
|
||||||
|
} else {
|
||||||
|
toast.error(response.message);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
toast.error("Gagal mendapatkan grup, coba lagi nanti");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { WARNA, LayoutDrawer, API_ADDRESS } from "@/module/_global";
|
import { WARNA, LayoutDrawer, API_ADDRESS } from "@/module/_global";
|
||||||
|
import { funGetAllGroup, IDataGroup } from "@/module/group";
|
||||||
import { Box, Stack, SimpleGrid, Flex, TextInput, Button, Text, Select } from "@mantine/core";
|
import { Box, Stack, SimpleGrid, Flex, TextInput, Button, Text, Select } from "@mantine/core";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
@@ -7,15 +8,11 @@ import toast from "react-hot-toast";
|
|||||||
import { IoAddCircle } from "react-icons/io5";
|
import { IoAddCircle } from "react-icons/io5";
|
||||||
import { RiFilter2Line } from "react-icons/ri";
|
import { RiFilter2Line } from "react-icons/ri";
|
||||||
|
|
||||||
type dataGroup = {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function DrawerListPosition({ onCreated }: { onCreated: (val: boolean) => void }) {
|
export default function DrawerListPosition({ onCreated }: { onCreated: (val: boolean) => void }) {
|
||||||
const [openDrawerGroup, setOpenDrawerGroup] = useState(false)
|
const [openDrawerGroup, setOpenDrawerGroup] = useState(false)
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [listGroup, setListGorup] = useState<dataGroup[]>([])
|
const [listGroup, setListGorup] = useState<IDataGroup[]>([])
|
||||||
|
|
||||||
const [listData, setListData] = useState({
|
const [listData, setListData] = useState({
|
||||||
name: "",
|
name: "",
|
||||||
@@ -24,11 +21,15 @@ export default function DrawerListPosition({ onCreated }: { onCreated: (val: boo
|
|||||||
|
|
||||||
async function getAllGroup() {
|
async function getAllGroup() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${API_ADDRESS.apiGetAllGroup}&villageId=121212&active=true`)
|
const response = await funGetAllGroup('?active=true')
|
||||||
const data = await res.json()
|
if (response.success) {
|
||||||
setListGorup(data)
|
setListGorup(response.data);
|
||||||
|
} else {
|
||||||
|
toast.error(response.message);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
toast.error("Gagal mendapatkan grup, coba lagi nanti");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import { API_ADDRESS, WARNA } from "@/module/_global";
|
import { API_ADDRESS, WARNA } from "@/module/_global";
|
||||||
import LayoutModal from "@/module/_global/layout/layout_modal";
|
import LayoutModal from "@/module/_global/layout/layout_modal";
|
||||||
|
import { funGetAllGroup, IDataGroup } from "@/module/group";
|
||||||
import { Box, Button, Select, Stack, TextInput } from "@mantine/core";
|
import { Box, Button, Select, Stack, TextInput } from "@mantine/core";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import { HiUser } from "react-icons/hi2";
|
import { HiUser } from "react-icons/hi2";
|
||||||
|
|
||||||
type dataGroup = {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
};
|
|
||||||
type dataPosition = {
|
type dataPosition = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -24,7 +22,7 @@ type dataROleUser = {
|
|||||||
export default function CreateMember() {
|
export default function CreateMember() {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [isModal, setModal] = useState(false)
|
const [isModal, setModal] = useState(false)
|
||||||
const [listGroup, setListGorup] = useState<dataGroup[]>([])
|
const [listGroup, setListGorup] = useState<IDataGroup[]>([])
|
||||||
const [listPosition, setListPosition] = useState<dataPosition[]>([])
|
const [listPosition, setListPosition] = useState<dataPosition[]>([])
|
||||||
const [listUserRole, setListUserRole] = useState<dataROleUser[]>([])
|
const [listUserRole, setListUserRole] = useState<dataROleUser[]>([])
|
||||||
|
|
||||||
@@ -42,11 +40,15 @@ export default function CreateMember() {
|
|||||||
|
|
||||||
async function getAllGroup() {
|
async function getAllGroup() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${API_ADDRESS.apiGetAllGroup}&villageId=desa1&active=true`)
|
const response = await funGetAllGroup('?active=true')
|
||||||
const data = await res.json()
|
if (response.success) {
|
||||||
setListGorup(data)
|
setListGorup(response.data);
|
||||||
|
} else {
|
||||||
|
toast.error(response.message);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
toast.error("Gagal mendapatkan grup, coba lagi nanti");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import { API_ADDRESS, WARNA } from "@/module/_global";
|
import { API_ADDRESS, WARNA } from "@/module/_global";
|
||||||
import LayoutModal from "@/module/_global/layout/layout_modal";
|
import LayoutModal from "@/module/_global/layout/layout_modal";
|
||||||
|
import { funGetAllGroup, IDataGroup } from "@/module/group";
|
||||||
import { Box, Button, Select, Stack, TextInput } from "@mantine/core";
|
import { Box, Button, Select, Stack, TextInput } from "@mantine/core";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
@@ -20,10 +21,7 @@ type dataMember = {
|
|||||||
idUserRole: string;
|
idUserRole: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type dataGroup = {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
};
|
|
||||||
type dataPosition = {
|
type dataPosition = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -37,7 +35,7 @@ type dataROleUser = {
|
|||||||
export default function EditMember({ id }: { id: string | undefined }) {
|
export default function EditMember({ id }: { id: string | undefined }) {
|
||||||
const [isModal, setModal] = useState(false)
|
const [isModal, setModal] = useState(false)
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [listGroup, setListGorup] = useState<dataGroup[]>([])
|
const [listGroup, setListGorup] = useState<IDataGroup[]>([])
|
||||||
const [listPosition, setListPosition] = useState<dataPosition[]>([])
|
const [listPosition, setListPosition] = useState<dataPosition[]>([])
|
||||||
const [listUserRole, setListUserRole] = useState<dataROleUser[]>([])
|
const [listUserRole, setListUserRole] = useState<dataROleUser[]>([])
|
||||||
const [data, setData] = useState<dataMember>({
|
const [data, setData] = useState<dataMember>({
|
||||||
@@ -55,11 +53,15 @@ export default function EditMember({ id }: { id: string | undefined }) {
|
|||||||
|
|
||||||
async function getAllGroup() {
|
async function getAllGroup() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${API_ADDRESS.apiGetAllGroup}&villageId=desa1&active=true`)
|
const response = await funGetAllGroup('?active=true')
|
||||||
const data = await res.json()
|
if (response.success) {
|
||||||
setListGorup(data)
|
setListGorup(response.data);
|
||||||
|
} else {
|
||||||
|
toast.error(response.message);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
toast.error("Gagal mendapatkan grup, coba lagi nanti");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user