diff --git a/src/app/(application)/banner/page.tsx b/src/app/(application)/banner/page.tsx
index cf5edef..23618b0 100644
--- a/src/app/(application)/banner/page.tsx
+++ b/src/app/(application)/banner/page.tsx
@@ -1,4 +1,3 @@
-
import { ListBanner, NavbarBanner } from "@/module/banner";
import { Box } from "@mantine/core";
@@ -7,7 +6,6 @@ export default function Page() {
-
);
}
\ No newline at end of file
diff --git a/src/app/api/home/route.ts b/src/app/api/home/route.ts
index aee2186..d2cde94 100644
--- a/src/app/api/home/route.ts
+++ b/src/app/api/home/route.ts
@@ -185,9 +185,10 @@ export async function GET(request: Request) {
const cek = data.some((i: any) => i.status == dataStatus[index].status)
if (cek) {
const find = ((Number(data.find((i: any) => i.status == dataStatus[index].status)?._count) * 100) / data.reduce((n, { _count }) => n + _count, 0)).toFixed(2)
+ const fix = find.substr(-2, 2) == "00" ? find.substr(0, 2) : find
input = {
name: dataStatus[index].name,
- value: find
+ value: fix
}
} else {
input = {
diff --git a/src/module/_global/layout/layout_icon_back.tsx b/src/module/_global/layout/layout_icon_back.tsx
index d4658fa..a84f8c1 100644
--- a/src/module/_global/layout/layout_icon_back.tsx
+++ b/src/module/_global/layout/layout_icon_back.tsx
@@ -1,11 +1,9 @@
'use client'
-import { ActionIcon, Box } from '@mantine/core';
-import { useRouter } from 'next/navigation';
-import React from 'react';
-import { HiChevronLeft } from 'react-icons/hi2';
-import { WARNA } from '../fun/WARNA';
-import _ from 'lodash';
import { useHookstate } from '@hookstate/core';
+import { ActionIcon, Box } from '@mantine/core';
+import _ from 'lodash';
+import { useRouter } from 'next/navigation';
+import { HiChevronLeft } from 'react-icons/hi2';
import { TEMA } from '../bin/val_global';
function LayoutIconBack({ back }: { back?: string }) {
diff --git a/src/module/_global/layout/layout_navbar_new.tsx b/src/module/_global/layout/layout_navbar_new.tsx
index bd2059a..5f5a244 100644
--- a/src/module/_global/layout/layout_navbar_new.tsx
+++ b/src/module/_global/layout/layout_navbar_new.tsx
@@ -1,11 +1,10 @@
'use client'
-import { ActionIcon, Box, Grid, Group, Text, Title } from '@mantine/core';
-import React from 'react';
-import { WARNA } from '../fun/WARNA';
-import LayoutIconBack from './layout_icon_back';
-import _ from 'lodash';
import { useHookstate } from '@hookstate/core';
+import { Box, Grid, Group, Title } from '@mantine/core';
+import _ from 'lodash';
+import React from 'react';
import { TEMA } from '../bin/val_global';
+import LayoutIconBack from './layout_icon_back';
export const LayoutNavbarNew = ({ back, state, title, menu }: { back?: string, title: string, menu: React.ReactNode, state?: React.ReactNode }) => {
const tema = useHookstate(TEMA)
diff --git a/src/module/banner/ui/list_banner.tsx b/src/module/banner/ui/list_banner.tsx
index 05b2c2b..8497475 100644
--- a/src/module/banner/ui/list_banner.tsx
+++ b/src/module/banner/ui/list_banner.tsx
@@ -5,7 +5,7 @@ import LayoutModal from '@/module/_global/layout/layout_modal';
import { useHookstate } from '@hookstate/core';
import { ActionIcon, Box, Flex, Group, Image, Paper, SimpleGrid, Stack, Text } from '@mantine/core';
import { useShallowEffect } from '@mantine/hooks';
-import { useParams, useRouter } from 'next/navigation';
+import { useRouter } from 'next/navigation';
import { useState } from 'react';
import toast from 'react-hot-toast';
import { FaFile, FaPencil, FaTrash } from 'react-icons/fa6';
@@ -25,6 +25,7 @@ function ListBanner() {
const [isData, setData] = useState([])
const [idData, setIdData] = useState('')
const [isPage, setPage] = useState(1)
+ const [loadingModal, setLoadingModal] = useState(false)
const fetchData = async (loading: boolean) => {
try {
@@ -57,6 +58,7 @@ function ListBanner() {
async function onDelete(id: string) {
try {
+ setLoadingModal(true)
const res = await funDeleteBanner(id);
if (res.success) {
toast.success(res.message)
@@ -70,8 +72,10 @@ function ListBanner() {
} catch (error) {
console.error(error);
toast.error("Gagal menghapus banner, coba lagi nanti");
+ } finally {
+ setLoadingModal(false)
+ setOpenModal(false)
}
-
}
@@ -100,34 +104,34 @@ function ListBanner() {
isData.map((v, i) => {
return (
- {
- setIdData(v.id);
- setIdDataStorage(v.image);
- setExtension(v.extension);
- setOpenDrawer(true)
- }
- }
- style={{
- width: '100%',
- maxWidth: 550,
- height: 85,
- backgroundColor: 'transparent',
- border: `1px solid ${tema.get().bgTotalKegiatan}`
+ {
+ setIdData(v.id);
+ setIdDataStorage(v.image);
+ setExtension(v.extension);
+ setOpenDrawer(true)
+ }
+ }
+ style={{
+ width: '100%',
+ maxWidth: 550,
+ height: 85,
+ backgroundColor: 'transparent',
+ border: `1px solid ${tema.get().bgTotalKegiatan}`
- }}>
-
-
-
-
- {v.title}
-
-
+ }}>
+
+
+
+
+ {v.title}
+
+
)
})
@@ -178,14 +182,16 @@ function ListBanner() {
setOpenModal(false)}
description='Apakah Anda yakin ingin menghapus banner?'
onYes={(val) => {
if (val) {
onDelete(idData)
+ } else {
+ setOpenModal(false)
}
- setOpenModal(false)
}} />
setOpenModalView(false)} file={idDataStorage} extension={isExtension} fitur="image" />
diff --git a/src/module/color_palette/ui/drawer_palet_edit_end_default.tsx b/src/module/color_palette/ui/drawer_palet_edit_end_default.tsx
index c23d491..d64abd6 100644
--- a/src/module/color_palette/ui/drawer_palet_edit_end_default.tsx
+++ b/src/module/color_palette/ui/drawer_palet_edit_end_default.tsx
@@ -3,11 +3,11 @@ import LayoutModal from '@/module/_global/layout/layout_modal';
import { useHookstate } from '@hookstate/core';
import { Box, Flex, SimpleGrid, Text } from '@mantine/core';
import { useRouter } from 'next/navigation';
-import React, { useState } from 'react';
+import { useState } from 'react';
import toast from 'react-hot-toast';
import { FaPencil, FaTrash } from 'react-icons/fa6';
import { IoColorPalette } from 'react-icons/io5';
-import { funChangeTheme, funDeleteTheme, funGetThemeById } from '../lib/api_theme';
+import { funChangeTheme, funDeleteTheme } from '../lib/api_theme';
import { globalRefreshTheme } from '../lib/val_theme';
export default function DrawerPaletEditEndDefault({ id, idVillage, isUse }: { id: string, idVillage: string, isUse: boolean }) {
@@ -16,9 +16,12 @@ export default function DrawerPaletEditEndDefault({ id, idVillage, isUse }: { id
const [isModalDel, setModalDel] = useState(false)
const tema = useHookstate(TEMA)
const refresh = useHookstate(globalRefreshTheme)
+ const [loadingApply, setLoadingApply] = useState(false)
+ const [loadingDelete, setLoadingDelete] = useState(false)
async function onChangeTheme() {
try {
+ setLoadingApply(true)
const res = await funChangeTheme(id)
if (res.success) {
tema.set(res.data)
@@ -29,11 +32,15 @@ export default function DrawerPaletEditEndDefault({ id, idVillage, isUse }: { id
} catch (error) {
console.error(error)
toast.error("Gagal mengubah tema, coba lagi nanti");
+ } finally {
+ setLoadingApply(false)
+ setModal(false)
}
}
async function onDelete() {
try {
+ setLoadingDelete(true)
const res = await funDeleteTheme(id)
if (res.success) {
toast.success(res.message);
@@ -44,6 +51,9 @@ export default function DrawerPaletEditEndDefault({ id, idVillage, isUse }: { id
} catch (error) {
console.error(error)
toast.error("Gagal menghapus tema, coba lagi nanti");
+ } finally {
+ setLoadingDelete(false)
+ setModalDel(false)
}
}
@@ -86,23 +96,25 @@ export default function DrawerPaletEditEndDefault({ id, idVillage, isUse }: { id
}
- setModal(false)}
+ setModal(false)}
description="Apakah Anda yakin ingin mengubah Tema Aplikasi?"
onYes={(val) => {
if (val) {
onChangeTheme()
+ }else{
+ setModal(false)
}
- setModal(false)
}} />
- setModalDel(false)}
+ setModalDel(false)}
description="Apakah Anda yakin ingin menghapus Tema Aplikasi?"
onYes={(val) => {
if (val) {
onDelete()
+ }else{
+ setModalDel(false)
}
- setModalDel(false)
}} />
);
diff --git a/src/module/division_new/ui/navbar_detail_division.tsx b/src/module/division_new/ui/navbar_detail_division.tsx
index d857157..007c0bd 100644
--- a/src/module/division_new/ui/navbar_detail_division.tsx
+++ b/src/module/division_new/ui/navbar_detail_division.tsx
@@ -1,14 +1,14 @@
'use client'
import { LayoutDrawer, LayoutNavbarNew, TEMA } from "@/module/_global";
-import { ActionIcon, Box } from "@mantine/core";
-import { useState } from "react";
-import { HiMenu } from "react-icons/hi";
-import DrawerDetailDivision from "./drawer_detail_division";
-import { funGetDivisionById } from "../lib/api_division";
-import { useParams } from "next/navigation";
-import toast from "react-hot-toast";
-import { useShallowEffect } from "@mantine/hooks";
import { useHookstate } from "@hookstate/core";
+import { ActionIcon } from "@mantine/core";
+import { useShallowEffect } from "@mantine/hooks";
+import { useParams } from "next/navigation";
+import { useState } from "react";
+import toast from "react-hot-toast";
+import { HiMenu } from "react-icons/hi";
+import { funGetDivisionById } from "../lib/api_division";
+import DrawerDetailDivision from "./drawer_detail_division";
export default function NavbarDetailDivision() {
const [openDrawer, setOpenDrawer] = useState(false)
@@ -37,7 +37,7 @@ export default function NavbarDetailDivision() {
return (
<>
- (setOpenDrawer(true))} bg={tema.get().bgIcon} size="lg" radius="lg" aria-label="Settings">
diff --git a/src/module/group/ui/drawer_group.tsx b/src/module/group/ui/drawer_group.tsx
index 99d70c3..b53a39d 100644
--- a/src/module/group/ui/drawer_group.tsx
+++ b/src/module/group/ui/drawer_group.tsx
@@ -12,6 +12,7 @@ export default function DrawerGroup({ onSuccess, }: { onSuccess: (val: boolean)
const [namaGroup, setNamaGroup] = useState("");
const tema = useHookstate(TEMA)
const refresh = useHookstate(globalRefreshGroup)
+ const [loading, setLoading] = useState(false)
const [touched, setTouched] = useState({
name: false,
});
@@ -19,8 +20,8 @@ export default function DrawerGroup({ onSuccess, }: { onSuccess: (val: boolean)
async function createData() {
try {
+ setLoading(true)
const response = await funCreateGroup({ name: namaGroup })
-
if (response.success) {
toast.success(response.message);
refresh.set(!refresh.get())
@@ -33,6 +34,8 @@ export default function DrawerGroup({ onSuccess, }: { onSuccess: (val: boolean)
} catch (error) {
console.error(error);
toast.error("Gagal menambahkan grup, coba lagi nanti");
+ } finally {
+ setLoading(false)
}
}
@@ -85,7 +88,7 @@ export default function DrawerGroup({ onSuccess, }: { onSuccess: (val: boolean)
onClose={() => setOpenDrawerGroup(false)}
title={"Tambah Grup"}
>
-
+
-
+
diff --git a/src/module/group/ui/edit_drawer_group.tsx b/src/module/group/ui/edit_drawer_group.tsx
index cc34ea3..f5c7e48 100644
--- a/src/module/group/ui/edit_drawer_group.tsx
+++ b/src/module/group/ui/edit_drawer_group.tsx
@@ -2,15 +2,7 @@
import { LayoutDrawer, TEMA } from "@/module/_global";
import LayoutModal from "@/module/_global/layout/layout_modal";
import { useHookstate } from "@hookstate/core";
-import {
- Box,
- Button,
- Flex,
- SimpleGrid,
- Stack,
- Text,
- TextInput
-} from "@mantine/core";
+import { Box, Button, Flex, SimpleGrid, Stack, Text, TextInput } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { useState } from "react";
import toast from "react-hot-toast";
@@ -23,6 +15,7 @@ export default function EditDrawerGroup({ onUpdated, id, isActive, }: { onUpdate
const [isModal, setModal] = useState(false);
const [name, setName] = useState("");
const [loading, setLoading] = useState(false);
+ const [loadingModal, setLoadingModal] = useState(false)
const refresh = useHookstate(globalRefreshGroup)
const tema = useHookstate(TEMA)
const [touched, setTouched] = useState({
@@ -90,6 +83,7 @@ export default function EditDrawerGroup({ onUpdated, id, isActive, }: { onUpdate
async function nonActive(val: boolean) {
try {
if (val) {
+ setLoadingModal(true)
const res = await funEditStatusGroup(id, { isActive: isActive });
if (res.success) {
toast.success(res.message);
@@ -99,11 +93,12 @@ export default function EditDrawerGroup({ onUpdated, id, isActive, }: { onUpdate
toast.error(res.message)
}
}
- setModal(false);
} catch (error) {
- setModal(false);
console.error(error);
toast.error("Edit grup gagal, coba lagi nanti");
+ } finally {
+ setLoadingModal(false)
+ setModal(false);
}
}
@@ -146,7 +141,7 @@ export default function EditDrawerGroup({ onUpdated, id, isActive, }: { onUpdate
onClose={() => setOpenDrawerGroup(false)}
title={"Edit Grup"}
>
-
+
{
onValidation('name', e.target.value)
@@ -171,7 +166,7 @@ export default function EditDrawerGroup({ onUpdated, id, isActive, }: { onUpdate
label="Grup"
required
/>
-
+
diff --git a/src/module/home/lib/type_home.ts b/src/module/home/lib/type_home.ts
index 3dd4c64..a447b57 100644
--- a/src/module/home/lib/type_home.ts
+++ b/src/module/home/lib/type_home.ts
@@ -2,7 +2,7 @@ export interface IDataHomeKegiatan {
id: string
title: string
desc: string
- status: string
+ status: number
progress: number
createdAt: string
}
diff --git a/src/module/home/ui/chart_progress_tugas.tsx b/src/module/home/ui/chart_progress_tugas.tsx
index 9d72fe5..3e6caac 100644
--- a/src/module/home/ui/chart_progress_tugas.tsx
+++ b/src/module/home/ui/chart_progress_tugas.tsx
@@ -1,13 +1,13 @@
'use client'
-import { TEMA, WARNA } from "@/module/_global";
-import { Box, Text } from "@mantine/core";
+import { TEMA } from "@/module/_global";
+import { useHookstate } from "@hookstate/core";
+import { Box } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { EChartsOption } from "echarts";
import EChartsReact from "echarts-for-react";
import { useState } from "react";
-import { funGetHome } from "../lib/api_home";
import toast from "react-hot-toast";
-import { useHookstate } from "@hookstate/core";
+import { funGetHome } from "../lib/api_home";
export default function ChartProgressHome() {
const [options, setOptions] = useState({});
@@ -41,7 +41,7 @@ export default function ChartProgressHome() {
}
};
- const loadData = (value:any) => {
+ const loadData = (value: any) => {
const option: EChartsOption = {
title: {
text: "PROGRES KEGIATAN",
diff --git a/src/module/home/ui/list_project.tsx b/src/module/home/ui/list_project.tsx
index e1c8767..7dc653e 100644
--- a/src/module/home/ui/list_project.tsx
+++ b/src/module/home/ui/list_project.tsx
@@ -2,7 +2,7 @@
import { TEMA } from "@/module/_global";
import { useHookstate } from "@hookstate/core";
import { Carousel } from "@mantine/carousel";
-import { Box, Card, Flex, Progress, Skeleton, Stack, Text, Title } from "@mantine/core";
+import { Badge, Box, Card, Flex, Group, Progress, Skeleton, Stack, Text, Title } from "@mantine/core";
import { useMediaQuery, useShallowEffect } from "@mantine/hooks";
import _ from "lodash";
import { useRouter } from "next/navigation";
@@ -79,7 +79,24 @@ export default function ListProjects() {
{_.isNull(v.progress) ? 0 : v.progress}%
- {v.createdAt}
+
+ {v.createdAt}
+
+ {
+ v.status === 0 ? 'Segera' :
+ v.status === 1 ? 'Dikerjakan' :
+ v.status === 2 ? 'Selesai' :
+ v.status === 3 ? 'Dibatalkan' :
+ "Segera"
+ }
+
+
diff --git a/src/module/home/ui/view_search.tsx b/src/module/home/ui/view_search.tsx
index 263298c..bd9bb47 100644
--- a/src/module/home/ui/view_search.tsx
+++ b/src/module/home/ui/view_search.tsx
@@ -1,62 +1,49 @@
"use client";
-import { LayoutNavbarNew, TEMA, WARNA } from "@/module/_global";
-import {
- ActionIcon,
- Avatar,
- Box,
- Divider,
- Grid,
- Group,
- Text,
- TextInput,
-} from "@mantine/core";
-import React, { useState } from "react";
-import {
- HiMagnifyingGlass,
- HiMiniPresentationChartBar,
- HiMiniUserGroup,
-} from "react-icons/hi2";
-import { funGetSearchAll } from "../lib/api_search";
-import { useMediaQuery, useShallowEffect } from "@mantine/hooks";
-import {
- IDataDivisionSearch,
- IDataProjectSearch,
- IDataUserSearch,
-} from "../lib/type_search";
-import { useRouter } from "next/navigation";
-import _ from "lodash";
+import { LayoutNavbarNew, SkeletonList, TEMA, WARNA } from "@/module/_global";
import { useHookstate } from "@hookstate/core";
+import { ActionIcon, Avatar, Box, Divider, Grid, Text, TextInput } from "@mantine/core";
+import { useMediaQuery } from "@mantine/hooks";
+import _ from "lodash";
+import { useRouter } from "next/navigation";
+import { useState } from "react";
+import toast from "react-hot-toast";
+import { HiMagnifyingGlass, HiMiniPresentationChartBar, HiMiniUserGroup, } from "react-icons/hi2";
+import { funGetSearchAll } from "../lib/api_search";
+import { IDataDivisionSearch, IDataProjectSearch, IDataUserSearch, } from "../lib/type_search";
export default function ViewSearch() {
- const [search, setSearch] = useState("");
- const [dataUser, setDataUser] = useState([]);
- const [dataProject, setDataProject] = useState([]);
- const [dataDivision, setDataDivision] = useState([]);
- const router = useRouter();
- const tema = useHookstate(TEMA);
+ const [search, setSearch] = useState("")
+ const [dataUser, setDataUser] = useState([])
+ const [dataProject, setDataProject] = useState([])
+ const [dataDivision, setDataDivision] = useState([])
+ const [loading, setLoading] = useState(false)
+ const router = useRouter()
+ const tema = useHookstate(TEMA)
+ const isMobile2 = useMediaQuery("(max-width: 460px)");
- async function featchSearch() {
+ async function featchSearch(cari: string) {
try {
- const res = await funGetSearchAll("?search=" + search);
- setDataUser(res.data.user);
- setDataProject(res.data.project);
- setDataDivision(res.data.division);
+ setLoading(true)
+ setSearch(cari)
+ if (cari != "") {
+ const res = await funGetSearchAll("?search=" + cari);
+ setDataUser(res.data.user);
+ setDataProject(res.data.project);
+ setDataDivision(res.data.division);
+ } else {
+ setDataUser([]);
+ setDataProject([]);
+ setDataDivision([]);
+ }
} catch (error) {
console.error(error);
- throw new Error("Error");
+ toast.error("Gagal mendapatkan data, coba lagi nanti");
+ } finally {
+ setLoading(false)
}
}
- useShallowEffect(() => {
- if (search != "") {
- featchSearch();
- } else {
- setDataUser([]);
- setDataProject([]);
- setDataDivision([]);
- }
- }, [search]);
- const isMobile2 = useMediaQuery("(max-width: 460px)");
+
return (
<>
@@ -74,263 +61,280 @@ export default function ViewSearch() {
radius={30}
leftSection={}
placeholder="Pencarian"
- onChange={(e) => setSearch(e.target.value)}
+ onChange={(e) => featchSearch(e.target.value)}
/>
- {dataUser.length || dataProject.length || dataDivision.length > 0 ? (
-
-
- {dataUser.length > 0 ? (
-
- ANGGOTA
+ {
+ loading ?
+ Array(5)
+ .fill(null)
+ .map((_, i) => (
+
+
+
+ ))
+ :
+ dataUser.length || dataProject.length || dataDivision.length > 0 ?
+ (
+
{dataUser.length > 0 ? (
-
- {dataUser.map((v, i) => {
- return (
-
- {
- router.push(`/member/${v.id}`);
- }}
- >
-
-
-
-
-
-
+ ANGGOTA
+
+ {dataUser.length > 0 ? (
+
+ {dataUser.map((v, i) => {
+ return (
+
+ {
+ router.push(`/member/${v.id}`);
+ }}
>
- {_.startCase(v.name)}
-
-
- {v.group + " - " + v.position}
-
-
-
-
-
+
+
+
+
+
+
+ {_.startCase(v.name)}
+
+
+ {v.group + " - " + v.position}
+
+
+
+
+
+
+ );
+ })}
- );
- })}
+ ) : null}
+
) : null}
-
-
- ) : null}
- {dataDivision.length > 0 ? (
-
- DIVISI
-
{dataDivision.length > 0 ? (
-
- {dataDivision.map((v, i) => {
- return (
- router.push(`/division/${v.id}`)}
- >
-
-
-
-
-
-
-
+
+ DIVISI
+
+ {dataDivision.length > 0 ? (
+
+ {dataDivision.map((v, i) => {
+ return (
router.push(`/division/${v.id}`)}
>
+
+
+
+
+
+
+
+
+
+ {v.name.toUpperCase()}
+
+
+
+ {v.group}
+
+
+
- {v.name.toUpperCase()}
+ {v.desc}
+
-
- {v.group}
-
-
-
-
- {v.desc}
-
-
+ );
+ })}
- );
- })}
+ ) : null}
+
) : null}
-
-
- ) : null}
- {dataProject.length > 0 ? (
-
- KEGIATAN
-
{dataProject.length > 0 ? (
-
- {dataProject.map((v, i) => {
- return (
- router.push(`/project/${v.id}`)}
- >
-
-
-
-
-
-
-
+
+ KEGIATAN
+
+ {dataProject.length > 0 ? (
+
+ {dataProject.map((v, i) => {
+ return (
router.push(`/project/${v.id}`)}
>
-
- {v.title.toUpperCase()}
-
+
+
+
+
+
+
+
+
+
+ {v.title.toUpperCase()}
+
+
+
+ {v.group}
+
+
+
+
-
- {v.group}
-
-
-
-
+ );
+ })}
- );
- })}
+ ) : null}
+
) : null}
- ) : null}
-
-
- ) : null}
+ ) :
+ search != '' ?
+
+ Tidak ada data
+
+ : null
+ }
>
);
diff --git a/src/module/position/ui/drawer_detail_position.tsx b/src/module/position/ui/drawer_detail_position.tsx
index aff4f6b..c81cc9c 100644
--- a/src/module/position/ui/drawer_detail_position.tsx
+++ b/src/module/position/ui/drawer_detail_position.tsx
@@ -1,25 +1,24 @@
-import { keyWibu, LayoutDrawer, TEMA, WARNA } from "@/module/_global"
+import { keyWibu, LayoutDrawer, TEMA } from "@/module/_global"
import LayoutModal from "@/module/_global/layout/layout_modal"
-import { funGetAllGroup, IDataGroup } from "@/module/group"
-import { Box, Stack, SimpleGrid, Flex, Text, Select, TextInput, Button, Skeleton } from "@mantine/core"
+import { funGetAllGroup } from "@/module/group"
+import { useHookstate } from "@hookstate/core"
+import { Box, Button, Flex, SimpleGrid, Skeleton, Stack, Text, TextInput } from "@mantine/core"
import { useShallowEffect } from "@mantine/hooks"
-import { useEffect, useState } from "react"
+import { useState } from "react"
import toast from "react-hot-toast"
import { FaPencil, FaToggleOff } from "react-icons/fa6"
+import { useWibuRealtime } from "wibu-realtime"
import { funEditPosition, funEditStatusPosition, funGetOnePosition } from "../lib/api_position"
import { IDataPosition } from "../lib/type_position"
-import { useHookstate } from "@hookstate/core"
import { globalRefreshPosition } from "../lib/val_posisition"
-import { useWibuRealtime } from "wibu-realtime"
-export default function DrawerDetailPosition({ onUpdated, id, isActive }: {
- onUpdated: (val: boolean) => void, id: string, isActive: boolean;
-}) {
+export default function DrawerDetailPosition({ onUpdated, id, isActive }: { onUpdated: (val: boolean) => void, id: string, isActive: boolean; }) {
const [openDrawerGroup, setOpenDrawerGroup] = useState(false)
const [isModal, setModal] = useState(false)
const refresh = useHookstate(globalRefreshPosition)
const [loading, setLoading] = useState(true)
const [loadingEdit, setLoadingEdit] = useState(false)
+ const [loadingModal, setLoadingModal] = useState(false)
const tema = useHookstate(TEMA)
const [data, setData] = useState({
id: id,
@@ -128,6 +127,7 @@ export default function DrawerDetailPosition({ onUpdated, id, isActive }: {
async function nonActive(val: boolean) {
try {
if (val) {
+ setLoadingModal(true)
const res = await funEditStatusPosition(id, { isActive: isActive })
if (res.success) {
toast.success(res.message);
@@ -142,12 +142,13 @@ export default function DrawerDetailPosition({ onUpdated, id, isActive }: {
toast.error(res.message)
}
}
- setModal(false);
} catch (error) {
console.error(error);
- setModal(false);
toast.error("Edit jabatan gagal, coba lagi nanti");
- onUpdated(false);
+ onUpdated(false)
+ } finally {
+ setLoadingModal(false)
+ setModal(false)
}
}
@@ -185,7 +186,7 @@ export default function DrawerDetailPosition({ onUpdated, id, isActive }: {
setOpenDrawerGroup(false)} title={'Edit Jabatan'} >
-
+
{loading ?
@@ -233,7 +234,7 @@ export default function DrawerDetailPosition({ onUpdated, id, isActive }: {
- setModal(false)}
+ setModal(false)}
description="Apakah Anda yakin ingin mengubah status aktifasi data?"
onYes={(val) => { nonActive(val) }} />
diff --git a/src/module/project/ui/navbar_detail_project.tsx b/src/module/project/ui/navbar_detail_project.tsx
index 0568bf5..d6e6676 100644
--- a/src/module/project/ui/navbar_detail_project.tsx
+++ b/src/module/project/ui/navbar_detail_project.tsx
@@ -10,8 +10,8 @@ import { FaFileCirclePlus, FaPencil, FaUsers } from 'react-icons/fa6';
import { HiMenu } from 'react-icons/hi';
import { IoAddCircle } from 'react-icons/io5';
import { MdCancel } from 'react-icons/md';
-import { funGetOneProjectById } from '../lib/api_project';
import { useWibuRealtime } from 'wibu-realtime';
+import { funGetOneProjectById } from '../lib/api_project';
export default function NavbarDetailProject() {
const router = useRouter()
@@ -54,7 +54,7 @@ export default function NavbarDetailProject() {
return (
<>
- void; id: string; status: boolean; }) {
- const router = useRouter();
- const [isModal, setModal] = useState(false);
- const tema = useHookstate(TEMA)
- const [dataRealTime, setDataRealtime] = useWibuRealtime({
- WIBU_REALTIME_TOKEN: keyWibu,
- project: "sdm"
- })
+ const router = useRouter()
+ const [isModal, setModal] = useState(false)
+ const tema = useHookstate(TEMA)
+ const [loadingModal, setLoadingModal] = useState(false)
+ const [dataRealTime, setDataRealtime] = useWibuRealtime({
+ WIBU_REALTIME_TOKEN: keyWibu,
+ project: "sdm"
+ })
- async function nonActive(val: boolean) {
- try {
- if (val) {
- const res = await funEditStatusMember(id, {
- isActive: status ? true : false,
- });
- if (res.success) {
- setDataRealtime([{
- category: "data-member",
- group: res.data.idGroup,
- }])
- toast.success(res.message);
- router.push("/member?active=true");
- onDeleted(true);
- } else {
- onDeleted(false);
- }
+ async function nonActive(val: boolean) {
+ try {
+ if (val) {
+ setLoadingModal(true)
+ const res = await funEditStatusMember(id, {
+ isActive: status ? true : false,
+ });
+ if (res.success) {
+ setDataRealtime([{
+ category: "data-member",
+ group: res.data.idGroup,
+ }])
+ toast.success(res.message);
+ router.push("/member?active=true");
+ onDeleted(true);
+ } else {
+ onDeleted(false);
+ }
+ }
+ } catch (error) {
+ console.error(error);
+ toast.error("Terjadi kesalahan");
+ } finally {
+ setModal(false)
+ setLoadingModal(false)
}
- setModal(false);
- } catch (error) {
- console.error(error);
- setModal(false);
- toast.error("Terjadi kesalahan");
- }
- }
+ }
- return (
-
-
-
- {
- setModal(true);
- }}
- >
-
-
-
-
-
- {" "}
- {status === false ? "Aktifkan" : "Non Aktifkan"}
-
-
-
+ return (
+
+
+
+ {
+ setModal(true);
+ }}
+ >
+
+
+
+
+
+ {" "}
+ {status === false ? "Aktifkan" : "Non Aktifkan"}
+
+
+
- {
- router.push(`/member/edit/${id}`);
+ {
+ router.push(`/member/edit/${id}`);
+ }}
+ >
+
+
+
+
+
+ Edit
+
+
+
+
+
+ setModal(false)}
+ description="Apakah Anda yakin ingin mengubah status aktifasi anggota?"
+ onYes={(val) => {
+ nonActive(val);
}}
- >
-
-
-
-
-
- Edit
-
-
-
-
-
- setModal(false)}
- description="Apakah Anda yakin ingin mengubah status aktifasi anggota?"
- onYes={(val) => {
- nonActive(val);
- }}
- />
-
- );
+ />
+
+ );
}
diff --git a/src/module/user/member/ui/navbar_detail_member.tsx b/src/module/user/member/ui/navbar_detail_member.tsx
index 56b3fe9..c3123ab 100644
--- a/src/module/user/member/ui/navbar_detail_member.tsx
+++ b/src/module/user/member/ui/navbar_detail_member.tsx
@@ -1,19 +1,19 @@
'use client'
-import { LayoutNavbarHome, LayoutIconBack, WARNA, LayoutDrawer, SkeletonDetailProfile, globalRole, TEMA } from "@/module/_global";
-import { Box, Group, ActionIcon, Stack, Text, Center, Avatar, Skeleton, Grid } from "@mantine/core";
-import { HiMenu } from "react-icons/hi";
-import DrawerDetailMember from "./drawer_detail_member";
-import { useState } from "react";
-import { RiIdCardFill } from "react-icons/ri";
-import { FaSquarePhone } from "react-icons/fa6";
-import { MdEmail } from "react-icons/md";
-import { IoMaleFemale } from "react-icons/io5";
-import { useShallowEffect } from "@mantine/hooks";
-import { funGetOneMember } from "../lib/api_member";
-import toast from "react-hot-toast";
-import { IListMember, IMember } from "../lib/type_member";
+import { globalRole, LayoutDrawer, LayoutIconBack, LayoutNavbarHome, SkeletonDetailProfile, TEMA } from "@/module/_global";
import { useHookstate } from "@hookstate/core";
+import { ActionIcon, Avatar, Box, Center, Grid, Group, Skeleton, Stack, Text } from "@mantine/core";
+import { useShallowEffect } from "@mantine/hooks";
+import { useState } from "react";
+import toast from "react-hot-toast";
+import { FaSquarePhone } from "react-icons/fa6";
+import { HiMenu } from "react-icons/hi";
+import { IoMaleFemale } from "react-icons/io5";
+import { MdEmail } from "react-icons/md";
+import { RiIdCardFill } from "react-icons/ri";
import { valueRoleUser } from "../../lib/val_user";
+import { funGetOneMember } from "../lib/api_member";
+import { IListMember, IMember } from "../lib/type_member";
+import DrawerDetailMember from "./drawer_detail_member";
export default function NavbarDetailMember({ id }: IMember) {
diff --git a/src/module/user/profile/ui/profile.tsx b/src/module/user/profile/ui/profile.tsx
index 6a73729..c3af99e 100644
--- a/src/module/user/profile/ui/profile.tsx
+++ b/src/module/user/profile/ui/profile.tsx
@@ -1,19 +1,19 @@
"use client"
-import { LayoutIconBack, LayoutNavbarHome, SkeletonAvatar, SkeletonDetailProfile, TEMA, WARNA } from "@/module/_global";
-import { ActionIcon, Avatar, Box, Grid, Group, Skeleton, Stack, Text } from "@mantine/core";
-import { RiIdCardFill } from "react-icons/ri";
-import { FaSquarePhone } from "react-icons/fa6";
-import { MdEmail } from "react-icons/md";
-import { IoMaleFemale } from "react-icons/io5";
-import toast from "react-hot-toast";
-import { LuLogOut } from "react-icons/lu";
+import { LayoutIconBack, LayoutNavbarHome, SkeletonDetailProfile, TEMA } from "@/module/_global";
import LayoutModal from "@/module/_global/layout/layout_modal";
-import { useState } from "react";
-import { funGetProfileByCookies } from "../lib/api_profile";
-import { useShallowEffect } from "@mantine/hooks";
-import { IProfileById } from "../lib/type_profile";
-import { useRouter } from "next/navigation";
import { useHookstate } from "@hookstate/core";
+import { ActionIcon, Avatar, Box, Grid, Group, Skeleton, Stack, Text } from "@mantine/core";
+import { useShallowEffect } from "@mantine/hooks";
+import { useRouter } from "next/navigation";
+import { useState } from "react";
+import toast from "react-hot-toast";
+import { FaSquarePhone } from "react-icons/fa6";
+import { IoMaleFemale } from "react-icons/io5";
+import { LuLogOut } from "react-icons/lu";
+import { MdEmail } from "react-icons/md";
+import { RiIdCardFill } from "react-icons/ri";
+import { funGetProfileByCookies } from "../lib/api_profile";
+import { IProfileById } from "../lib/type_profile";
export default function Profile() {
const [openModal, setOpenModal] = useState(false);
@@ -22,6 +22,7 @@ export default function Profile() {
const [loading, setLoading] = useState(true)
const [img, setIMG] = useState()
const tema = useHookstate(TEMA)
+ const [loadingModal, setLoadingModal] = useState(false)
async function getData() {
try {
@@ -44,17 +45,19 @@ export default function Profile() {
async function onLogout(val: boolean) {
try {
if (val) {
+ setLoadingModal(true)
await fetch('/api/auth/logout', {
method: 'DELETE',
});
toast.success('Logout Sukses')
window.location.href = '/';
}
-
- setOpenModal(false)
-
} catch (error) {
console.error(error);
+ toast.error("Logout gagal, coba lagi nanti");
+ } finally {
+ setLoadingModal(false)
+ setOpenModal(false)
}
}
return (
@@ -72,12 +75,12 @@ export default function Profile() {
justify="center"
gap="xs"
>
- {loading ? :
-
+ {loading ? :
+
}
{/* */}
{loading ?
@@ -150,7 +153,7 @@ export default function Profile() {
}
- setOpenModal(false)}
+ setOpenModal(false)}
description="Apakah Anda yakin ingin keluar?"
onYes={(val) => onLogout(val)} />
>