diff --git a/app/(application)/_layout.tsx b/app/(application)/_layout.tsx index 5f02572..3b32f68 100644 --- a/app/(application)/_layout.tsx +++ b/app/(application)/_layout.tsx @@ -52,7 +52,6 @@ export default function RootLayout() { const checkVersion = async () => { try { const response = await apiGetVersion(); - console.log('response',response) if (response.success && response.data) { const maintenance = response.data.find((item: any) => item.id === 'mobile_maintenance')?.value === 'true'; const latestVersion = response.data.find((item: any) => item.id === 'mobile_latest_version')?.value || '0.0.0'; diff --git a/app/(application)/announcement/[id].tsx b/app/(application)/announcement/[id].tsx index c786929..1c62559 100644 --- a/app/(application)/announcement/[id].tsx +++ b/app/(application)/announcement/[id].tsx @@ -89,9 +89,11 @@ export default function DetailAnnouncement() { } else { Toast.show({ type: 'small', text1: response.message }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Gagal mengambil data' }) + } catch (error: any) { + console.error(error); + const message = error?.response?.data?.message || "Gagal mengambil data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/announcement/create.tsx b/app/(application)/announcement/create.tsx index ea8bccc..98c5a3b 100644 --- a/app/(application)/announcement/create.tsx +++ b/app/(application)/announcement/create.tsx @@ -78,6 +78,7 @@ export default function CreateAnnouncement() { async function handleCreate() { try { setLoading(true) + console.log('jalan') const hasil = await decryptToken(String(token?.current)) const fd = new FormData() @@ -90,7 +91,7 @@ export default function CreateAnnouncement() { } fd.append("data", JSON.stringify( - { user: hasil, groups: divisionMember, ...dataForm } + { user: 'apaya', groups: divisionMember, ...dataForm } )) const response = await apiCreateAnnouncement(fd) @@ -100,11 +101,16 @@ export default function CreateAnnouncement() { Toast.show({ type: 'small', text1: 'Berhasil menambahkan data', }) router.back(); } else { - Toast.show({ type: 'small', text1: 'Gagal menambahkan data', }) + Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error: any) { console.error(error); - Toast.show({ type: 'small', text1: 'Gagal menambahkan data', }) + const message = error?.response?.data?.message || "Tidak dapat terhubung ke server" + + Toast.show({ + type: 'small', + text1: message + }) } finally { setLoading(false) } diff --git a/app/(application)/announcement/edit/[id].tsx b/app/(application)/announcement/edit/[id].tsx index 20de0bb..60c850d 100644 --- a/app/(application)/announcement/edit/[id].tsx +++ b/app/(application)/announcement/edit/[id].tsx @@ -147,9 +147,11 @@ export default function EditAnnouncement() { } else { Toast.show({ type: 'small', text1: 'Gagal mengubah data', }) } - } catch (error) { + } catch (error: any) { console.error(error); - Toast.show({ type: 'small', text1: 'Gagal mengubah data', }) + const message = error?.response?.data?.message || "Gagal mengubah data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } @@ -309,7 +311,7 @@ export default function EditAnnouncement() { Divisi - + { dataMember.map((item: { name: any; Division: any }, index: any) => { return ( diff --git a/app/(application)/banner/[id].tsx b/app/(application)/banner/[id].tsx index 424cbae..a80d1fa 100644 --- a/app/(application)/banner/[id].tsx +++ b/app/(application)/banner/[id].tsx @@ -106,9 +106,11 @@ export default function EditBanner() { } else { Toast.show({ type: 'small', text1: 'Gagal mengupdate data', }) } - } catch (error) { + } catch (error: any) { console.error(error); - Toast.show({ type: 'small', text1: 'Gagal mengupdate data', }) + const message = error?.response?.data?.message || "Gagal mengupdate data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/banner/create.tsx b/app/(application)/banner/create.tsx index 1e092cb..5f769ae 100644 --- a/app/(application)/banner/create.tsx +++ b/app/(application)/banner/create.tsx @@ -88,9 +88,11 @@ export default function CreateBanner() { } else { Toast.show({ type: 'small', text1: 'Gagal menambahkan data', }) } - } catch (error) { + } catch (error: any) { console.error(error); - Toast.show({ type: 'small', text1: 'Gagal menambahkan data', }) + const message = error?.response?.data?.message || "Gagal menambahkan data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/banner/index.tsx b/app/(application)/banner/index.tsx index 8b1a455..dc6ce62 100644 --- a/app/(application)/banner/index.tsx +++ b/app/(application)/banner/index.tsx @@ -56,9 +56,11 @@ export default function BannerList() { } else { Toast.show({ type: 'small', text1: 'Gagal menghapus data', }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error: any) { + console.error(error); + const message = error?.response?.data?.message || "Gagal menghapus data" + + Toast.show({ type: 'small', text1: message }) } finally { setModal(false) } diff --git a/app/(application)/discussion/[id].tsx b/app/(application)/discussion/[id].tsx index 9a4e242..e47e18a 100644 --- a/app/(application)/discussion/[id].tsx +++ b/app/(application)/discussion/[id].tsx @@ -158,8 +158,11 @@ export default function DetailDiscussionGeneral() { Toast.show({ type: 'small', text1: response.message }) } } - } catch (error) { - console.error(error) + } catch (error: any) { + console.error(error); + const message = error?.response?.data?.message || "Gagal menambahkan data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoadingSendKomentar(false) } @@ -175,8 +178,11 @@ export default function DetailDiscussionGeneral() { } else { Toast.show({ type: 'small', text1: response.message }) } - } catch (error) { - console.error(error) + } catch (error: any) { + console.error(error); + const message = error?.response?.data?.message || "Gagal mengupdate data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoadingSendKomentar(false) handleViewEditKomentar() @@ -193,8 +199,11 @@ export default function DetailDiscussionGeneral() { } else { Toast.show({ type: 'small', text1: response.message }) } - } catch (error) { - console.error(error) + } catch (error: any) { + console.error(error); + const message = error?.response?.data?.message || "Gagal menghapus data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoadingSendKomentar(false) setVisible(false) diff --git a/app/(application)/discussion/add-member/[id].tsx b/app/(application)/discussion/add-member/[id].tsx index 2dd0775..f60275f 100644 --- a/app/(application)/discussion/add-member/[id].tsx +++ b/app/(application)/discussion/add-member/[id].tsx @@ -84,9 +84,11 @@ export default function AddMemberDiscussionDetail() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Gagal menambahkan anggota', }) + } catch (error: any) { + console.error(error); + const message = error?.response?.data?.message || "Gagal menambahkan anggota" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/discussion/create.tsx b/app/(application)/discussion/create.tsx index c153e27..421c1ca 100644 --- a/app/(application)/discussion/create.tsx +++ b/app/(application)/discussion/create.tsx @@ -156,9 +156,11 @@ export default function CreateDiscussionGeneral() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error: any) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal menambahkan data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/discussion/edit/[id].tsx b/app/(application)/discussion/edit/[id].tsx index 767f7c8..5d1641e 100644 --- a/app/(application)/discussion/edit/[id].tsx +++ b/app/(application)/discussion/edit/[id].tsx @@ -157,9 +157,11 @@ export default function EditDiscussionGeneral() { } else { Toast.show({ type: 'small', text1: 'Gagal mengubah data', }) } - } catch (error) { + } catch (error: any) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal mengubah data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/discussion/member/[id].tsx b/app/(application)/discussion/member/[id].tsx index 59999a7..7dae308 100644 --- a/app/(application)/discussion/member/[id].tsx +++ b/app/(application)/discussion/member/[id].tsx @@ -67,8 +67,11 @@ export default function MemberDiscussionDetail() { await apiDeleteMemberDiscussionGeneral({ user: hasil, idUser: chooseUser.idUser }, id) Toast.show({ type: 'small', text1: 'Berhasil mengeluarkan anggota dari diskusi', }) handleLoad(false) - } catch (error) { - console.error(error) + } catch (error: any) { + console.error(error); + const message = error?.response?.data?.message || "Gagal mengeluarkan anggota" + + Toast.show({ type: 'small', text1: message }) } finally { setModal(false) } diff --git a/app/(application)/division/[id]/(fitur-division)/calendar/[detail]/add-member.tsx b/app/(application)/division/[id]/(fitur-division)/calendar/[detail]/add-member.tsx index 0ed576c..332ad30 100644 --- a/app/(application)/division/[id]/(fitur-division)/calendar/[detail]/add-member.tsx +++ b/app/(application)/division/[id]/(fitur-division)/calendar/[detail]/add-member.tsx @@ -92,9 +92,11 @@ export default function AddMemberCalendarEvent() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error: any) { + console.error(error); + const message = error?.response?.data?.message || "Gagal menambahkan anggota" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/division/[id]/(fitur-division)/calendar/[detail]/edit.tsx b/app/(application)/division/[id]/(fitur-division)/calendar/[detail]/edit.tsx index 0d6b753..78363a0 100644 --- a/app/(application)/division/[id]/(fitur-division)/calendar/[detail]/edit.tsx +++ b/app/(application)/division/[id]/(fitur-division)/calendar/[detail]/edit.tsx @@ -57,9 +57,11 @@ export default function EditEventCalendar() { setData({ ...response.data, dateStart: moment(response.data.dateStartFormat, 'DD-MM-YYYY').format('DD-MM-YYYY') }) setIdCalendar(response.data.idCalendar) setChoose({ val: response.data.repeatEventTyper, label: valueTypeEventRepeat.find((item) => item.id == response.data.repeatEventTyper)?.name || "" }) - } catch (error) { + } catch (error: any) { console.error(error); - Toast.show({ type: 'small', text1: 'Gagal mendapatkan data', }) + const message = error?.response?.data?.message || "Gagal mendapatkan data" + + Toast.show({ type: 'small', text1: message }) } } @@ -154,9 +156,11 @@ export default function EditEventCalendar() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error: any) { + console.error(error); + const message = error?.response?.data?.message || "Gagal mengubah acara" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/division/[id]/(fitur-division)/calendar/[detail]/index.tsx b/app/(application)/division/[id]/(fitur-division)/calendar/[detail]/index.tsx index 5bdf203..9574196 100644 --- a/app/(application)/division/[id]/(fitur-division)/calendar/[detail]/index.tsx +++ b/app/(application)/division/[id]/(fitur-division)/calendar/[detail]/index.tsx @@ -137,9 +137,11 @@ export default function DetailEventCalendar() { dispatch(setUpdateCalendar({ ...update, member: !update.member })); } Toast.show({ type: 'small', text1: response.message, }) - } catch (error) { + } catch (error: any) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal menghapus anggota" + + Toast.show({ type: 'small', text1: message }) } finally { setModalMember(false) } diff --git a/app/(application)/division/[id]/(fitur-division)/calendar/create-member.tsx b/app/(application)/division/[id]/(fitur-division)/calendar/create-member.tsx index e3d1c17..060268c 100644 --- a/app/(application)/division/[id]/(fitur-division)/calendar/create-member.tsx +++ b/app/(application)/division/[id]/(fitur-division)/calendar/create-member.tsx @@ -83,9 +83,11 @@ export default function CreateCalendarAddMember() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error: any) { + console.error(error); + const message = error?.response?.data?.message || "Gagal membuat acara" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/division/[id]/(fitur-division)/discussion/[detail]/edit.tsx b/app/(application)/division/[id]/(fitur-division)/discussion/[detail]/edit.tsx index 6df69f2..360a9d3 100644 --- a/app/(application)/division/[id]/(fitur-division)/discussion/[detail]/edit.tsx +++ b/app/(application)/division/[id]/(fitur-division)/discussion/[detail]/edit.tsx @@ -89,9 +89,11 @@ export default function DiscussionDivisionEdit() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error: any) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal mengubah data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/division/[id]/(fitur-division)/discussion/[detail]/index.tsx b/app/(application)/division/[id]/(fitur-division)/discussion/[detail]/index.tsx index 7344bc8..e85030f 100644 --- a/app/(application)/division/[id]/(fitur-division)/discussion/[detail]/index.tsx +++ b/app/(application)/division/[id]/(fitur-division)/discussion/[detail]/index.tsx @@ -202,8 +202,11 @@ export default function DiscussionDetail() { setKomentar("") updateTrigger() } - } catch (error) { + } catch (error: any) { console.error(error); + const message = error?.response?.data?.message || "Gagal menambahkan komentar" + + Toast.show({ type: 'small', text1: message }) } finally { setLoadingSend(false); } @@ -222,8 +225,11 @@ export default function DiscussionDetail() { } else { Toast.show({ type: 'small', text1: response.message }) } - } catch (error) { + } catch (error : any ) { console.error(error); + const message = error?.response?.data?.message || "Gagal mengedit komentar" + + Toast.show({ type: 'small', text1: message }) } finally { setLoadingSend(false); handleViewEditKomentar() @@ -243,8 +249,11 @@ export default function DiscussionDetail() { } else { Toast.show({ type: 'small', text1: response.message }) } - } catch (error) { + } catch (error : any ) { console.error(error); + const message = error?.response?.data?.message || "Gagal menghapus komentar" + + Toast.show({ type: 'small', text1: message }) } finally { setLoadingSend(false) setVisible(false) diff --git a/app/(application)/division/[id]/(fitur-division)/discussion/create.tsx b/app/(application)/division/[id]/(fitur-division)/discussion/create.tsx index 2e1c6d7..61d1b0a 100644 --- a/app/(application)/division/[id]/(fitur-division)/discussion/create.tsx +++ b/app/(application)/division/[id]/(fitur-division)/discussion/create.tsx @@ -81,9 +81,11 @@ export default function CreateDiscussionDivision() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error: any) { + console.error(error); + const message = error?.response?.data?.message || "Gagal menambahkan data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/division/[id]/(fitur-division)/document/index.tsx b/app/(application)/division/[id]/(fitur-division)/document/index.tsx index 5db917c..5104754 100644 --- a/app/(application)/division/[id]/(fitur-division)/document/index.tsx +++ b/app/(application)/division/[id]/(fitur-division)/document/index.tsx @@ -235,9 +235,11 @@ export default function DocumentDivision() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal mengubah nama" + + Toast.show({ type: 'small', text1: message }) } finally { setLoadingRename(false) setRename(false) @@ -258,9 +260,11 @@ export default function DocumentDivision() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal menghapus" + + Toast.show({ type: 'small', text1: message }) } } @@ -284,9 +288,11 @@ export default function DocumentDivision() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal membagikan" + + Toast.show({ type: 'small', text1: message }) } finally { setShare(false); } diff --git a/app/(application)/division/[id]/(fitur-division)/task/[detail]/add-file.tsx b/app/(application)/division/[id]/(fitur-division)/task/[detail]/add-file.tsx index 82a5975..52c32f7 100644 --- a/app/(application)/division/[id]/(fitur-division)/task/[detail]/add-file.tsx +++ b/app/(application)/division/[id]/(fitur-division)/task/[detail]/add-file.tsx @@ -120,9 +120,11 @@ export default function TaskDivisionAddFile() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal menambahkan file" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } 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 84d6dca..d212b12 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 @@ -86,9 +86,11 @@ export default function AddMemberTask() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal menambahkan anggota" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/division/[id]/(fitur-division)/task/[detail]/add-task.tsx b/app/(application)/division/[id]/(fitur-division)/task/[detail]/add-task.tsx index 3abd52b..1fb4964 100644 --- a/app/(application)/division/[id]/(fitur-division)/task/[detail]/add-task.tsx +++ b/app/(application)/division/[id]/(fitur-division)/task/[detail]/add-task.tsx @@ -133,9 +133,11 @@ export default function TaskDivisionAddTask() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal menambahkan data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/division/[id]/(fitur-division)/task/[detail]/cancel.tsx b/app/(application)/division/[id]/(fitur-division)/task/[detail]/cancel.tsx index d9d0254..d728f82 100644 --- a/app/(application)/division/[id]/(fitur-division)/task/[detail]/cancel.tsx +++ b/app/(application)/division/[id]/(fitur-division)/task/[detail]/cancel.tsx @@ -62,9 +62,11 @@ export default function TaskDivisionCancel() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal membatalkan kegiatan" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/division/[id]/(fitur-division)/task/[detail]/edit.tsx b/app/(application)/division/[id]/(fitur-division)/task/[detail]/edit.tsx index eaf71b6..9a17686 100644 --- a/app/(application)/division/[id]/(fitur-division)/task/[detail]/edit.tsx +++ b/app/(application)/division/[id]/(fitur-division)/task/[detail]/edit.tsx @@ -80,9 +80,11 @@ export default function TaskDivisionEdit() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal mengubah data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/division/[id]/(fitur-division)/task/[detail]/report.tsx b/app/(application)/division/[id]/(fitur-division)/task/[detail]/report.tsx index 5b8ba7e..8856374 100644 --- a/app/(application)/division/[id]/(fitur-division)/task/[detail]/report.tsx +++ b/app/(application)/division/[id]/(fitur-division)/task/[detail]/report.tsx @@ -80,9 +80,11 @@ export default function TaskDivisionReport() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal mengubah data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/division/[id]/(fitur-division)/task/create.tsx b/app/(application)/division/[id]/(fitur-division)/task/create.tsx index 66b587a..f6d2b34 100644 --- a/app/(application)/division/[id]/(fitur-division)/task/create.tsx +++ b/app/(application)/division/[id]/(fitur-division)/task/create.tsx @@ -105,9 +105,11 @@ export default function CreateTaskDivision() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal menambahkan data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/division/[id]/(fitur-division)/task/update/[detail].tsx b/app/(application)/division/[id]/(fitur-division)/task/update/[detail].tsx index 475e7b0..70c4132 100644 --- a/app/(application)/division/[id]/(fitur-division)/task/update/[detail].tsx +++ b/app/(application)/division/[id]/(fitur-division)/task/update/[detail].tsx @@ -125,9 +125,11 @@ export default function UpdateProjectTaskDivision() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal mengubah data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoadingSubmit(false) } diff --git a/app/(application)/division/[id]/add-member.tsx b/app/(application)/division/[id]/add-member.tsx index 9218098..7c959d5 100644 --- a/app/(application)/division/[id]/add-member.tsx +++ b/app/(application)/division/[id]/add-member.tsx @@ -89,9 +89,11 @@ export default function AddMemberDivision() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error: any) { + console.error(error); + const message = error?.response?.data?.message || "Gagal menambahkan anggota" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/division/[id]/edit.tsx b/app/(application)/division/[id]/edit.tsx index 478d1e3..54901e6 100644 --- a/app/(application)/division/[id]/edit.tsx +++ b/app/(application)/division/[id]/edit.tsx @@ -56,9 +56,11 @@ export default function EditDivision() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error: any) { + console.error(error); + const message = error?.response?.data?.message || "Gagal mengubah data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/division/[id]/info.tsx b/app/(application)/division/[id]/info.tsx index 0132cb9..b8907be 100644 --- a/app/(application)/division/[id]/info.tsx +++ b/app/(application)/division/[id]/info.tsx @@ -78,9 +78,11 @@ export default function InformationDivision() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error: any) { + console.error(error); + const message = error?.response?.data?.message || "Gagal mengeluarkan anggota" + + Toast.show({ type: 'small', text1: message }) } finally { setModal(false) } @@ -96,9 +98,11 @@ export default function InformationDivision() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error: any) { + console.error(error); + const message = error?.response?.data?.message || "Gagal mengubah status admin" + + Toast.show({ type: 'small', text1: message }) } finally { setModal(false) } diff --git a/app/(application)/division/[id]/report.tsx b/app/(application)/division/[id]/report.tsx index cadbdf0..e21d661 100644 --- a/app/(application)/division/[id]/report.tsx +++ b/app/(application)/division/[id]/report.tsx @@ -94,8 +94,11 @@ export default function ReportDivision() { } else { Toast.show({ type: 'small', text1: response.message, }); } - } catch (error) { + } catch (error: any) { console.error(error); + const message = error?.response?.data?.message || "Gagal mengambil data" + + Toast.show({ type: 'small', text1: message }) } } diff --git a/app/(application)/division/create.tsx b/app/(application)/division/create.tsx index 516951a..74170da 100644 --- a/app/(application)/division/create.tsx +++ b/app/(application)/division/create.tsx @@ -77,9 +77,11 @@ export default function CreateDivision() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error: any) { + console.error(error); + const message = error?.response?.data?.message || "Gagal menambahkan data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoadingBtn(false) } diff --git a/app/(application)/division/create/add-admin-division.tsx b/app/(application)/division/create/add-admin-division.tsx index b8618a8..7c7950d 100644 --- a/app/(application)/division/create/add-admin-division.tsx +++ b/app/(application)/division/create/add-admin-division.tsx @@ -66,9 +66,11 @@ export default function CreateDivisionAddAdmin() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal menambahkan data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/division/report.tsx b/app/(application)/division/report.tsx index 61399bd..aebc19e 100644 --- a/app/(application)/division/report.tsx +++ b/app/(application)/division/report.tsx @@ -112,8 +112,11 @@ export default function Report() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error: any) { console.error(error); + const message = error?.response?.data?.message || "Gagal mengambil data" + + Toast.show({ type: 'small', text1: message }) } } diff --git a/app/(application)/edit-profile.tsx b/app/(application)/edit-profile.tsx index 8f8e9e9..bc544f9 100644 --- a/app/(application)/edit-profile.tsx +++ b/app/(application)/edit-profile.tsx @@ -188,9 +188,14 @@ export default function EditProfile() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Gagal mengupdate data', }) + } catch (error: any) { + console.error(error); + const message = error?.response?.data?.message || "Gagal mengupdate data" + + Toast.show({ + type: 'small', + text1: message + }) } finally { setLoading(false) } diff --git a/app/(application)/member/[id].tsx b/app/(application)/member/[id].tsx index 811ca10..71c0165 100644 --- a/app/(application)/member/[id].tsx +++ b/app/(application)/member/[id].tsx @@ -55,9 +55,11 @@ export default function MemberDetail() { } else { Toast.show({ type: 'small', text1: response.message }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Gagal mengambil data' }) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal mengambil data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/member/create.tsx b/app/(application)/member/create.tsx index dfaed74..91efcd7 100644 --- a/app/(application)/member/create.tsx +++ b/app/(application)/member/create.tsx @@ -185,9 +185,11 @@ export default function CreateMember() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal menambahkan data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/member/edit/[id].tsx b/app/(application)/member/edit/[id].tsx index 8880a51..cb45140 100644 --- a/app/(application)/member/edit/[id].tsx +++ b/app/(application)/member/edit/[id].tsx @@ -211,9 +211,11 @@ export default function EditMember() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal menambahkan data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/position/index.tsx b/app/(application)/position/index.tsx index a2f98e6..47fe3a9 100644 --- a/app/(application)/position/index.tsx +++ b/app/(application)/position/index.tsx @@ -88,8 +88,11 @@ export default function Index() { const hasil = await decryptToken(String(token?.current)) const response = await apiDeletePosition({ user: hasil, isActive: chooseData.active }, chooseData.id) dispatch(setUpdatePosition(!update)) - } catch (error) { - console.error(error) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal menghapus data" + + Toast.show({ type: 'small', text1: message }) } finally { setModal(false) Toast.show({ type: 'small', text1: 'Berhasil mengupdate data', }) @@ -107,8 +110,11 @@ export default function Index() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal mengubah data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoadingSubmit(false) setVisibleEdit(false) diff --git a/app/(application)/project/[id]/add-file.tsx b/app/(application)/project/[id]/add-file.tsx index cdde484..dd88cab 100644 --- a/app/(application)/project/[id]/add-file.tsx +++ b/app/(application)/project/[id]/add-file.tsx @@ -118,9 +118,11 @@ export default function ProjectAddFile() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal menambahkan data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/project/[id]/add-member.tsx b/app/(application)/project/[id]/add-member.tsx index e177d93..10af1ab 100644 --- a/app/(application)/project/[id]/add-member.tsx +++ b/app/(application)/project/[id]/add-member.tsx @@ -45,9 +45,11 @@ export default function AddMemberProject() { setIdGroup(responseGroup.data.idGroup) const responsemember = await apiGetUser({ user: hasil, active: "true", search: search, group: String(responseGroup.data.idGroup) }) setData(responsemember.data.filter((i: any) => i.idUserRole != 'supadmin')) - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal mengambil data" + + Toast.show({ type: 'small', text1: message }) } } @@ -86,9 +88,11 @@ export default function AddMemberProject() { dispatch(setUpdateProject({ ...update, member: !update.member })) router.back() } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal menambahkan anggota" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/project/[id]/add-task.tsx b/app/(application)/project/[id]/add-task.tsx index cfe51da..2672b0c 100644 --- a/app/(application)/project/[id]/add-task.tsx +++ b/app/(application)/project/[id]/add-task.tsx @@ -126,9 +126,11 @@ export default function ProjectAddTask() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal menambahkan data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/project/[id]/cancel.tsx b/app/(application)/project/[id]/cancel.tsx index 8246be5..6f73528 100644 --- a/app/(application)/project/[id]/cancel.tsx +++ b/app/(application)/project/[id]/cancel.tsx @@ -58,9 +58,11 @@ export default function ProjectCancel() { Toast.show({ type: 'small', text1: 'Berhasil membatalkan kegiatan', }) router.back(); } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal membatalkan kegiatan" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/project/[id]/edit.tsx b/app/(application)/project/[id]/edit.tsx index 5d4c941..50fc0c6 100644 --- a/app/(application)/project/[id]/edit.tsx +++ b/app/(application)/project/[id]/edit.tsx @@ -77,9 +77,11 @@ export default function EditProject() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal mengubah data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/project/[id]/report.tsx b/app/(application)/project/[id]/report.tsx index d3e102d..77f67c7 100644 --- a/app/(application)/project/[id]/report.tsx +++ b/app/(application)/project/[id]/report.tsx @@ -77,9 +77,11 @@ export default function ReportProject() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal mengubah data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/project/create.tsx b/app/(application)/project/create.tsx index 83dbfd7..34de7be 100644 --- a/app/(application)/project/create.tsx +++ b/app/(application)/project/create.tsx @@ -151,9 +151,11 @@ export default function CreateProject() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal menambahkan data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoading(false) } diff --git a/app/(application)/project/update/[detail].tsx b/app/(application)/project/update/[detail].tsx index f0e75bb..fe77ee8 100644 --- a/app/(application)/project/update/[detail].tsx +++ b/app/(application)/project/update/[detail].tsx @@ -118,9 +118,11 @@ export default function UpdateProjectTask() { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal mengubah data" + + Toast.show({ type: 'small', text1: message }) } finally { setLoadingSubmit(false) } diff --git a/app/(application)/search.tsx b/app/(application)/search.tsx index 401bfa7..6541b76 100644 --- a/app/(application)/search.tsx +++ b/app/(application)/search.tsx @@ -65,9 +65,14 @@ export default function Search() { setDataDivisi([]) setDataProject([]) } - } catch (error) { - console.error(error) - return Toast.show({ type: 'small', text1: 'Gagal melakukan pencarian', }) + } catch (error: any) { + console.error(error); + const message = error?.response?.data?.message || "Gagal melakukan pencarian" + + Toast.show({ + type: 'small', + text1: message + }) } } diff --git a/components/auth/viewLogin.tsx b/components/auth/viewLogin.tsx index 64bf6f2..92068f1 100644 --- a/components/auth/viewLogin.tsx +++ b/components/auth/viewLogin.tsx @@ -38,13 +38,18 @@ export default function ViewLogin({ onValidate }: Props) { if (responseOtp == 200) { await AsyncStorage.setItem('user', response.id) return onValidate({ phone: `62${phone}`, otp }) + } else { + return Toast.show({ type: 'small', text1: 'Gagal mengirim kode verifikasi', position: 'bottom' }) } } } else { return Toast.show({ type: 'small', text1: response.message, position: 'bottom' }) } - } catch (error) { - return Toast.show({ type: 'small', text1: `Terjadi kesalahan, coba lagi`, position: 'bottom' }) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal login" + + Toast.show({ type: 'small', text1: message }) } finally { setLoadingLogin(false) } diff --git a/components/calendar/headerCalendarDetail.tsx b/components/calendar/headerCalendarDetail.tsx index b7a2839..9e3cefe 100644 --- a/components/calendar/headerCalendarDetail.tsx +++ b/components/calendar/headerCalendarDetail.tsx @@ -38,9 +38,11 @@ export default function HeaderRightCalendarDetail({ id, idReminder }: Props) { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal menghapus data" + + Toast.show({ type: 'small', text1: message }) } finally { setVisible(false) } diff --git a/components/discussion/headerDiscussionDetail.tsx b/components/discussion/headerDiscussionDetail.tsx index 454e24a..1d5a200 100644 --- a/components/discussion/headerDiscussionDetail.tsx +++ b/components/discussion/headerDiscussionDetail.tsx @@ -40,9 +40,11 @@ export default function HeaderRightDiscussionDetail({ id, status, isActive }: Pr } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal mengubah data" + + Toast.show({ type: 'small', text1: message }) } finally { setVisible(false) } @@ -59,9 +61,11 @@ export default function HeaderRightDiscussionDetail({ id, status, isActive }: Pr } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal mengubah data" + + Toast.show({ type: 'small', text1: message }) } finally { setVisible(false) } diff --git a/components/division/headerDivisionInfo.tsx b/components/division/headerDivisionInfo.tsx index 7091161..b6c113d 100644 --- a/components/division/headerDivisionInfo.tsx +++ b/components/division/headerDivisionInfo.tsx @@ -37,9 +37,11 @@ export default function HeaderRightDivisionInfo({ id, active }: Props) { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal mengubah status" + + Toast.show({ type: 'small', text1: message }) } finally { setVisible(false) } diff --git a/components/document/headerDocument.tsx b/components/document/headerDocument.tsx index 8837ad4..b3a3a40 100644 --- a/components/document/headerDocument.tsx +++ b/components/document/headerDocument.tsx @@ -40,9 +40,11 @@ export default function HeaderRightDocument({ path, isMember }: { path: string, } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal membuat folder" + + Toast.show({ type: 'small', text1: message }) } finally { setLoadingFolder(false) setNewFolder(false) @@ -93,9 +95,11 @@ export default function HeaderRightDocument({ path, isMember }: { path: string, } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal mengunggah file" + + Toast.show({ type: 'small', text1: message }) } finally { setVisible(false) setLoading(false) diff --git a/components/document/modalMore.tsx b/components/document/modalMore.tsx index 2f82955..2d4a2a5 100644 --- a/components/document/modalMore.tsx +++ b/components/document/modalMore.tsx @@ -71,9 +71,11 @@ export default function ModalMore({ } else { Toast.show({ type: 'small', text1: response.message, }); } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }); + const message = error?.response?.data?.message || "Gagal memindahkan file" + + Toast.show({ type: 'small', text1: message }) } finally { setIsCut(false); onClose(); @@ -95,9 +97,11 @@ export default function ModalMore({ } else { Toast.show({ type: 'small', text1: response.message, }); } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }); + const message = error?.response?.data?.message || "Gagal menyalin file" + + Toast.show({ type: 'small', text1: message }) } finally { setIsCopy(false); onClose(); diff --git a/components/document/modalNewFolder.tsx b/components/document/modalNewFolder.tsx index 5635e12..a790c74 100644 --- a/components/document/modalNewFolder.tsx +++ b/components/document/modalNewFolder.tsx @@ -29,9 +29,11 @@ export function ModalNewFolder({ path, onCreated }: { path: string, onCreated: ( } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal membuat folder" + + Toast.show({ type: 'small', text1: message }) } finally { onCreated() setLoadingFolder(false) diff --git a/components/member/headerMemberDetail.tsx b/components/member/headerMemberDetail.tsx index 6e30e10..3b8044c 100644 --- a/components/member/headerMemberDetail.tsx +++ b/components/member/headerMemberDetail.tsx @@ -37,8 +37,11 @@ export default function HeaderRightMemberDetail({ active, id }: Props) { } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { - console.error(error) + } catch (error : any ) { + console.error(error); + const message = error?.response?.data?.message || "Gagal mengupdate data" + + Toast.show({ type: 'small', text1: message }) } finally { setVisible(false) } diff --git a/components/project/headerProjectDetail.tsx b/components/project/headerProjectDetail.tsx index 3f5a562..d29f084 100644 --- a/components/project/headerProjectDetail.tsx +++ b/components/project/headerProjectDetail.tsx @@ -44,8 +44,11 @@ export default function HeaderRightProjectDetail({ id, status }: Props) { } else { Toast.show({ type: 'small', text1: 'Gagal menghapus kegiatan', }) } - } catch (error) { + } catch (error :any ) { console.error(error) + const message = error?.response?.data?.message || "Gagal menghapus kegiatan" + + Toast.show({ type: 'small', text1: message }) } finally { setVisible(false) } @@ -61,8 +64,11 @@ export default function HeaderRightProjectDetail({ id, status }: Props) { } else { Toast.show({ type: 'small', text1: 'Gagal menambahkan link', }) } - } catch (error) { + } catch (error :any ) { console.error(error) + const message = error?.response?.data?.message || "Gagal menambahkan link" + + Toast.show({ type: 'small', text1: message }) } finally { setAddLink(false) } diff --git a/components/project/sectionFile.tsx b/components/project/sectionFile.tsx index 32f29ce..c4643dd 100644 --- a/components/project/sectionFile.tsx +++ b/components/project/sectionFile.tsx @@ -86,9 +86,11 @@ export default function SectionFile({ status, member, refreshing }: { status: nu } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal menghapus file" + + Toast.show({ type: 'small', text1: message }) } finally { setModal(false) } diff --git a/components/project/sectionLink.tsx b/components/project/sectionLink.tsx index ab5a749..5685007 100644 --- a/components/project/sectionLink.tsx +++ b/components/project/sectionLink.tsx @@ -68,9 +68,11 @@ export default function SectionLink({ status, member, refreshing }: { status: nu } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal menghapus link" + + Toast.show({ type: 'small', text1: message }) } finally { setModal(false) } diff --git a/components/project/sectionMember.tsx b/components/project/sectionMember.tsx index 5050309..9999ec5 100644 --- a/components/project/sectionMember.tsx +++ b/components/project/sectionMember.tsx @@ -88,8 +88,11 @@ export default function SectionMember({ status, refreshing }: { status: number | dispatch(setUpdateProject({ ...update, member: !update.member })) setModal(false); } - } catch (error) { + } catch (error : any ) { console.error(error); + const message = error?.response?.data?.message || "Gagal menghapus anggota" + + Toast.show({ type: 'small', text1: message }) } } diff --git a/components/project/sectionTanggalTugas.tsx b/components/project/sectionTanggalTugas.tsx index a5619fa..183adee 100644 --- a/components/project/sectionTanggalTugas.tsx +++ b/components/project/sectionTanggalTugas.tsx @@ -91,8 +91,11 @@ export default function SectionTanggalTugasProject({ status, member, refreshing setSelect(false); Toast.show({ type: 'small', text1: 'Berhasil mengubah data', }) } - } catch (error) { + } catch (error : any ) { console.error(error); + const message = error?.response?.data?.message || "Gagal mengubah data" + + Toast.show({ type: 'small', text1: message }) } } @@ -108,8 +111,11 @@ export default function SectionTanggalTugasProject({ status, member, refreshing setModal(false); Toast.show({ type: 'small', text1: 'Berhasil menghapus data', }) } - } catch (error) { + } catch (error : any ) { console.error(error); + const message = error?.response?.data?.message || "Gagal menghapus data" + + Toast.show({ type: 'small', text1: message }) } } diff --git a/components/task/headerTaskDetail.tsx b/components/task/headerTaskDetail.tsx index 83fe4db..6d1e29c 100644 --- a/components/task/headerTaskDetail.tsx +++ b/components/task/headerTaskDetail.tsx @@ -45,8 +45,11 @@ export default function HeaderRightTaskDetail({ id, division, status, isAdminDiv } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error) + const message = error?.response?.data?.message || "Gagal menghapus tugas" + + Toast.show({ type: 'small', text1: message }) } finally { setVisible(false) } @@ -62,8 +65,11 @@ export default function HeaderRightTaskDetail({ id, division, status, isAdminDiv } else { Toast.show({ type: 'small', text1: 'Gagal menambahkan link', }) } - } catch (error) { + } catch (error : any ) { console.error(error) + const message = error?.response?.data?.message || "Gagal menambahkan link" + + Toast.show({ type: 'small', text1: message }) } finally { setAddLink(false) } diff --git a/components/task/sectionFileTask.tsx b/components/task/sectionFileTask.tsx index c55a0ad..66d8675 100644 --- a/components/task/sectionFileTask.tsx +++ b/components/task/sectionFileTask.tsx @@ -119,9 +119,11 @@ export default function SectionFileTask({ refreshing, isMemberDivision }: { refr } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal menghapus file" + + Toast.show({ type: 'small', text1: message }) } finally { setModal(false) } diff --git a/components/task/sectionLinkTask.tsx b/components/task/sectionLinkTask.tsx index 5c08587..db89d58 100644 --- a/components/task/sectionLinkTask.tsx +++ b/components/task/sectionLinkTask.tsx @@ -62,9 +62,11 @@ export default function SectionLinkTask({ refreshing, isMemberDivision }: { refr } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + const message = error?.response?.data?.message || "Gagal menghapus link" + + Toast.show({ type: 'small', text1: message }) } finally { setModal(false) } diff --git a/components/task/sectionMemberTask.tsx b/components/task/sectionMemberTask.tsx index 7e2cc45..61f3f0d 100644 --- a/components/task/sectionMemberTask.tsx +++ b/components/task/sectionMemberTask.tsx @@ -88,9 +88,11 @@ export default function SectionMemberTask({ refreshing, isAdminDivision }: { ref } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Gagal menghapus anggota', }) + const message = error?.response?.data?.message || "Gagal menghapus anggota" + + Toast.show({ type: 'small', text1: message }) } finally { setModal(false); } diff --git a/components/task/sectionTanggalTugasTask.tsx b/components/task/sectionTanggalTugasTask.tsx index e365afd..c23022d 100644 --- a/components/task/sectionTanggalTugasTask.tsx +++ b/components/task/sectionTanggalTugasTask.tsx @@ -73,9 +73,11 @@ export default function SectionTanggalTugasTask({ refreshing, isMemberDivision } } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Gagal mengubah data', }) + const message = error?.response?.data?.message || "Gagal mengubah data" + + Toast.show({ type: 'small', text1: message }) } finally { setSelect(false) } @@ -109,9 +111,11 @@ export default function SectionTanggalTugasTask({ refreshing, isMemberDivision } } else { Toast.show({ type: 'small', text1: response.message, }) } - } catch (error) { + } catch (error : any ) { console.error(error); - Toast.show({ type: 'small', text1: 'Gagal menghapus data', }) + const message = error?.response?.data?.message || "Gagal menghapus data" + + Toast.show({ type: 'small', text1: message }) } finally { setModal(false); }