upd: pull to refresh

Deskripsi:
- list banner
- lit grouop
- list position
- list member
- list diskusi umum
- list pengumuman
- list project
- list divisi
- list tugas divisi
- list diskusi divisi
- list kalender divisi
- list dokumen divisi

No Issues
This commit is contained in:
2025-07-15 12:08:55 +08:00
parent ae420ec560
commit 4a10655582
12 changed files with 249 additions and 63 deletions

View File

@@ -34,6 +34,7 @@ import {
Alert,
Platform,
Pressable,
RefreshControl,
SafeAreaView,
ScrollView,
Text,
@@ -62,23 +63,24 @@ type PropsPath = {
};
export default function DocumentDivision() {
const [isShare, setShare] = useState(false);
const { token, decryptToken } = useAuthSession();
const { id } = useLocalSearchParams<{ id: string }>();
const [path, setPath] = useState("home");
const [data, setData] = useState<Props[]>([]);
const [dataJalur, setDataJalur] = useState<PropsPath[]>([]);
const [dariSelectAll, setDariSelectAll] = useState(false);
const [selectedFiles, setSelectedFiles] = useState<any>([]);
const [selectAll, setSelectAll] = useState(false);
const [shareSelected, setShareSelected] = useState(false);
const [copyAllowed, setCopyAllowed] = useState(true);
const [modalMore, setModalMore] = useState(false);
const [isRename, setRename] = useState(false);
const [isShare, setShare] = useState(false)
const { token, decryptToken } = useAuthSession()
const { id } = useLocalSearchParams<{ id: string }>()
const [path, setPath] = useState("home")
const [data, setData] = useState<Props[]>([])
const [dataJalur, setDataJalur] = useState<PropsPath[]>([])
const [dariSelectAll, setDariSelectAll] = useState(false)
const [selectedFiles, setSelectedFiles] = useState<any>([])
const [selectAll, setSelectAll] = useState(false)
const [shareSelected, setShareSelected] = useState(false)
const [copyAllowed, setCopyAllowed] = useState(true)
const [modalMore, setModalMore] = useState(false)
const [isRename, setRename] = useState(false)
const dispatch = useDispatch();
const [loading, setLoading] = useState(true)
const arrSkeleton = Array.from({ length: 3 })
const update = useSelector((state: any) => state.dokumenUpdate);
const update = useSelector((state: any) => state.dokumenUpdate)
const [refreshing, setRefreshing] = useState(false)
const [bodyRename, setBodyRename] = useState({
id: "",
name: "",
@@ -87,9 +89,9 @@ export default function DocumentDivision() {
extension: "",
});
async function handleLoad() {
async function handleLoad(loading: boolean) {
try {
setLoading(true)
setLoading(loading)
const hasil = await decryptToken(String(token?.current));
const response = await apiGetDocument({
user: hasil,
@@ -107,7 +109,7 @@ export default function DocumentDivision() {
}
useEffect(() => {
handleLoad();
handleLoad(true);
}, [path, update]);
const handleCheckboxChange = (index: number) => {
@@ -297,6 +299,13 @@ export default function DocumentDivision() {
});
};
const handleRefresh = async () => {
setRefreshing(true)
handleLoad(false)
await new Promise(resolve => setTimeout(resolve, 2000));
setRefreshing(false)
};
return (
<SafeAreaView>
<Stack.Screen
@@ -336,7 +345,14 @@ export default function DocumentDivision() {
),
}}
/>
<ScrollView style={{ height: "100%" }}>
<ScrollView
style={{ height: "100%" }}
refreshControl={
<RefreshControl
refreshing={refreshing}
onRefresh={handleRefresh}
/>
}>
<View style={[Styles.p15, Styles.mb100]}>
<View style={[Styles.rowItemsCenter]}>
{