fix: divisi

Deskripsi:
- tampilan kosong saat list grid
- tombol back pada detail divisi
- format tgl pada input laporan divisi
- format desimal pada chart progres tugas laporan divisi
- perbaikan kata event pada laporan divisi
- perbaikan inputan grup pada laporan divisi yg hanya bisa di akses oleh super admin
- perbaikan kalimat belum ada menjadi tidak ada
- menampilkan hanya user dg role coadmin dan user aja saat tambah anggota divisi
- perbaikan pencarian
- loading saat tambah anggota
- tidak memmakai skeleton pada saat hapus dan ganti sstatus admin divisi
- saat edit berhasil maka diarahkan ke halaman detail info divisi
- perbaikan saat bilangan desimal 100.00 pada halaman home

No Issues
This commit is contained in:
amel
2024-11-01 16:59:04 +08:00
parent 8f6e2307bb
commit 47e8718276
18 changed files with 319 additions and 276 deletions

View File

@@ -8,14 +8,20 @@ export async function GET(request: Request) {
try { try {
const user = await funGetUserByCookies() const user = await funGetUserByCookies()
const { searchParams } = new URL(request.url) const { searchParams } = new URL(request.url)
const group = searchParams.get("group") const idGroup = searchParams.get("group")
const division = searchParams.get("division") const division = searchParams.get("division")
const date = searchParams.get("date") const date = searchParams.get("date")
let grup
if (user.id == undefined) { if (user.id == undefined) {
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 }) return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 })
} }
if (idGroup == "null" || idGroup == undefined || idGroup == "") {
grup = user.idGroup
} else {
grup = idGroup
}
// CHART PROGRESS // CHART PROGRESS
let kondisiProgress let kondisiProgress
@@ -26,7 +32,7 @@ export async function GET(request: Request) {
lte: new Date(String(date)) lte: new Date(String(date))
}, },
Division: { Division: {
idGroup: String(group) idGroup: String(grup)
} }
} }
} else { } else {
@@ -52,9 +58,10 @@ export async function GET(request: Request) {
const cek = data.some((i: any) => i.status == dataStatus[index].status) const cek = data.some((i: any) => i.status == dataStatus[index].status)
if (cek) { 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 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 != "100.00" ? find.substr(-2, 2) == "00" ? find.substr(0, 2) : find : "100"
input = { input = {
name: dataStatus[index].name, name: dataStatus[index].name,
value: find value: fix
} }
} else { } else {
input = { input = {
@@ -75,7 +82,7 @@ export async function GET(request: Request) {
isActive: true, isActive: true,
category: 'FILE', category: 'FILE',
Division: { Division: {
idGroup: String(group) idGroup: String(grup)
}, },
createdAt: { createdAt: {
lte: new Date(String(date)) lte: new Date(String(date))
@@ -137,7 +144,7 @@ export async function GET(request: Request) {
kondisiEvent = { kondisiEvent = {
isActive: true, isActive: true,
Division: { Division: {
idGroup: String(group) idGroup: String(grup)
}, },
dateStart: new Date(String(date)) dateStart: new Date(String(date))
} }

View File

@@ -185,7 +185,7 @@ export async function GET(request: Request) {
const cek = data.some((i: any) => i.status == dataStatus[index].status) const cek = data.some((i: any) => i.status == dataStatus[index].status)
if (cek) { 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 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 const fix = find != "100.00" ? find.substr(-2, 2) == "00" ? find.substr(0, 2) : find : "100"
input = { input = {
name: dataStatus[index].name, name: dataStatus[index].name,
value: fix value: fix

View File

@@ -50,6 +50,7 @@ export async function GET(request: Request) {
}, },
select: { select: {
id: true, id: true,
idUserRole: true,
isActive: true, isActive: true,
nik: true, nik: true,
name: true, name: true,
@@ -92,6 +93,7 @@ export async function GET(request: Request) {
}, },
select: { select: {
id: true, id: true,
idUserRole: true,
isActive: true, isActive: true,
nik: true, nik: true,
name: true, name: true,

View File

@@ -28,7 +28,8 @@ export default function CreateAnggotaDivision() {
const [loading, setLoading] = useState(true) const [loading, setLoading] = useState(true)
const [onClickSearch, setOnClickSearch] = useState(false) const [onClickSearch, setOnClickSearch] = useState(false)
const tema = useHookstate(TEMA) const tema = useHookstate(TEMA)
const isMobile2 = useMediaQuery("(max-width: 438px)"); const isMobile2 = useMediaQuery("(max-width: 438px)")
const [loadingModal, setLoadingModal] = useState(false)
const handleFileClick = (index: number) => { const handleFileClick = (index: number) => {
if (selectedFiles.some((i: any) => i.idUser == dataMember[index].id)) { if (selectedFiles.some((i: any) => i.idUser == dataMember[index].id)) {
@@ -44,16 +45,25 @@ export default function CreateAnggotaDivision() {
async function loadMember(group: string, search: string) { async function loadMember(group: string, search: string) {
setLoading(true) try {
const res = await funGetAllmember('?active=true&group=' + group + '&search=' + search); setLoading(true)
const user = await funGetUserByCookies(); const res = await funGetAllmember('?active=true&group=' + group + '&search=' + search);
const user = await funGetUserByCookies();
if (res.success) { if (res.success) {
setDataMember(res.data.filter((i: any) => i.id != user.id)) const dariUserLogin = res.data.filter((i: any) => i.id != user.id)
} else { const fixListUser = dariUserLogin.filter((i: any) => i.idUserRole == 'coadmin' || i.idUserRole == 'user')
toast.error(res.message) setDataMember(fixListUser)
} else {
toast.error(res.message)
}
} catch (error) {
console.error(error)
toast.error("Gagal memuat data, coba lagi nanti")
} finally {
setLoading(false)
} }
setLoading(false)
} }
async function loadFirst() { async function loadFirst() {
@@ -69,6 +79,7 @@ export default function CreateAnggotaDivision() {
async function addMember() { async function addMember() {
try { try {
setLoadingModal(true)
const res = await funAddDivisionMember(param.id, selectedFiles) const res = await funAddDivisionMember(param.id, selectedFiles)
if (res.success) { if (res.success) {
toast.success(res.message) toast.success(res.message)
@@ -76,15 +87,22 @@ export default function CreateAnggotaDivision() {
} else { } else {
toast.error(res.message) toast.error(res.message)
} }
setOpen(false)
} catch (error) { } catch (error) {
setOpen(false)
console.error(error); console.error(error);
toast.error("Gagal menambahkan anggota divisi, coba lagi nanti"); toast.error("Gagal menambahkan anggota divisi, coba lagi nanti");
} finally {
setLoadingModal(false)
setOpen(false)
} }
} }
function onCheck() {
if (selectedFiles.length == 0) {
return toast.error("Error! silahkan pilih anggota")
}
setOpen(true)
}
useShallowEffect(() => { useShallowEffect(() => {
loadFirst() loadFirst()
@@ -149,7 +167,7 @@ export default function CreateAnggotaDivision() {
borderBottom: `1px solid ${"#E0DFDF"}` borderBottom: `1px solid ${"#E0DFDF"}`
}}> }}>
{selectedFiles.length > 0 ? ( {selectedFiles.length > 0 ? (
<Carousel dragFree slideGap={"xs"} align="start" slideSize={"xs"} withControls={false}> <Carousel dragFree slideGap={"xs"} align="start" slideSize={"xs"} withControls={false}>
{selectedFiles.map((v: any, i: any) => { {selectedFiles.map((v: any, i: any) => {
return ( return (
<Carousel.Slide key={i}> <Carousel.Slide key={i}>
@@ -195,51 +213,51 @@ export default function CreateAnggotaDivision() {
<Text c="dimmed" ta={"center"} fs={"italic"}>Tidak ada anggota</Text> <Text c="dimmed" ta={"center"} fs={"italic"}>Tidak ada anggota</Text>
</Stack> </Stack>
: :
<Box pt={90} mb={100}> <Box pt={90} mb={100}>
{dataMember.map((v: any, index: any) => { {dataMember.map((v: any, index: any) => {
const isSelected = selectedFiles.some((i: any) => i.idUser == dataMember[index].id) const isSelected = selectedFiles.some((i: any) => i.idUser == dataMember[index].id)
const found = memberDb.some((i: any) => i.idUser == v.id) const found = memberDb.some((i: any) => i.idUser == v.id)
return ( return (
<Box my={10} key={index} onClick={() => (!found) ? handleFileClick(index) : null}> <Box my={10} key={index} onClick={() => (!found) ? handleFileClick(index) : null}>
<Grid align='center' > <Grid align='center' >
<Grid.Col <Grid.Col
span={{ span={{
base: 1, base: 1,
xs: 1, xs: 1,
sm: 1, sm: 1,
md: 1, md: 1,
lg: 1, lg: 1,
xl: 1, xl: 1,
}} }}
> >
<Avatar src={`https://wibu-storage.wibudev.com/api/files/${v.img}`} alt="it's me" size="lg" /> <Avatar src={`https://wibu-storage.wibudev.com/api/files/${v.img}`} alt="it's me" size="lg" />
</Grid.Col> </Grid.Col>
<Grid.Col <Grid.Col
span={{ span={{
base: 11, base: 11,
xs: 11, xs: 11,
sm: 11, sm: 11,
md: 11, md: 11,
lg: 11, lg: 11,
xl: 11, xl: 11,
}} }}
> >
<Flex justify='space-between' align={"center"}> <Flex justify='space-between' align={"center"}>
<Flex direction={'column'} align="flex-start" justify="flex-start"> <Flex direction={'column'} align="flex-start" justify="flex-start">
<Text pl={isMobile2 ? 40 : 30} lineClamp={1}>{v.name}</Text> <Text pl={isMobile2 ? 40 : 30} lineClamp={1}>{v.name}</Text>
<Text pl={isMobile2 ? 40 : 30} c={"dimmed"} lineClamp={1}>{(found) ? "sudah menjadi anggota divisi" : ""}</Text> <Text pl={isMobile2 ? 40 : 30} c={"dimmed"} lineClamp={1}>{(found) ? "sudah menjadi anggota divisi" : ""}</Text>
</Flex>
{isSelected ? <FaCheck /> : null}
</Flex> </Flex>
{isSelected ? <FaCheck /> : null} </Grid.Col>
</Flex> </Grid>
</Grid.Col> <Box mt={10}>
</Grid> <Divider size={"xs"} />
<Box mt={10}> </Box>
<Divider size={"xs"} />
</Box> </Box>
</Box> )
) })}
})} </Box>
</Box>
} }
</Box> </Box>
<Box pos={'fixed'} bottom={0} p={rem(20)} w={"100%"} style={{ <Box pos={'fixed'} bottom={0} p={rem(20)} w={"100%"} style={{
@@ -253,12 +271,12 @@ export default function CreateAnggotaDivision() {
size="lg" size="lg"
radius={30} radius={30}
fullWidth fullWidth
onClick={() => { setOpen(true) }} onClick={() => { onCheck() }}
> >
Simpan Simpan
</Button> </Button>
</Box> </Box>
<LayoutModal opened={isOpen} onClose={() => setOpen(false)} <LayoutModal loading={loadingModal} opened={isOpen} onClose={() => setOpen(false)}
description="Apakah Anda yakin ingin menambahkan anggota divisi?" description="Apakah Anda yakin ingin menambahkan anggota divisi?"
onYes={(val) => { onYes={(val) => {
if (val) { if (val) {

View File

@@ -1,19 +1,18 @@
"use client"; "use client";
import { LayoutNavbarNew, TEMA } from "@/module/_global"; import { globalRole, LayoutNavbarNew, TEMA } from "@/module/_global";
import { Box, Select, Skeleton, Stack, Text } from "@mantine/core";
import { DateInput } from "@mantine/dates";
import React, { useState } from "react";
import EchartPaiReport from "./echart_pai_report";
import EchartBarReport from "./echart_bar_report";
import EventReport from "./event_report";
import DiscussionReport from "./discussion_report";
import { funGetAllGroup, IDataGroup } from "@/module/group"; import { funGetAllGroup, IDataGroup } from "@/module/group";
import toast from "react-hot-toast";
import { useShallowEffect } from "@mantine/hooks";
import { funGetReportDivision } from "../lib/api_division";
import { useParams } from "next/navigation";
import moment from "moment";
import { useHookstate } from "@hookstate/core"; import { useHookstate } from "@hookstate/core";
import { Box, Select, Skeleton, Stack } from "@mantine/core";
import { DateInput } from "@mantine/dates";
import { useShallowEffect } from "@mantine/hooks";
import moment from "moment";
import { useParams } from "next/navigation";
import { useState } from "react";
import toast from "react-hot-toast";
import { funGetReportDivision } from "../lib/api_division";
import EchartBarReport from "./echart_bar_report";
import EchartPaiReport from "./echart_pai_report";
import EventReport from "./event_report";
export default function CreateReport() { export default function CreateReport() {
const [value, setValue] = useState<Date | null>(null); const [value, setValue] = useState<Date | null>(null);
@@ -23,6 +22,7 @@ export default function CreateReport() {
const [isGroup, setIsGroup] = useState(""); const [isGroup, setIsGroup] = useState("");
const param = useParams<{ id: string }>() const param = useParams<{ id: string }>()
const tema = useHookstate(TEMA) const tema = useHookstate(TEMA)
const roleLogin = useHookstate(globalRole)
const [report, setReport] = useState({ const [report, setReport] = useState({
progress: [], progress: [],
dokumen: [], dokumen: [],
@@ -74,13 +74,20 @@ export default function CreateReport() {
} }
function onChangeDate(val: any) { function onChangeDate(val: any) {
if (val != null && val != "" && isGroup != "" && isGroup != "null") {
onReport(isGroup, val)
}
if (isGroup == null || isGroup == "") { if (roleLogin.get() == "supadmin") {
setTampil(false) if (val != null && val != "" && isGroup != "" && isGroup != "null") {
toast.error("Error! harus memilih grup") onReport(isGroup, val)
}
if (isGroup == null || isGroup == "") {
setTampil(false)
toast.error("Error! harus memilih grup")
}
} else {
if (val != null && val != "") {
onReport(isGroup, val)
}
} }
setValue(val) setValue(val)
@@ -95,19 +102,23 @@ export default function CreateReport() {
<LayoutNavbarNew back="/division" title="Laporan Divisi" menu /> <LayoutNavbarNew back="/division" title="Laporan Divisi" menu />
<Box p={20}> <Box p={20}>
<Stack> <Stack>
<Select {roleLogin.get() == "supadmin" &&
placeholder="Grup" <Select
label="Grup" placeholder="Grup"
size="md" label="Grup"
required size="md"
radius={10} required
data={dataGroup?.map((pro: any) => ({ radius={10}
value: String(pro.id), data={dataGroup?.map((pro: any) => ({
label: pro.name value: String(pro.id),
}))} label: pro.name
onChange={(val) => { onChooseGroup(val) }} }))}
/> onChange={(val) => { onChooseGroup(val) }}
/>
}
<DateInput <DateInput
valueFormat="DD-MM-YYYY"
value={value} value={value}
onChange={(val) => { onChangeDate(val) }} onChange={(val) => { onChangeDate(val) }}
radius={10} radius={10}

View File

@@ -1,10 +1,9 @@
"use client" "use client"
import { TEMA } from "@/module/_global"; import { TEMA } from "@/module/_global";
import { useHookstate } from "@hookstate/core"; import { useHookstate } from "@hookstate/core";
import { Box, Stack, SimpleGrid, Flex, Text } from "@mantine/core"; import { Box, Flex, SimpleGrid, Stack, Text } from "@mantine/core";
import { useParams, useRouter } from "next/navigation"; import { useParams, useRouter } from "next/navigation";
import { BsInfoCircle } from "react-icons/bs"; import { BsInfoCircle } from "react-icons/bs";
import { FaPencil } from "react-icons/fa6";
import { TbReportAnalytics } from "react-icons/tb"; import { TbReportAnalytics } from "react-icons/tb";
export default function DrawerDetailDivision() { export default function DrawerDetailDivision() {

View File

@@ -1,11 +1,10 @@
import React, { useState } from 'react';
import { EChartsOption, color } from "echarts";
import EChartsReact from "echarts-for-react";
import { useShallowEffect } from '@mantine/hooks';
import * as echarts from 'echarts';
import { Box } from '@mantine/core';
import { TEMA } from '@/module/_global'; import { TEMA } from '@/module/_global';
import { useHookstate } from '@hookstate/core'; 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';
export default function EchartPaiReport({ data }: { data: any }) { export default function EchartPaiReport({ data }: { data: any }) {
const [options, setOptions] = useState<EChartsOption>({}); const [options, setOptions] = useState<EChartsOption>({});

View File

@@ -70,8 +70,6 @@ export default function EditDivision() {
} else { } else {
toast.error(res.message); toast.error(res.message);
} }
setLoading(false);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
toast.error("Gagal mendapatkan divisi, coba lagi nanti"); toast.error("Gagal mendapatkan divisi, coba lagi nanti");
@@ -87,6 +85,7 @@ export default function EditDivision() {
const res = await funEditDivision(param.id, body) const res = await funEditDivision(param.id, body)
if (res.success) { if (res.success) {
toast.success(res.message) toast.success(res.message)
router.push("/division/info/" + param.id)
} else { } else {
toast.error(res.message) toast.error(res.message)
} }

View File

@@ -1,8 +1,7 @@
import { Box, Divider, Group, ScrollArea, Stack, Text } from '@mantine/core'; import { Box, Divider, Group, Text } from '@mantine/core';
import React from 'react';
import { IDataReportDivision } from '../lib/type_division';
import _ from 'lodash'; import _ from 'lodash';
import { useRouter } from 'next/navigation'; import { useRouter } from 'next/navigation';
import { IDataReportDivision } from '../lib/type_division';
export default function EventReport({ data, tgl }: { data: IDataReportDivision[], tgl: string }) { export default function EventReport({ data, tgl }: { data: IDataReportDivision[], tgl: string }) {
const router = useRouter() const router = useRouter()
@@ -14,7 +13,7 @@ export default function EventReport({ data, tgl }: { data: IDataReportDivision[]
_.isEmpty(data) _.isEmpty(data)
? ?
<Box style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '20vh' }}> <Box style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '20vh' }}>
<Text c="dimmed" ta={"center"} fs={"italic"}>Tidak ada event</Text> <Text c="dimmed" ta={"center"} fs={"italic"}>Tidak ada acara</Text>
</Box> </Box>
: :
data.map((event, index) => { data.map((event, index) => {

View File

@@ -37,10 +37,11 @@ export default function InformationDivision() {
const isMobile2 = useMediaQuery("(max-width: 438px)"); const isMobile2 = useMediaQuery("(max-width: 438px)");
const tema = useHookstate(TEMA) const tema = useHookstate(TEMA)
const [loadingStatus, setLoadingStatus] = useState(false) const [loadingStatus, setLoadingStatus] = useState(false)
const [loadingDelete, setLoadingDelete] = useState(false)
async function getOneData() { async function getOneData(loading: boolean) {
try { try {
setLoading(true); setLoading(loading)
const res = await funGetDivisionById(param.id); const res = await funGetDivisionById(param.id);
const login = await funGetUserByCookies() const login = await funGetUserByCookies()
if (res.success) { if (res.success) {
@@ -53,18 +54,17 @@ export default function InformationDivision() {
} else { } else {
toast.error(res.message); toast.error(res.message);
} }
setLoading(false);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
toast.error("Gagal mendapatkan divisi, coba lagi nanti"); toast.error("Gagal mendapatkan divisi, coba lagi nanti");
} finally { } finally {
setLoading(false); setLoading(false)
} }
} }
useShallowEffect(() => { useShallowEffect(() => {
getOneData(); getOneData(true);
}, [param.id]) }, [param.id])
@@ -77,19 +77,21 @@ export default function InformationDivision() {
async function deleteMember() { async function deleteMember() {
try { try {
setLoadingDelete(true)
const res = await funDeleteMemberDivision(param.id, { id: valChooseMember }) const res = await funDeleteMemberDivision(param.id, { id: valChooseMember })
if (res.success) { if (res.success) {
toast.success(res.message) toast.success(res.message)
setDrawer(false) setDrawer(false)
getOneData() getOneData(false)
} else { } else {
toast.error(res.message) toast.error(res.message)
} }
setOpenModal(false)
} catch (error) { } catch (error) {
console.error(error); console.error(error);
setOpenModal(false)
toast.error("Gagal mendapatkan divisi, coba lagi nanti"); toast.error("Gagal mendapatkan divisi, coba lagi nanti");
} finally {
setLoadingDelete(false)
setOpenModal(false)
} }
} }
@@ -99,7 +101,7 @@ export default function InformationDivision() {
const res = await funEditStatusAdminDivision(param.id, { id: valChooseMember, isAdmin: valChooseMemberStatus }) const res = await funEditStatusAdminDivision(param.id, { id: valChooseMember, isAdmin: valChooseMemberStatus })
if (res.success) { if (res.success) {
toast.success(res.message) toast.success(res.message)
getOneData() getOneData(false)
} else { } else {
toast.error(res.message) toast.error(res.message)
} }
@@ -116,7 +118,7 @@ export default function InformationDivision() {
const res = await funUpdateStatusDivision(param.id, { isActive: valActive }) const res = await funUpdateStatusDivision(param.id, { isActive: valActive })
if (res.success) { if (res.success) {
toast.success(res.message) toast.success(res.message)
getOneData() getOneData(false)
} else { } else {
toast.error(res.message) toast.error(res.message)
} }
@@ -276,7 +278,7 @@ export default function InformationDivision() {
</Box> </Box>
</LayoutDrawer> </LayoutDrawer>
<LayoutModal opened={isOpenModal} onClose={() => setOpenModal(false)} <LayoutModal loading={loadingDelete} opened={isOpenModal} onClose={() => setOpenModal(false)}
description="Apakah Anda yakin ingin mengeluarkan anggota?" description="Apakah Anda yakin ingin mengeluarkan anggota?"
onYes={(val) => { onYes={(val) => {
if (!val) { if (!val) {

View File

@@ -1,15 +1,15 @@
"use client" "use client"
import { TEMA } from "@/module/_global"; import { TEMA } from "@/module/_global";
import { useHookstate } from "@hookstate/core";
import { Box, Grid, Group, Skeleton, Stack, Text } from "@mantine/core"; import { Box, Grid, Group, Skeleton, Stack, Text } from "@mantine/core";
import { useMediaQuery, useShallowEffect } from "@mantine/hooks"; import { useMediaQuery, useShallowEffect } from "@mantine/hooks";
import { useParams, useRouter } from "next/navigation"; import { useParams, useRouter } from "next/navigation";
import { useState } from "react"; import { useState } from "react";
import toast from "react-hot-toast"; import toast from "react-hot-toast";
import { CiUser, CiClock2 } from "react-icons/ci"; import { CiClock2, CiUser } from "react-icons/ci";
import { GoDiscussionClosed } from "react-icons/go"; import { GoDiscussionClosed } from "react-icons/go";
import { funGetDetailDivisionById } from "../lib/api_division"; import { funGetDetailDivisionById } from "../lib/api_division";
import { IDataDiscussionOnDetailDivision } from "../lib/type_division"; import { IDataDiscussionOnDetailDivision } from "../lib/type_division";
import { useHookstate } from "@hookstate/core";
export default function ListDiscussionOnDetailDivision() { export default function ListDiscussionOnDetailDivision() {
@@ -30,7 +30,6 @@ export default function ListDiscussionOnDetailDivision() {
} else { } else {
toast.error(res.message); toast.error(res.message);
} }
setLoading(false);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
toast.error("Gagal mendapatkan divisi, coba lagi nanti"); toast.error("Gagal mendapatkan divisi, coba lagi nanti");
@@ -49,106 +48,108 @@ export default function ListDiscussionOnDetailDivision() {
<Text c={tema.get().utama} mb={10} fw={"bold"} fz={16}> <Text c={tema.get().utama} mb={10} fw={"bold"} fz={16}>
Diskusi Terbaru Diskusi Terbaru
</Text> </Text>
<Box {
bg={"white"} !loading && data.length === 0 ?
style={{ <Stack align="stretch" justify="center" w={"100%"}>
borderRadius: 10, <Text c="dimmed" ta={"center"} fs={"italic"}>Tidak ada diskusi</Text>
border: `1px solid ${"#D6D8F6"}`, </Stack>
padding: 10, :
}} <Box
> bg={"white"}
style={{
borderRadius: 10,
border: `1px solid ${"#D6D8F6"}`,
padding: 10,
}}
>
{ {
loading ? loading ?
Array(2) Array(2)
.fill(null) .fill(null)
.map((_, i) => ( .map((_, i) => (
<Stack align="stretch" justify="center" key={i} pb={10}> <Stack align="stretch" justify="center" key={i} pb={10}>
<Skeleton height={80} radius="md" m={0} /> <Skeleton height={80} radius="md" m={0} />
<Group justify="space-between"> <Group justify="space-between">
<Skeleton height={10} radius="md" m={0} w={100} /> <Skeleton height={10} radius="md" m={0} w={100} />
<Skeleton height={10} radius="md" m={0} w={100} /> <Skeleton height={10} radius="md" m={0} w={100} />
</Group> </Group>
</Stack> </Stack>
)) ))
: : <></>
(data.length === 0) ? }
<Stack align="stretch" justify="center" w={"100%"}> {data.map((v, i) => {
<Text c="dimmed" ta={"center"} fs={"italic"}>Belum ada diskusi</Text> return (
</Stack> <Box key={i} p={10}>
: <></> <Box style={{
} borderRadius: 10,
{data.map((v, i) => { border: `1px solid ${"#D6D8F6"}`,
return ( padding: 10,
<Box key={i} p={10}> }}
<Box style={{ onClick={() => router.push(`${param.id}/discussion/${v.id}`)}
borderRadius: 10,
border: `1px solid ${"#D6D8F6"}`,
padding: 10,
}}
onClick={() => router.push(`${param.id}/discussion/${v.id}`)}
>
<Grid align='center'>
<Grid.Col
span={{
base: 1,
xs: 1,
sm: 1,
md: 1,
lg: 1,
xl: 1,
}}
> >
<GoDiscussionClosed size={25} /> <Grid align='center'>
</Grid.Col> <Grid.Col
<Grid.Col span={{
span={{ base: 1,
base: 11, xs: 1,
xs: 11, sm: 1,
sm: 11, md: 1,
md: 11, lg: 1,
lg: 11, xl: 1,
xl: 11, }}
}} >
> <GoDiscussionClosed size={25} />
<Text fw={"bold"} truncate="end" pl={isMobile2 ? 10 : 0} fz={isMobile ? 14 : 16}> </Grid.Col>
{v.desc} <Grid.Col
</Text> span={{
</Grid.Col> base: 11,
</Grid> xs: 11,
<Grid align="center" mt={20}> sm: 11,
<Grid.Col span={{ md: 11,
base: 7, lg: 11,
xl: 9 xl: 11,
}}> }}
<Group gap={5} align="center"> >
<CiUser size={18} /> <Text fw={"bold"} truncate="end" pl={isMobile2 ? 10 : 0} fz={isMobile ? 14 : 16}>
<Box w={{ {v.desc}
base: isMobile ? 110 : 125,
xl: 300
}}>
<Text fz={13} lineClamp={1}>
{v.user}
</Text> </Text>
</Box> </Grid.Col>
</Group> </Grid>
</Grid.Col> <Grid align="center" mt={20}>
<Grid.Col span={{ <Grid.Col span={{
base: 5, base: 7,
xl: 3 xl: 9
}}> }}>
<Group gap={5} align="center" justify="flex-end"> <Group gap={5} align="center">
<CiClock2 size={18} /> <CiUser size={18} />
<Text fz={isMobile ? 11 : 13}>{v.date}</Text> <Box w={{
</Group> base: isMobile ? 110 : 125,
</Grid.Col> xl: 300
</Grid> }}>
</Box> <Text fz={13} lineClamp={1}>
</Box> {v.user}
</Text>
</Box>
</Group>
</Grid.Col>
<Grid.Col span={{
base: 5,
xl: 3
}}>
<Group gap={5} align="center" justify="flex-end">
<CiClock2 size={18} />
<Text fz={isMobile ? 11 : 13}>{v.date}</Text>
</Group>
</Grid.Col>
</Grid>
</Box>
</Box>
); );
})} })}
</Box> </Box>
}
</Box> </Box>
</> </>
); );

View File

@@ -1,5 +1,5 @@
'use client' 'use client'
import { currentScroll, globalNotifPage, globalRole, LayoutDrawer, LayoutNavbarNew, ReloadButtonTop, SkeletonList, TEMA } from '@/module/_global'; import { currentScroll, globalNotifPage, globalRole, ReloadButtonTop, SkeletonList, TEMA } from '@/module/_global';
import { useHookstate } from '@hookstate/core'; import { useHookstate } from '@hookstate/core';
import { ActionIcon, Avatar, Box, Card, Center, Divider, Flex, Grid, Group, Skeleton, Text, TextInput, Title } from '@mantine/core'; import { ActionIcon, Avatar, Box, Card, Center, Divider, Flex, Grid, Group, Skeleton, Text, TextInput, Title } from '@mantine/core';
import { useMediaQuery, useShallowEffect } from '@mantine/hooks'; import { useMediaQuery, useShallowEffect } from '@mantine/hooks';
@@ -7,12 +7,10 @@ import _ from 'lodash';
import { useRouter, useSearchParams } from 'next/navigation'; import { useRouter, useSearchParams } 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 { HiMenu } from 'react-icons/hi';
import { HiMagnifyingGlass, HiMiniUserGroup, HiOutlineListBullet, HiSquares2X2 } from 'react-icons/hi2'; import { HiMagnifyingGlass, HiMiniUserGroup, HiOutlineListBullet, HiSquares2X2 } from 'react-icons/hi2';
import { MdAccountCircle } from 'react-icons/md'; import { MdAccountCircle } from 'react-icons/md';
import { funGetAllDivision } from '../lib/api_division'; import { funGetAllDivision } from '../lib/api_division';
import { IDataDivison } from '../lib/type_division'; import { IDataDivison } from '../lib/type_division';
import DrawerDivision from './drawer_division';
export default function ListDivision() { export default function ListDivision() {
const [isList, setIsList] = useState(false) const [isList, setIsList] = useState(false)
@@ -243,36 +241,42 @@ export default function ListDivision() {
</Box> </Box>
)) ))
: :
data?.map((v: any, i: any) => { _.isEmpty(data)
return ( ?
<Box key={i} mb={20}> <Box style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '50vh' }}>
<Card shadow="sm" padding="md" component="a" radius={10} onClick={() => router.push(`/division/${v.id}`)}> <Text c="dimmed" ta={"center"} fs={"italic"}>Tidak ada Divisi</Text>
<Card.Section> </Box>
<Box h={120} bg={tema.get().utama}> :
<Flex justify={'center'} align={'center'} h={"100%"} pl={20} pr={20}> data?.map((v: any, i: any) => {
<Title order={3} c={"white"} ta={"center"} lineClamp={2}>{v.name}</Title> return (
</Flex> <Box key={i} mb={20}>
<Card shadow="sm" padding="md" component="a" radius={10} onClick={() => router.push(`/division/${v.id}`)}>
<Card.Section>
<Box h={120} bg={tema.get().utama}>
<Flex justify={'center'} align={'center'} h={"100%"} pl={20} pr={20}>
<Title order={3} c={"white"} ta={"center"} lineClamp={2}>{v.name}</Title>
</Flex>
</Box>
</Card.Section>
<Box pt={10}>
<Text lineClamp={2}>{v.desc}</Text>
<Group align='center' pt={10} justify='flex-end'>
<Avatar.Group>
<Avatar>
<MdAccountCircle size={32} color={tema.get().utama} />
</Avatar>
<Avatar>
{
(v.jumlah_member == 0) ? "0" : "+" + (v.jumlah_member - 1)
}
</Avatar>
</Avatar.Group>
</Group>
</Box> </Box>
</Card.Section> </Card>
<Box pt={10}> </Box>
<Text lineClamp={2}>{v.desc}</Text> );
<Group align='center' pt={10} justify='flex-end'> })
<Avatar.Group>
<Avatar>
<MdAccountCircle size={32} color={tema.get().utama} />
</Avatar>
<Avatar>
{
(v.jumlah_member == 0) ? "0" : "+" + (v.jumlah_member - 1)
}
</Avatar>
</Avatar.Group>
</Group>
</Box>
</Card>
</Box>
);
})
} }
</Box> </Box>
)} )}

View File

@@ -1,15 +1,15 @@
'use client' 'use client'
import { TEMA, } from "@/module/_global"; import { TEMA, } from "@/module/_global";
import { useHookstate } from "@hookstate/core";
import { Carousel } from "@mantine/carousel"; import { Carousel } from "@mantine/carousel";
import { Box, Image, Text, Center, Paper, Stack, UnstyledButton, Skeleton, Group } from "@mantine/core"; import { Box, Center, Group, Image, Skeleton, Stack, Text, UnstyledButton } from "@mantine/core";
import * as ICON from '../lib/file_icon'
import { useParams, useRouter } from "next/navigation";
import { useMediaQuery, useShallowEffect } from "@mantine/hooks"; import { useMediaQuery, useShallowEffect } from "@mantine/hooks";
import { useParams, useRouter } from "next/navigation";
import { useState } from "react";
import toast from "react-hot-toast"; import toast from "react-hot-toast";
import { funGetDetailDivisionById } from "../lib/api_division"; import { funGetDetailDivisionById } from "../lib/api_division";
import * as ICON from '../lib/file_icon';
import { IDataKalenderOnDetailDivision } from "../lib/type_division"; import { IDataKalenderOnDetailDivision } from "../lib/type_division";
import { useState } from "react";
import { useHookstate } from "@hookstate/core";
const iconContainer = (icon: string) => 'data:image/svg+xml;base64,' + btoa(icon) const iconContainer = (icon: string) => 'data:image/svg+xml;base64,' + btoa(icon)
@@ -29,7 +29,6 @@ export default function ListDocumentOnDetailDivision() {
} else { } else {
toast.error(res.message); toast.error(res.message);
} }
setLoading(false);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
toast.error("Gagal mendapatkan divisi, coba lagi nanti"); toast.error("Gagal mendapatkan divisi, coba lagi nanti");
@@ -60,7 +59,7 @@ export default function ListDocumentOnDetailDivision() {
)) ))
: (data.length === 0) ? : (data.length === 0) ?
<Stack align="stretch" justify="center" w={"100%"}> <Stack align="stretch" justify="center" w={"100%"}>
<Text c="dimmed" ta={"center"} fs={"italic"}>Belum ada file</Text> <Text c="dimmed" ta={"center"} fs={"italic"}>Tidak ada dokumen</Text>
</Stack> </Stack>
: <></> : <></>
} }

View File

@@ -1,16 +1,15 @@
'use client' 'use client'
import { TEMA } from "@/module/_global"; import { TEMA } from "@/module/_global";
import { useHookstate } from "@hookstate/core";
import { Carousel } from "@mantine/carousel"; import { Carousel } from "@mantine/carousel";
import { Avatar, Box, Group, Skeleton, Stack, Text } from "@mantine/core"; import { Box, Group, Skeleton, Stack, Text } from "@mantine/core";
import { useMediaQuery, useShallowEffect } from "@mantine/hooks"; import { useMediaQuery, useShallowEffect } from "@mantine/hooks";
import { useParams, useRouter } from "next/navigation"; import { useParams, useRouter } from "next/navigation";
import { useState } from "react";
import toast from "react-hot-toast"; import toast from "react-hot-toast";
import { CiClock2 } from "react-icons/ci"; import { CiClock2 } from "react-icons/ci";
import { funGetDetailDivisionById } from "../lib/api_division"; import { funGetDetailDivisionById } from "../lib/api_division";
import { useState } from "react";
import { IDataTaskOnDetailDivision } from "../lib/type_division"; import { IDataTaskOnDetailDivision } from "../lib/type_division";
import _ from "lodash";
import { useHookstate } from "@hookstate/core";
export default function ListTaskOnDetailDivision() { export default function ListTaskOnDetailDivision() {
@@ -29,7 +28,6 @@ export default function ListTaskOnDetailDivision() {
} else { } else {
toast.error(res.message); toast.error(res.message);
} }
setLoading(false);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
toast.error("Gagal mendapatkan divisi, coba lagi nanti"); toast.error("Gagal mendapatkan divisi, coba lagi nanti");
@@ -61,7 +59,7 @@ export default function ListTaskOnDetailDivision() {
: :
(data.length === 0) ? (data.length === 0) ?
<Stack align="stretch" justify="center" w={"100%"}> <Stack align="stretch" justify="center" w={"100%"}>
<Text c="dimmed" ta={"center"} fs={"italic"}>Belum ada tugas hari ini</Text> <Text c="dimmed" ta={"center"} fs={"italic"}>Tidak ada tugas hari ini</Text>
</Stack> </Stack>
: <></> : <></>
} }

View File

@@ -1,5 +1,5 @@
'use client' 'use client'
import { LayoutDrawer, LayoutNavbarNew, TEMA } from "@/module/_global"; import { globalRole, LayoutDrawer, LayoutNavbarNew, TEMA } from "@/module/_global";
import { useHookstate } from "@hookstate/core"; import { useHookstate } from "@hookstate/core";
import { ActionIcon } from "@mantine/core"; import { ActionIcon } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks"; import { useShallowEffect } from "@mantine/hooks";
@@ -15,12 +15,16 @@ export default function NavbarDetailDivision() {
const param = useParams<{ id: string }>() const param = useParams<{ id: string }>()
const [name, setName] = useState('') const [name, setName] = useState('')
const tema = useHookstate(TEMA) const tema = useHookstate(TEMA)
const roleLogin = useHookstate(globalRole)
const [grup, setGroup] = useState('')
async function getOneData() { async function getOneData() {
try { try {
const res = await funGetDivisionById(param.id); const res = await funGetDivisionById(param.id);
if (res.success) { if (res.success) {
setName(res.data.division.name); setName(res.data.division.name);
setGroup(res.data.division.idGroup)
} else { } else {
toast.error(res.message); toast.error(res.message);
} }
@@ -37,7 +41,7 @@ export default function NavbarDetailDivision() {
return ( return (
<> <>
<LayoutNavbarNew back="" title={name} menu={ <LayoutNavbarNew back={roleLogin.get() == 'supadmin' ? `/division?group=${grup}` : '/division'} title={name} menu={
<ActionIcon variant="light" onClick={() => (setOpenDrawer(true))} bg={tema.get().bgIcon} size="lg" radius="lg" aria-label="Settings"> <ActionIcon variant="light" onClick={() => (setOpenDrawer(true))} bg={tema.get().bgIcon} size="lg" radius="lg" aria-label="Settings">
<HiMenu size={20} color='white' /> <HiMenu size={20} color='white' />
</ActionIcon> </ActionIcon>

View File

@@ -1,18 +1,17 @@
"use client" "use client"
import { LayoutNavbarNew, TEMA } from '@/module/_global'; import { LayoutNavbarNew, TEMA } from '@/module/_global';
import { useHookstate } from '@hookstate/core';
import { Box, Skeleton, Stack } from '@mantine/core'; import { Box, Skeleton, Stack } from '@mantine/core';
import { DateInput } from '@mantine/dates'; import { DateInput } from '@mantine/dates';
import React, { useState } from 'react';
import EchartPaiReport from './echart_pai_report';
import EchartBarReport from './echart_bar_report';
import EventReport from './event_report';
import DiscussionReport from './discussion_report';
import { useParams } from 'next/navigation';
import { funGetReportDivision } from '../lib/api_division';
import moment from 'moment'; import moment from 'moment';
import "moment/locale/id"; import "moment/locale/id";
import { useParams } from 'next/navigation';
import { useState } from 'react';
import toast from 'react-hot-toast'; import toast from 'react-hot-toast';
import { useHookstate } from '@hookstate/core'; import { funGetReportDivision } from '../lib/api_division';
import EchartBarReport from './echart_bar_report';
import EchartPaiReport from './echart_pai_report';
import EventReport from './event_report';
export default function ReportDivisionId() { export default function ReportDivisionId() {
@@ -64,6 +63,7 @@ export default function ReportDivisionId() {
<Box p={20}> <Box p={20}>
<Stack> <Stack>
<DateInput <DateInput
valueFormat='DD-MM-YYYY'
value={value} value={value}
onChange={(val) => { onChangeDate(val) }} onChange={(val) => { onChangeDate(val) }}
radius={10} radius={10}

View File

@@ -1,11 +1,12 @@
export type TypeUser = { export type TypeUser = {
id: string id: string
idUserRole: string
name: string name: string
nik: string nik: string
phone: string phone: string
email: string email: string
gender: string gender: string
img:string img: string
isActive: boolean, isActive: boolean,
group: string, group: string,
position: string position: string

View File

@@ -1,4 +1,4 @@
import { IEditDataMember, IFormMember, IStatusmember } from "./type_member"; import { IStatusmember } from "./type_member";
export const funGetAllmember = async (path?: string) => { export const funGetAllmember = async (path?: string) => {
const response = await fetch(`/api/user${(path) ? path : ''}`, { next: { tags: ['member'] } }); const response = await fetch(`/api/user${(path) ? path : ''}`, { next: { tags: ['member'] } });