upd: chart home

Deskripsi:
- belm selesai nih

No Issues
This commit is contained in:
amel
2024-08-28 17:35:02 +08:00
parent 4fd9f10ab6
commit 2e09a18545
3 changed files with 121 additions and 0 deletions

View File

@@ -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: {

View File

@@ -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: {