upd: project dan task divisi
Deskripsi: - menambahkan loading saat tambah file - button submit disable saat loading] No Issues
This commit is contained in:
@@ -32,6 +32,7 @@ export default function TaskDivisionAddFile() {
|
|||||||
const [loadingCheck, setLoadingCheck] = useState(false);
|
const [loadingCheck, setLoadingCheck] = useState(false);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const update = useSelector((state: any) => state.taskUpdate);
|
const update = useSelector((state: any) => state.taskUpdate);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
const pickDocumentAsync = async () => {
|
const pickDocumentAsync = async () => {
|
||||||
let result = await DocumentPicker.getDocumentAsync({
|
let result = await DocumentPicker.getDocumentAsync({
|
||||||
@@ -90,6 +91,7 @@ export default function TaskDivisionAddFile() {
|
|||||||
|
|
||||||
async function handleAddFile() {
|
async function handleAddFile() {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
const hasil = await decryptToken(String(token?.current));
|
const hasil = await decryptToken(String(token?.current));
|
||||||
const fd = new FormData();
|
const fd = new FormData();
|
||||||
|
|
||||||
@@ -119,6 +121,8 @@ export default function TaskDivisionAddFile() {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
|
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +142,7 @@ export default function TaskDivisionAddFile() {
|
|||||||
headerRight: () => (
|
headerRight: () => (
|
||||||
<ButtonSaveHeader
|
<ButtonSaveHeader
|
||||||
category="create"
|
category="create"
|
||||||
disable={fileForm.length == 0 ? true : false}
|
disable={fileForm.length == 0 || loading ? true : false}
|
||||||
onPress={() => { handleAddFile() }}
|
onPress={() => { handleAddFile() }}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
@@ -171,6 +175,9 @@ export default function TaskDivisionAddFile() {
|
|||||||
{
|
{
|
||||||
loadingCheck && <ActivityIndicator size="small" />
|
loadingCheck && <ActivityIndicator size="small" />
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
loading && <ActivityIndicator size="large" />
|
||||||
|
}
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export default function ProjectAddFile() {
|
|||||||
const [loadingCheck, setLoadingCheck] = useState(false)
|
const [loadingCheck, setLoadingCheck] = useState(false)
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const update = useSelector((state: any) => state.projectUpdate)
|
const update = useSelector((state: any) => state.projectUpdate)
|
||||||
|
const [loading, setLoading] = useState(false)
|
||||||
|
|
||||||
const pickDocumentAsync = async () => {
|
const pickDocumentAsync = async () => {
|
||||||
let result = await DocumentPicker.getDocumentAsync({
|
let result = await DocumentPicker.getDocumentAsync({
|
||||||
@@ -86,6 +87,7 @@ export default function ProjectAddFile() {
|
|||||||
|
|
||||||
async function handleAddFile() {
|
async function handleAddFile() {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
const hasil = await decryptToken(String(token?.current))
|
const hasil = await decryptToken(String(token?.current))
|
||||||
const fd = new FormData();
|
const fd = new FormData();
|
||||||
|
|
||||||
@@ -116,6 +118,8 @@ export default function ProjectAddFile() {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
|
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +134,7 @@ export default function ProjectAddFile() {
|
|||||||
headerTitle: 'Tambah File',
|
headerTitle: 'Tambah File',
|
||||||
headerTitleAlign: 'center',
|
headerTitleAlign: 'center',
|
||||||
headerRight: () => <ButtonSaveHeader
|
headerRight: () => <ButtonSaveHeader
|
||||||
disable={fileForm.length == 0 ? true : false}
|
disable={fileForm.length == 0 || loading ? true : false}
|
||||||
category="create"
|
category="create"
|
||||||
onPress={() => { handleAddFile() }} />
|
onPress={() => { handleAddFile() }} />
|
||||||
}}
|
}}
|
||||||
@@ -162,6 +166,9 @@ export default function ProjectAddFile() {
|
|||||||
{
|
{
|
||||||
loadingCheck && <ActivityIndicator size="small" />
|
loadingCheck && <ActivityIndicator size="small" />
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
loading && <ActivityIndicator size="large" />
|
||||||
|
}
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
||||||
|
|||||||
Reference in New Issue
Block a user