From d4b4db4251c1508e79bbad44d35952a20bb4ba04 Mon Sep 17 00:00:00 2001 From: amaliadwiy Date: Fri, 17 Apr 2026 15:01:14 +0800 Subject: [PATCH 1/3] upd: fix: jumlah dokumen grafik pada home --- components/home/chartDokumenHome.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/home/chartDokumenHome.tsx b/components/home/chartDokumenHome.tsx index ee76ae2..8e21972 100644 --- a/components/home/chartDokumenHome.tsx +++ b/components/home/chartDokumenHome.tsx @@ -20,6 +20,7 @@ export default function ChartDokumenHome({ refreshing }: { refreshing: boolean } const { colors } = useTheme(); const [data, setData] = useState([]) const [maxValue, setMaxValue] = useState(5) + const [chartKey, setChartKey] = useState(0) const barData = [ { value: 23, label: 'Gambar', frontColor: '#fac858' }, { value: 12, label: 'Dokumen', frontColor: '#92cc76' }, @@ -32,8 +33,8 @@ export default function ChartDokumenHome({ refreshing }: { refreshing: boolean } setLoading(loading) const hasil = await decryptToken(String(token?.current)) const response = await apiGetDataHome({ cat: "dokumen", user: hasil }) - const maxValue = response.data.reduce((max: number, obj: { value: number; }) => Math.max(max, obj.value), -Infinity); - const roundUp = Math.ceil(maxValue / 10) * 10 + const maxVal = response.data.reduce((max: number, obj: { value: number; }) => Math.max(max, Number(obj.value)), 0); + const roundUp = maxVal > 0 ? Math.ceil(maxVal / 10) * 10 : 10; setMaxValue(roundUp) const convertedArray = response.data.map((item: { color: any; label: any; value: any; }) => ({ frontColor: item.color, @@ -41,6 +42,7 @@ export default function ChartDokumenHome({ refreshing }: { refreshing: boolean } value: Number(item.value) })); setData(convertedArray) + setChartKey((prev: number) => prev + 1) } catch (error) { console.error(error) } finally { @@ -49,8 +51,9 @@ export default function ChartDokumenHome({ refreshing }: { refreshing: boolean } } useEffect(() => { - if (refreshing) + if (refreshing) { handleData(false) + } }, [refreshing]); useEffect(() => { @@ -64,6 +67,7 @@ export default function ChartDokumenHome({ refreshing }: { refreshing: boolean } loading ? : Date: Fri, 17 Apr 2026 15:26:06 +0800 Subject: [PATCH 2/3] upd: fix laopran grafik divisi --- components/division/reportChartDocument.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/division/reportChartDocument.tsx b/components/division/reportChartDocument.tsx index 865bf5f..9cb0957 100644 --- a/components/division/reportChartDocument.tsx +++ b/components/division/reportChartDocument.tsx @@ -7,10 +7,6 @@ import Text from "../Text"; export default function ReportChartDocument({ data }: { data: { label: string; value: number; }[] }) { const { colors } = useTheme(); const maxValue = Math.max(...data.map(i => i.value)) - const barData = [ - { value: 23, label: 'Gambar', }, - { value: 12, label: 'Dokumen' }, - ]; const width = Dimensions.get("window").width; return ( From 772551a9175ce5fda2c075fe249bad98720a6cbe Mon Sep 17 00:00:00 2001 From: amaliadwiy Date: Fri, 17 Apr 2026 16:46:49 +0800 Subject: [PATCH 3/3] upd: page kosong atau data udah di hapus pada pengumuman --- app/(application)/announcement/[id].tsx | 193 +++++++++++++----------- components/ErrorView.tsx | 42 ++++++ 2 files changed, 144 insertions(+), 91 deletions(-) create mode 100644 components/ErrorView.tsx diff --git a/app/(application)/announcement/[id].tsx b/app/(application)/announcement/[id].tsx index c6db8c2..096f612 100644 --- a/app/(application)/announcement/[id].tsx +++ b/app/(application)/announcement/[id].tsx @@ -3,6 +3,7 @@ import AppHeader from "@/components/AppHeader"; import BorderBottomItem from "@/components/borderBottomItem"; import Skeleton from "@/components/skeleton"; import Text from '@/components/Text'; +import ErrorView from "@/components/ErrorView"; import { ConstEnv } from "@/constants/ConstEnv"; import { isImageFile } from "@/constants/FileExtensions"; import Styles from "@/constants/Styles"; @@ -65,6 +66,7 @@ export default function DetailAnnouncement() { const [loadingOpen, setLoadingOpen] = useState(false) const [preview, setPreview] = useState(false) const [chooseFile, setChooseFile] = useState() + const [isError, setIsError] = useState(false) /** * Opens the image preview modal for the selected image file @@ -79,6 +81,7 @@ export default function DetailAnnouncement() { async function handleLoad(loading: boolean) { try { + setIsError(false) setLoading(loading) const hasil = await decryptToken(String(token?.current)) const response: ApiResponse = await apiGetAnnouncementOne({ id: id, user: hasil }) @@ -87,10 +90,12 @@ export default function DetailAnnouncement() { setDataMember(response.member) setDataFile(response.file) } else { + setIsError(true) Toast.show({ type: 'small', text1: response.message }) } } catch (error: any) { console.error(error); + setIsError(true) const message = error?.response?.data?.message || "Gagal mengambil data" Toast.show({ type: 'small', text1: message }) @@ -206,104 +211,110 @@ export default function DetailAnnouncement() { /> } > - - - { - loading ? - - - - - - - - - - - - : - <> - - - {data?.title} - - - { - hasHtmlTags(data?.desc) ? - - : - {data?.desc} - } - - - } - + {isError && !loading ? ( + + - { - dataFile.length > 0 && ( - - - File - - {dataFile.map((item, index) => ( - } - title={item.name + '.' + item.extension} - titleWeight="normal" - onPress={() => { - isImageFile(item.extension) ? - handleChooseFile(item) - : openFile(item) - }} - /> - ))} - - ) - } - - { - loading ? - arrSkeleton.map((item, index) => { - return ( - - - - + ) : ( + + + { + loading ? + + + + + + - ) - }) - : - Object.keys(dataMember).map((v: any, i: any) => { - return ( - - {dataMember[v]?.[0].group} + + + + + : + <> + + + {data?.title} + + { - dataMember[v].map((item: any, x: any) => { - return ( - - - {item.division} - - ) - }) + hasHtmlTags(data?.desc) ? + + : + {data?.desc} } - - ) - }) + + } + + + { + dataFile.length > 0 && ( + + + File + + {dataFile.map((item, index) => ( + } + title={item.name + '.' + item.extension} + titleWeight="normal" + onPress={() => { + isImageFile(item.extension) ? + handleChooseFile(item) + : openFile(item) + }} + /> + ))} + + ) } + + { + loading ? + arrSkeleton.map((item, index) => { + return ( + + + + + + ) + }) + : + Object.keys(dataMember).map((v: any, i: any) => { + return ( + + {dataMember[v]?.[0].group} + { + dataMember[v].map((item: any, x: any) => { + return ( + + + {item.division} + + ) + }) + } + + + ) + }) + } + - + )} + + + + + {title} + + + {message} + + + ); +}