Merge pull request #158 from bipproduction/amalia/28-agustus-24
upd: chart home
This commit is contained in:
@@ -115,8 +115,75 @@ export async function GET(request: Request) {
|
||||
allData = _.orderBy(format, 'jumlah', 'desc').slice(0, 5)
|
||||
|
||||
} else if (kategori == "progress") {
|
||||
let kondisi
|
||||
|
||||
// klo perbekel == semua grup
|
||||
if (roleUser == "supadmin") {
|
||||
kondisi = {
|
||||
isActive: true,
|
||||
Division: {
|
||||
idVillage: idVillage,
|
||||
Group: {
|
||||
isActive: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
kondisi = {
|
||||
isActive: true,
|
||||
Division: {
|
||||
idGroup: idGroup
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const data = await prisma.divisionProject.groupBy({
|
||||
where: kondisi,
|
||||
by: ["status"],
|
||||
_count: true
|
||||
})
|
||||
|
||||
console.log(data)
|
||||
allData = data
|
||||
|
||||
|
||||
} else if (kategori == "dokumen") {
|
||||
let kondisi
|
||||
|
||||
// klo perbekel == semua grup
|
||||
if (roleUser == "supadmin") {
|
||||
kondisi = {
|
||||
isActive: true,
|
||||
category: 'FILE',
|
||||
Division: {
|
||||
idVillage: idVillage,
|
||||
Group: {
|
||||
isActive: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
kondisi = {
|
||||
isActive: true,
|
||||
category: 'FILE',
|
||||
Division: {
|
||||
idGroup: idGroup
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const data = await prisma.divisionDocumentFolderFile.findMany({
|
||||
where: kondisi,
|
||||
})
|
||||
|
||||
allData = _.map(_.groupBy(data, "extension"), (v: any) => ({
|
||||
file: v[0].extension,
|
||||
jumlah: v.length,
|
||||
}))
|
||||
|
||||
console.log(allData)
|
||||
|
||||
|
||||
|
||||
} else if (kategori == "event") {
|
||||
let kondisi
|
||||
|
||||
@@ -5,14 +5,41 @@ import { useShallowEffect } from "@mantine/hooks";
|
||||
import { EChartsOption } from "echarts";
|
||||
import EChartsReact from "echarts-for-react";
|
||||
import { useState } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
import { funGetHome } from "../lib/api_home";
|
||||
|
||||
export default function ChartDocumentHome() {
|
||||
const [options, setOptions] = useState<EChartsOption>({});
|
||||
const [isData, setData] = useState<any[]>([])
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useShallowEffect(() => {
|
||||
loadData()
|
||||
fetchData()
|
||||
}, [])
|
||||
|
||||
|
||||
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
setData([]);
|
||||
setLoading(true);
|
||||
const response = await funGetHome('?cat=dokumen')
|
||||
|
||||
if (response.success) {
|
||||
setData(response.data)
|
||||
} else {
|
||||
toast.error(response.message);
|
||||
}
|
||||
setLoading(false);
|
||||
} catch (error) {
|
||||
toast.error("Gagal mendapatkan data, coba lagi nanti");
|
||||
console.error(error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const loadData = () => {
|
||||
const option: EChartsOption = {
|
||||
title: {
|
||||
|
||||
@@ -5,14 +5,41 @@ 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";
|
||||
|
||||
export default function ChartProgressHome() {
|
||||
const [options, setOptions] = useState<EChartsOption>({});
|
||||
const [isData, setData] = useState<any[]>([])
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useShallowEffect(() => {
|
||||
loadData()
|
||||
fetchData()
|
||||
}, [])
|
||||
|
||||
|
||||
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
setData([]);
|
||||
setLoading(true);
|
||||
const response = await funGetHome('?cat=progress')
|
||||
|
||||
if (response.success) {
|
||||
setData(response.data)
|
||||
} else {
|
||||
toast.error(response.message);
|
||||
}
|
||||
setLoading(false);
|
||||
} catch (error) {
|
||||
toast.error("Gagal mendapatkan data, coba lagi nanti");
|
||||
console.error(error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const loadData = () => {
|
||||
const option: EChartsOption = {
|
||||
title: {
|
||||
|
||||
Reference in New Issue
Block a user