upd: home
Deskripsi: - update chart progress task divisi pada halaman home No Issues
This commit is contained in:
@@ -143,9 +143,27 @@ export async function GET(request: Request) {
|
|||||||
_count: true
|
_count: true
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(data)
|
const dataStatus = [{ name: 'Segera dikerjakan', status: 0 }, { name: 'Dikerjakan', status: 1 }, { name: 'Selesai dikerjakan', status: 2 }, { name: 'Dibatalkan', status: 3 }]
|
||||||
allData = data
|
const hasil: any[] = []
|
||||||
|
let input
|
||||||
|
for (let index = 0; index < dataStatus.length; index++) {
|
||||||
|
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)
|
||||||
|
input = {
|
||||||
|
name: dataStatus[index].name,
|
||||||
|
value: find
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
input = {
|
||||||
|
name: dataStatus[index].name,
|
||||||
|
value: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hasil.push(input)
|
||||||
|
}
|
||||||
|
|
||||||
|
allData = hasil
|
||||||
|
|
||||||
} else if (kategori == "dokumen") {
|
} else if (kategori == "dokumen") {
|
||||||
let kondisi
|
let kondisi
|
||||||
@@ -181,7 +199,7 @@ export async function GET(request: Request) {
|
|||||||
jumlah: v.length,
|
jumlah: v.length,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
console.log(allData)
|
// console.log(allData)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ export default function ChartProgressHome() {
|
|||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
loadData()
|
|
||||||
fetchData()
|
fetchData()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
@@ -28,6 +27,7 @@ export default function ChartProgressHome() {
|
|||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setData(response.data)
|
setData(response.data)
|
||||||
|
loadData(response.data)
|
||||||
} else {
|
} else {
|
||||||
toast.error(response.message);
|
toast.error(response.message);
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ export default function ChartProgressHome() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadData = () => {
|
const loadData = (value:any) => {
|
||||||
const option: EChartsOption = {
|
const option: EChartsOption = {
|
||||||
title: {
|
title: {
|
||||||
text: "PROGRES KEGIATAN",
|
text: "PROGRES KEGIATAN",
|
||||||
@@ -69,12 +69,7 @@ export default function ChartProgressHome() {
|
|||||||
return `${a.value + "%"}`;
|
return `${a.value + "%"}`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: [
|
data: value,
|
||||||
{ value: 25, name: 'Dikerjakan' },
|
|
||||||
{ value: 35, name: 'Selesai dikerjakan' },
|
|
||||||
{ value: 10, name: 'Segera dikerjakan' },
|
|
||||||
{ value: 30, name: 'Batal dikerjakan' },
|
|
||||||
],
|
|
||||||
emphasis: {
|
emphasis: {
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
shadowBlur: 10,
|
shadowBlur: 10,
|
||||||
|
|||||||
Reference in New Issue
Block a user