Deskripsi: - detail project - batal project - edit project - tambah tugas project - update status tugas project No Issues'
82 lines
2.8 KiB
TypeScript
82 lines
2.8 KiB
TypeScript
import ButtonBackHeader from "@/components/buttonBackHeader";
|
|
import HeaderRightProjectDetail from "@/components/project/headerProjectDetail";
|
|
import SectionFile from "@/components/project/sectionFile";
|
|
import SectionMember from "@/components/project/sectionMember";
|
|
import SectionTanggalTugasProject from "@/components/project/sectionTanggalTugas";
|
|
import SectionCancel from "@/components/sectionCancel";
|
|
import SectionProgress from "@/components/sectionProgress";
|
|
import Styles from "@/constants/Styles";
|
|
import { apiGetProjectOne } from "@/lib/api";
|
|
import { useAuthSession } from "@/providers/AuthProvider";
|
|
import { router, Stack, useLocalSearchParams } from "expo-router";
|
|
import { useEffect, useState } from "react";
|
|
import { SafeAreaView, ScrollView, View } from "react-native";
|
|
import { useSelector } from "react-redux";
|
|
|
|
|
|
type Props = {
|
|
id: string,
|
|
idVillage: string,
|
|
idGroup: string,
|
|
title: string,
|
|
status: number,
|
|
desc: string,
|
|
reason: string,
|
|
isActive: string,
|
|
createdBy: string,
|
|
createdAt: string,
|
|
updatedAt: string,
|
|
}
|
|
|
|
export default function DetailProject() {
|
|
const { token, decryptToken } = useAuthSession()
|
|
const { id } = useLocalSearchParams<{ id: string }>();
|
|
const [data, setData] = useState<Props>()
|
|
const [progress, setProgress] = useState(0)
|
|
const [loading, setLoading] = useState(true)
|
|
const update = useSelector((state: any) => state.projectUpdate)
|
|
|
|
async function handleLoad() {
|
|
try {
|
|
setLoading(true)
|
|
const hasil = await decryptToken(String(token?.current))
|
|
const response = await apiGetProjectOne({ user: hasil, cat: 'data', id: id })
|
|
setData(response.data)
|
|
const responseProgress = await apiGetProjectOne({ user: hasil, cat: 'progress', id: id })
|
|
setProgress(responseProgress.data.progress)
|
|
} catch (error) {
|
|
console.error(error)
|
|
} finally {
|
|
setLoading(false)
|
|
}
|
|
}
|
|
|
|
useEffect(() => {
|
|
handleLoad()
|
|
}, [update.data, update.progress])
|
|
|
|
|
|
return (
|
|
<SafeAreaView>
|
|
<Stack.Screen
|
|
options={{
|
|
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
|
headerTitle: loading ? '' : data?.title,
|
|
headerTitleAlign: 'center',
|
|
headerRight: () => <HeaderRightProjectDetail id={id} />,
|
|
}}
|
|
/>
|
|
<ScrollView>
|
|
<View style={[Styles.p15, Styles.mb100]}>
|
|
{
|
|
data?.reason != null && data?.reason != "" && <SectionCancel text={data?.reason} />
|
|
}
|
|
<SectionProgress text={`Kemajuan Kegiatan ${progress}%`} progress={progress} />
|
|
<SectionTanggalTugasProject />
|
|
<SectionFile />
|
|
<SectionMember />
|
|
</View>
|
|
</ScrollView>
|
|
</SafeAreaView>
|
|
)
|
|
} |