upd: home
Deskripsi: - integrasi api kegiatan terupdate - integrasi api divisi teraktif - integrasi api progres kegiatan - integrasi api jumlah dokumen - integrasi api event hari ini - integrasi api diskusi No Issues
This commit is contained in:
@@ -1,20 +1,44 @@
|
||||
import Styles from "@/constants/Styles";
|
||||
import { apiGetDataHome } from "@/lib/api";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { PieChart } from "react-native-gifted-charts";
|
||||
|
||||
type Props = {
|
||||
value: number;
|
||||
text: string;
|
||||
color: string;
|
||||
}[]
|
||||
|
||||
export default function ChartProgresHome() {
|
||||
const pieData = [
|
||||
{ value: 54, text: "54%", color: '#177AD5' },
|
||||
{ value: 40, text: "40%", color: '#92cc76' },
|
||||
{ value: 20, text: "20%", color: '#ED6665' },
|
||||
{ value: 0, text: "0%", color: '#fac858' },
|
||||
];
|
||||
const { decryptToken, token } = useAuthSession()
|
||||
const [data, setData] = useState<Props>([])
|
||||
|
||||
async function handleData() {
|
||||
try {
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiGetDataHome({ cat: "progress", user: hasil })
|
||||
const convertedArray = response.data.map((item: { color: any; text: any; value: any; }) => ({
|
||||
color: item.color,
|
||||
text: item.text,
|
||||
value: Number(item.value)
|
||||
}));
|
||||
setData(convertedArray)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
handleData()
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<View style={[Styles.wrapPaper, Styles.contentItemCenter, Styles.mb15]}>
|
||||
<Text style={[Styles.textSubtitle, Styles.mv15]}>PROGRES KEGIATAN</Text>
|
||||
<PieChart
|
||||
data={pieData}
|
||||
data={data}
|
||||
showText
|
||||
showValuesAsTooltipText
|
||||
textColor="black"
|
||||
@@ -26,6 +50,31 @@ export default function ChartProgresHome() {
|
||||
textBackgroundRadius={0}
|
||||
isAnimated
|
||||
/>
|
||||
|
||||
<View style={[Styles.mt15]}>
|
||||
<View style={[Styles.rowSpaceBetween, Styles.w80]}>
|
||||
<View style={[Styles.rowItemsCenter, Styles.w60]}>
|
||||
<View style={[Styles.iconContent, { backgroundColor: '#177AD5' }]}></View>
|
||||
<Text style={[Styles.textInformation, Styles.ml10]}>Segera Dikerjakan</Text>
|
||||
</View>
|
||||
|
||||
<View style={[Styles.rowItemsCenter, Styles.w50]}>
|
||||
<View style={[Styles.iconContent, { backgroundColor: '#92cc76' }]}></View>
|
||||
<Text style={[Styles.textInformation, Styles.ml10]}>Selesai</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View style={[Styles.rowSpaceBetween, Styles.w80, Styles.mt10]}>
|
||||
<View style={[Styles.rowItemsCenter, Styles.w60]}>
|
||||
<View style={[Styles.iconContent, { backgroundColor: '#fac858' }]}></View>
|
||||
<Text style={[Styles.textInformation, Styles.ml10]}>Dikerjakan</Text>
|
||||
</View>
|
||||
|
||||
<View style={[Styles.rowItemsCenter, Styles.w50]}>
|
||||
<View style={[Styles.iconContent, { backgroundColor: '#ED6665' }]}></View>
|
||||
<Text style={[Styles.textInformation, Styles.ml10]}>Dibatalkan</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user