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
64 lines
2.1 KiB
TypeScript
64 lines
2.1 KiB
TypeScript
import Styles from "@/constants/Styles";
|
|
import { apiGetDataHome } from "@/lib/api";
|
|
import { useAuthSession } from "@/providers/AuthProvider";
|
|
import { router } from "expo-router";
|
|
import React, { useEffect, useState } from "react";
|
|
import { Dimensions, Text, View } from "react-native";
|
|
import Carousel, { ICarouselInstance } from "react-native-reanimated-carousel";
|
|
import PaperGridContent from "../paperGridContent";
|
|
|
|
type Props = {
|
|
id: string
|
|
name: string
|
|
jumlah: number
|
|
}
|
|
|
|
export default function DivisionHome() {
|
|
const { decryptToken, token } = useAuthSession()
|
|
const ref = React.useRef<ICarouselInstance>(null);
|
|
const width = Dimensions.get("window").width;
|
|
const [data, setData] = useState<Props[]>([])
|
|
|
|
async function handleData() {
|
|
try {
|
|
const hasil = await decryptToken(String(token?.current))
|
|
const response = await apiGetDataHome({ cat: "division", user: hasil })
|
|
setData(response.data)
|
|
} catch (error) {
|
|
console.error(error)
|
|
}
|
|
}
|
|
|
|
useEffect(() => {
|
|
handleData()
|
|
}, []);
|
|
|
|
|
|
|
|
return (
|
|
<View style={[Styles.mb15]}>
|
|
<Text style={[Styles.textDefaultSemiBold, Styles.mv10]}>Divisi Teraktif</Text>
|
|
<Carousel
|
|
ref={ref}
|
|
style={{ width: "100%" }}
|
|
width={width * 0.8}
|
|
height={235}
|
|
data={data}
|
|
loop={true}
|
|
autoPlay={false}
|
|
autoPlayReverse={false}
|
|
pagingEnabled={true}
|
|
snapEnabled={true}
|
|
vertical={false}
|
|
renderItem={({ index }) => (
|
|
<PaperGridContent onPress={() => { router.push(`/division/${data[index].id}`) }} content="carousel" title={data[index].name} headerColor="warning">
|
|
<View>
|
|
<Text style={{ fontSize: 50, textAlign: "center", fontWeight: 'bold' }}>{data[index].jumlah}</Text>
|
|
<Text style={[Styles.textSubtitle, { textAlign: "center" }]}>KEGIATAN</Text>
|
|
</View>
|
|
</PaperGridContent>
|
|
)}
|
|
/>
|
|
</View>
|
|
)
|
|
} |