Merge pull request #324 from bipproduction/amalia/01-nov-24
fix: divisi
This commit is contained in:
@@ -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))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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,18 +45,27 @@ export default function CreateAnggotaDivision() {
|
|||||||
|
|
||||||
|
|
||||||
async function loadMember(group: string, search: string) {
|
async function loadMember(group: string, search: string) {
|
||||||
|
try {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
const res = await funGetAllmember('?active=true&group=' + group + '&search=' + search);
|
const res = await funGetAllmember('?active=true&group=' + group + '&search=' + search);
|
||||||
const user = await funGetUserByCookies();
|
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)
|
||||||
|
const fixListUser = dariUserLogin.filter((i: any) => i.idUserRole == 'coadmin' || i.idUserRole == 'user')
|
||||||
|
setDataMember(fixListUser)
|
||||||
} else {
|
} else {
|
||||||
toast.error(res.message)
|
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() {
|
||||||
const respon = await funGetDivisionById(param.id);
|
const respon = await funGetDivisionById(param.id);
|
||||||
if (respon.success) {
|
if (respon.success) {
|
||||||
@@ -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()
|
||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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,6 +74,8 @@ export default function CreateReport() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onChangeDate(val: any) {
|
function onChangeDate(val: any) {
|
||||||
|
|
||||||
|
if (roleLogin.get() == "supadmin") {
|
||||||
if (val != null && val != "" && isGroup != "" && isGroup != "null") {
|
if (val != null && val != "" && isGroup != "" && isGroup != "null") {
|
||||||
onReport(isGroup, val)
|
onReport(isGroup, val)
|
||||||
}
|
}
|
||||||
@@ -82,6 +84,11 @@ export default function CreateReport() {
|
|||||||
setTampil(false)
|
setTampil(false)
|
||||||
toast.error("Error! harus memilih grup")
|
toast.error("Error! harus memilih grup")
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (val != null && val != "") {
|
||||||
|
onReport(isGroup, val)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setValue(val)
|
setValue(val)
|
||||||
}
|
}
|
||||||
@@ -95,6 +102,7 @@ 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>
|
||||||
|
{roleLogin.get() == "supadmin" &&
|
||||||
<Select
|
<Select
|
||||||
placeholder="Grup"
|
placeholder="Grup"
|
||||||
label="Grup"
|
label="Grup"
|
||||||
@@ -107,7 +115,10 @@ export default function CreateReport() {
|
|||||||
}))}
|
}))}
|
||||||
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}
|
||||||
|
|||||||
@@ -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() {
|
||||||
|
|||||||
@@ -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>({});
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) => {
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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,6 +48,12 @@ 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>
|
||||||
|
{
|
||||||
|
!loading && data.length === 0 ?
|
||||||
|
<Stack align="stretch" justify="center" w={"100%"}>
|
||||||
|
<Text c="dimmed" ta={"center"} fs={"italic"}>Tidak ada diskusi</Text>
|
||||||
|
</Stack>
|
||||||
|
:
|
||||||
<Box
|
<Box
|
||||||
bg={"white"}
|
bg={"white"}
|
||||||
style={{
|
style={{
|
||||||
@@ -71,11 +76,6 @@ export default function ListDiscussionOnDetailDivision() {
|
|||||||
</Group>
|
</Group>
|
||||||
</Stack>
|
</Stack>
|
||||||
))
|
))
|
||||||
:
|
|
||||||
(data.length === 0) ?
|
|
||||||
<Stack align="stretch" justify="center" w={"100%"}>
|
|
||||||
<Text c="dimmed" ta={"center"} fs={"italic"}>Belum ada diskusi</Text>
|
|
||||||
</Stack>
|
|
||||||
: <></>
|
: <></>
|
||||||
}
|
}
|
||||||
{data.map((v, i) => {
|
{data.map((v, i) => {
|
||||||
@@ -149,6 +149,7 @@ export default function ListDiscussionOnDetailDivision() {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</Box>
|
</Box>
|
||||||
|
}
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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,6 +241,12 @@ export default function ListDivision() {
|
|||||||
</Box>
|
</Box>
|
||||||
))
|
))
|
||||||
:
|
:
|
||||||
|
_.isEmpty(data)
|
||||||
|
?
|
||||||
|
<Box style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '50vh' }}>
|
||||||
|
<Text c="dimmed" ta={"center"} fs={"italic"}>Tidak ada Divisi</Text>
|
||||||
|
</Box>
|
||||||
|
:
|
||||||
data?.map((v: any, i: any) => {
|
data?.map((v: any, i: any) => {
|
||||||
return (
|
return (
|
||||||
<Box key={i} mb={20}>
|
<Box key={i} mb={20}>
|
||||||
|
|||||||
@@ -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>
|
||||||
: <></>
|
: <></>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
: <></>
|
: <></>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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'] } });
|
||||||
|
|||||||
Reference in New Issue
Block a user