upd: project
Deskripsi: - detail project - batal project - edit project - tambah tugas project - update status tugas project No Issues'
This commit is contained in:
@@ -1,29 +1,78 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import HeaderRightProjectDetail from "@/components/project/headerProjectDetail";
|
||||
import SectionFile from "@/components/sectionFile";
|
||||
import SectionMember from "@/components/sectionMember";
|
||||
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 SectionTanggalTugas from "@/components/sectionTanggalTugas";
|
||||
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 { id } = useLocalSearchParams()
|
||||
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: 'Judul Kegiatan',
|
||||
headerTitle: loading ? '' : data?.title,
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => <HeaderRightProjectDetail id={id} />,
|
||||
}}
|
||||
/>
|
||||
<ScrollView>
|
||||
<View style={[Styles.p15, Styles.mb100]}>
|
||||
<SectionProgress text="Kemajuan Kegiatan 50%" />
|
||||
<SectionTanggalTugas category="project" />
|
||||
{
|
||||
data?.reason != null && data?.reason != "" && <SectionCancel text={data?.reason} />
|
||||
}
|
||||
<SectionProgress text={`Kemajuan Kegiatan ${progress}%`} progress={progress} />
|
||||
<SectionTanggalTugasProject />
|
||||
<SectionFile />
|
||||
<SectionMember />
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user