Deskripsi: - divisi - detail divisi - informasi divisi - calender list - calender detail - history - diskusi list - detail diskusi - list task divisi NO Issuese
92 lines
3.4 KiB
TypeScript
92 lines
3.4 KiB
TypeScript
import Styles from "@/constants/Styles";
|
|
import { apiGetDivisionOneFeature } from "@/lib/api";
|
|
import { useAuthSession } from "@/providers/AuthProvider";
|
|
import { Feather } from "@expo/vector-icons";
|
|
import { useLocalSearchParams } 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 Skeleton from "../skeleton";
|
|
|
|
type Props = {
|
|
id: string
|
|
name: string
|
|
extension: string
|
|
path: string
|
|
share: boolean
|
|
}
|
|
|
|
export default function FileDivisionDetail() {
|
|
const ref = React.useRef<ICarouselInstance>(null);
|
|
const width = Dimensions.get("window").width;
|
|
const [data, setData] = useState<Props[]>([])
|
|
const { token, decryptToken } = useAuthSession()
|
|
const { id } = useLocalSearchParams<{ id: string }>()
|
|
const [loading, setLoading] = useState(true)
|
|
|
|
async function handleLoad() {
|
|
try {
|
|
setLoading(true)
|
|
const hasil = await decryptToken(String(token?.current))
|
|
const response = await apiGetDivisionOneFeature({ user: hasil, id, cat: 'new-file' })
|
|
setData(response.data)
|
|
} catch (error) {
|
|
console.error(error)
|
|
} finally {
|
|
setLoading(false)
|
|
}
|
|
}
|
|
|
|
useEffect(() => {
|
|
handleLoad()
|
|
}, [])
|
|
|
|
return (
|
|
<View style={[Styles.mb15]}>
|
|
<Text style={[Styles.textDefaultSemiBold, Styles.mv10]}>Dokumen Terkini</Text>
|
|
{
|
|
loading ?
|
|
<View style={[Styles.rowSpaceBetween]}>
|
|
<Skeleton width={30} widthType="percent" height={80} borderRadius={10} />
|
|
<Skeleton width={30} widthType="percent" height={80} borderRadius={10} />
|
|
<Skeleton width={30} widthType="percent" height={80} borderRadius={10} />
|
|
</View>
|
|
:
|
|
data.length > 0 ?
|
|
<Carousel
|
|
ref={ref}
|
|
width={width}
|
|
height={115}
|
|
data={data}
|
|
loop={true}
|
|
autoPlay={false}
|
|
autoPlayReverse={false}
|
|
pagingEnabled={true}
|
|
snapEnabled={true}
|
|
vertical={false}
|
|
style={{
|
|
width: width,
|
|
}}
|
|
mode="parallax"
|
|
modeConfig={{
|
|
parallaxScrollingScale: 1,
|
|
parallaxScrollingOffset: 280,
|
|
}}
|
|
renderItem={({ index }) => (
|
|
<View style={{ margin: 'auto', width: '28%' }}>
|
|
<View style={{ alignItems: 'center' }}>
|
|
<View style={[Styles.wrapPaper, { alignItems: 'center' }]}>
|
|
<Feather name="file-text" size={50} color="black" style={Styles.mr05} />
|
|
</View>
|
|
</View>
|
|
<Text style={[Styles.textMediumNormal, { textAlign: 'center' }]} numberOfLines={1}>{data[index].name}.{data[index].extension}</Text>
|
|
</View>
|
|
|
|
)}
|
|
/>
|
|
:
|
|
<Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada file</Text>
|
|
}
|
|
</View>
|
|
)
|
|
} |