116 lines
3.8 KiB
TypeScript
116 lines
3.8 KiB
TypeScript
import { ColorsStatus } from "@/constants/ColorsStatus"
|
|
import Styles from "@/constants/Styles"
|
|
import { apiGetDivisionOneFeature } from "@/lib/api"
|
|
import { useAuthSession } from "@/providers/AuthProvider"
|
|
import { AntDesign, Feather, MaterialIcons, SimpleLineIcons } from "@expo/vector-icons"
|
|
import { router, useLocalSearchParams } from "expo-router"
|
|
import { useEffect, useState } from "react"
|
|
import { View } from "react-native"
|
|
import BorderBottomItem from "../borderBottomItem"
|
|
import { useTheme } from "@/providers/ThemeProvider"
|
|
import Text from "../Text"
|
|
|
|
type Props = {
|
|
tugas: number
|
|
dokumen: number
|
|
diskusi: number
|
|
kalender: number
|
|
}
|
|
|
|
export default function FiturDivisionDetail({ refreshing }: { refreshing: boolean }) {
|
|
const { colors } = useTheme();
|
|
const { token, decryptToken } = useAuthSession()
|
|
const { id } = useLocalSearchParams<{ id: string }>()
|
|
const [data, setData] = useState<Props>({
|
|
tugas: 0,
|
|
dokumen: 0,
|
|
diskusi: 0,
|
|
kalender: 0,
|
|
})
|
|
|
|
async function handleLoad() {
|
|
try {
|
|
const hasil = await decryptToken(String(token?.current))
|
|
const response = await apiGetDivisionOneFeature({ user: hasil, id, cat: 'jumlah' })
|
|
setData(response.data)
|
|
} catch (error) {
|
|
console.error(error)
|
|
}
|
|
}
|
|
|
|
useEffect(() => {
|
|
if (refreshing)
|
|
handleLoad()
|
|
}, [refreshing])
|
|
|
|
useEffect(() => {
|
|
handleLoad()
|
|
}, [])
|
|
|
|
return (
|
|
<View style={[Styles.mb15]}>
|
|
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Fitur</Text>
|
|
<View>
|
|
<View style={[Styles.rowSpaceBetween]}>
|
|
<BorderBottomItem
|
|
bgColor={colors.card}
|
|
borderType="all"
|
|
icon={
|
|
<View style={[Styles.p05]}>
|
|
<AntDesign name="filetext1" size={28} color={colors.text} />
|
|
</View>
|
|
}
|
|
title="Tugas"
|
|
subtitle={`${data.tugas} Tugas`}
|
|
width={30}
|
|
onPress={() => { router.push(`/division/${id}/task?status=0`) }}
|
|
/>
|
|
|
|
<BorderBottomItem
|
|
bgColor={colors.card}
|
|
borderType="all"
|
|
icon={
|
|
<View style={[Styles.p05]}>
|
|
<Feather name="paperclip" size={28} color={colors.text} />
|
|
</View>
|
|
}
|
|
title="Dokumen"
|
|
subtitle={`${data.dokumen} File`}
|
|
width={30}
|
|
onPress={() => { router.push(`/division/${id}/document`) }}
|
|
/>
|
|
</View>
|
|
|
|
<View style={[Styles.rowSpaceBetween]}>
|
|
<BorderBottomItem
|
|
bgColor={colors.card}
|
|
borderType="all"
|
|
icon={
|
|
<View style={[Styles.p05]}>
|
|
<SimpleLineIcons name="bubbles" size={28} color={colors.text} />
|
|
</View>
|
|
}
|
|
title="Diskusi"
|
|
subtitle={`${data.diskusi} Diskusi`}
|
|
width={30}
|
|
onPress={() => { router.push(`/division/${id}/discussion?active=true`) }}
|
|
/>
|
|
|
|
<BorderBottomItem
|
|
bgColor={colors.card}
|
|
borderType="all"
|
|
icon={
|
|
<View style={[Styles.p05]}>
|
|
<AntDesign name="calendar" size={28} color={colors.text} />
|
|
</View>
|
|
}
|
|
title="Kalender"
|
|
subtitle={`${data.kalender} Acara`}
|
|
width={30}
|
|
onPress={() => { router.push(`/division/${id}/calendar`) }}
|
|
/>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
)
|
|
} |