From b4eab22731635cc61c96749c481f868a5af3698f Mon Sep 17 00:00:00 2001 From: amal Date: Tue, 22 Jul 2025 15:27:13 +0800 Subject: [PATCH] fix : tampilan deskripsi: - detail divisi > on klik pda file - update project dan tugas divisi tidak perlu loading judul project - tampilan notifikasi top right info No Issues --- .../task/[detail]/add-member.tsx | 6 +-- .../(fitur-division)/task/[detail]/index.tsx | 24 +++++---- app/(application)/notification.tsx | 1 + app/(application)/project/[id]/add-member.tsx | 10 ++-- app/(application)/project/[id]/index.tsx | 22 +++++--- components/division/fileDivisionDetail.tsx | 50 +++++++++++++++++-- 6 files changed, 84 insertions(+), 29 deletions(-) diff --git a/app/(application)/division/[id]/(fitur-division)/task/[detail]/add-member.tsx b/app/(application)/division/[id]/(fitur-division)/task/[detail]/add-member.tsx index 25d2159..b84fae5 100644 --- a/app/(application)/division/[id]/(fitur-division)/task/[detail]/add-member.tsx +++ b/app/(application)/division/[id]/(fitur-division)/task/[detail]/add-member.tsx @@ -104,7 +104,7 @@ export default function AddMemberTask() { ) }} /> - + setSearch(val)} value={search} /> { @@ -142,10 +142,10 @@ export default function AddMemberTask() { !found && onChoose(item.idUser, item.name, item.img) }} > - + - {item.name} + {item.name} { found && sudah menjadi anggota } diff --git a/app/(application)/division/[id]/(fitur-division)/task/[detail]/index.tsx b/app/(application)/division/[id]/(fitur-division)/task/[detail]/index.tsx index eb6d9a5..710e444 100644 --- a/app/(application)/division/[id]/(fitur-division)/task/[detail]/index.tsx +++ b/app/(application)/division/[id]/(fitur-division)/task/[detail]/index.tsx @@ -31,14 +31,16 @@ export default function DetailTaskDivision() { const update = useSelector((state: any) => state.taskUpdate) - async function handleLoad() { + async function handleLoad(cat: 'data' | 'progress') { try { - setLoading(true) + if (cat == 'data') setLoading(true) const hasil = await decryptToken(String(token?.current)) - const response = await apiGetTaskOne({ id: detail, user: hasil, cat: 'data' }) - setData(response.data) - const responseProgress = await apiGetTaskOne({ id: detail, user: hasil, cat: 'progress' }) - setProgress(responseProgress.data.progress) + const response = await apiGetTaskOne({ id: detail, user: hasil, cat: cat }) + if (cat == 'data') { + setData(response.data) + } else { + setProgress(response.data.progress) + } } catch (error) { console.error(error) } finally { @@ -47,8 +49,12 @@ export default function DetailTaskDivision() { } useEffect(() => { - handleLoad() - }, [update.progress, update.data]) + handleLoad('data') + }, [update.data]) + + useEffect(() => { + handleLoad('progress') + }, [update.progress]) return ( @@ -57,7 +63,7 @@ export default function DetailTaskDivision() { headerLeft: () => { router.back() }} />, headerTitle: loading ? 'Loading... ' : data?.title, headerTitleAlign: 'center', - headerRight: () => , + headerRight: () => , }} /> diff --git a/app/(application)/notification.tsx b/app/(application)/notification.tsx index c60fd7a..b872806 100644 --- a/app/(application)/notification.tsx +++ b/app/(application)/notification.tsx @@ -135,6 +135,7 @@ export default function Notification() { return ( diff --git a/app/(application)/project/[id]/add-member.tsx b/app/(application)/project/[id]/add-member.tsx index 6e44dab..1c37a53 100644 --- a/app/(application)/project/[id]/add-member.tsx +++ b/app/(application)/project/[id]/add-member.tsx @@ -102,9 +102,8 @@ export default function AddMemberProject() { ) }} /> - + handleSearch(val)} value={search} /> - { selectMember.length > 0 ? @@ -115,7 +114,7 @@ export default function AddMemberProject() { onChoose(item.idUser, item.name, item.img)} /> )) @@ -127,7 +126,6 @@ export default function AddMemberProject() { Tidak ada member yang dipilih } - { data.length > 0 ? data.map((item: any, index: any) => { @@ -140,10 +138,10 @@ export default function AddMemberProject() { !found && onChoose(item.id, item.name, item.img) }} > - + - {item.name} + {item.name} { found && sudah menjadi anggota } diff --git a/app/(application)/project/[id]/index.tsx b/app/(application)/project/[id]/index.tsx index e1f0a8d..cbcacdd 100644 --- a/app/(application)/project/[id]/index.tsx +++ b/app/(application)/project/[id]/index.tsx @@ -38,14 +38,16 @@ export default function DetailProject() { const [isMember, setIsMember] = useState(false) const entityUser = useSelector((state: any) => state.user) - async function handleLoad() { + async function handleLoad(cat: 'data' | 'progress') { try { - setLoading(true) + if (cat == 'data') 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) + const response = await apiGetProjectOne({ user: hasil, cat: cat, id: id }) + if (cat == 'data') { + setData(response.data) + } else { + setProgress(response.data.progress) + } } catch (error) { console.error(error) } finally { @@ -65,8 +67,12 @@ export default function DetailProject() { } useEffect(() => { - handleLoad() - }, [update.data, update.progress]) + handleLoad('data') + }, [update.data]) + + useEffect(() => { + handleLoad('progress') + }, [update.progress]) useEffect(() => { checkMember() diff --git a/components/division/fileDivisionDetail.tsx b/components/division/fileDivisionDetail.tsx index 4e34647..7399e51 100644 --- a/components/division/fileDivisionDetail.tsx +++ b/components/division/fileDivisionDetail.tsx @@ -2,11 +2,16 @@ import Styles from "@/constants/Styles"; import { apiGetDivisionOneFeature } from "@/lib/api"; import { useAuthSession } from "@/providers/AuthProvider"; import { Feather } from "@expo/vector-icons"; +import * as FileSystem from 'expo-file-system'; +import { startActivityAsync } from 'expo-intent-launcher'; import { useLocalSearchParams } from "expo-router"; +import * as Sharing from 'expo-sharing'; import React, { useEffect, useState } from "react"; -import { Dimensions, Text, View } from "react-native"; +import { Alert, Dimensions, Platform, Pressable, Text, View } from "react-native"; +import * as mime from 'react-native-mime-types'; import { ICarouselInstance } from "react-native-reanimated-carousel"; import Skeleton from "../skeleton"; +import ModalLoading from "../modalLoading"; type Props = { id: string @@ -14,6 +19,7 @@ type Props = { extension: string path: string share: boolean + idStorage: string } export default function FileDivisionDetail() { @@ -23,6 +29,7 @@ export default function FileDivisionDetail() { const { token, decryptToken } = useAuthSession() const { id } = useLocalSearchParams<{ id: string }>() const [loading, setLoading] = useState(true) + const [loadingOpen, setLoadingOpen] = useState(false) async function handleLoad() { try { @@ -41,8 +48,45 @@ export default function FileDivisionDetail() { handleLoad() }, []) + + const openFile = (item: Props) => { + setLoadingOpen(true) + let remoteUrl = 'https://wibu-storage.wibudev.com/api/files/' + item.idStorage; + const fileName = item.name + '.' + item.extension; + let localPath = `${FileSystem.documentDirectory}/${fileName}`; + const mimeType = mime.lookup(fileName) + + FileSystem.downloadAsync(remoteUrl, localPath).then(async ({ uri }) => { + const contentURL = await FileSystem.getContentUriAsync(uri); + try { + if (Platform.OS == 'android') { + // open with android intent + await startActivityAsync( + 'android.intent.action.VIEW', + { + data: contentURL, + flags: 1, + type: mimeType as string, + } + ); + // or + // Sharing.shareAsync(localPath); + + } else if (Platform.OS == 'ios') { + Sharing.shareAsync(localPath); + } + } catch (error) { + Alert.alert('INFO', 'Gagal membuka file, tidak ada aplikasi yang dapat membuka file ini'); + } finally { + setLoadingOpen(false) + } + }); + }; + + return ( + Dokumen Terkini { loading ? @@ -56,7 +100,7 @@ export default function FileDivisionDetail() { { data.map((item, index) => ( - + openFile(item)}> @@ -65,7 +109,7 @@ export default function FileDivisionDetail() { {item.name}.{item.extension} - + )) }