upd: project dan task divisi

Deskripsi:
- menambahkan loading saat tambah file
- button submit disable saat loading]

No Issues
This commit is contained in:
2025-08-04 11:48:06 +08:00
parent c54f4c9fda
commit b7c44109a1
2 changed files with 16 additions and 2 deletions

View File

@@ -32,6 +32,7 @@ export default function TaskDivisionAddFile() {
const [loadingCheck, setLoadingCheck] = useState(false);
const dispatch = useDispatch();
const update = useSelector((state: any) => state.taskUpdate);
const [loading, setLoading] = useState(false);
const pickDocumentAsync = async () => {
let result = await DocumentPicker.getDocumentAsync({
@@ -90,6 +91,7 @@ export default function TaskDivisionAddFile() {
async function handleAddFile() {
try {
setLoading(true)
const hasil = await decryptToken(String(token?.current));
const fd = new FormData();
@@ -119,6 +121,8 @@ export default function TaskDivisionAddFile() {
} catch (error) {
console.error(error);
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
} finally {
setLoading(false)
}
}
@@ -138,7 +142,7 @@ export default function TaskDivisionAddFile() {
headerRight: () => (
<ButtonSaveHeader
category="create"
disable={fileForm.length == 0 ? true : false}
disable={fileForm.length == 0 || loading ? true : false}
onPress={() => { handleAddFile() }}
/>
),
@@ -171,6 +175,9 @@ export default function TaskDivisionAddFile() {
{
loadingCheck && <ActivityIndicator size="small" />
}
{
loading && <ActivityIndicator size="large" />
}
</View>
</ScrollView>
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">

View File

@@ -26,6 +26,7 @@ export default function ProjectAddFile() {
const [loadingCheck, setLoadingCheck] = useState(false)
const dispatch = useDispatch()
const update = useSelector((state: any) => state.projectUpdate)
const [loading, setLoading] = useState(false)
const pickDocumentAsync = async () => {
let result = await DocumentPicker.getDocumentAsync({
@@ -86,6 +87,7 @@ export default function ProjectAddFile() {
async function handleAddFile() {
try {
setLoading(true)
const hasil = await decryptToken(String(token?.current))
const fd = new FormData();
@@ -116,6 +118,8 @@ export default function ProjectAddFile() {
} catch (error) {
console.error(error);
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
} finally {
setLoading(false)
}
}
@@ -130,7 +134,7 @@ export default function ProjectAddFile() {
headerTitle: 'Tambah File',
headerTitleAlign: 'center',
headerRight: () => <ButtonSaveHeader
disable={fileForm.length == 0 ? true : false}
disable={fileForm.length == 0 || loading ? true : false}
category="create"
onPress={() => { handleAddFile() }} />
}}
@@ -162,6 +166,9 @@ export default function ProjectAddFile() {
{
loadingCheck && <ActivityIndicator size="small" />
}
{
loading && <ActivityIndicator size="large" />
}
</View>
</ScrollView>
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">