upd: button save

Deskripsi:
- disable button saat udh submit

No Issues
This commit is contained in:
2025-08-04 13:56:33 +08:00
parent b7c44109a1
commit fafb52d87c
31 changed files with 211 additions and 64 deletions

View File

@@ -38,6 +38,7 @@ export default function ProjectAddTask() {
title: false,
})
const [title, setTitle] = useState('');
const [loading, setLoading] = useState(false)
const from = range.startDate
? dayjs(range.startDate).format("DD-MM-YYYY")
@@ -69,15 +70,21 @@ export default function ProjectAddTask() {
async function handleCreate() {
try {
setLoading(true)
const hasil = await decryptToken(String(token?.current));
const response = await apiCreateProjectTask({ data: { name: title, dateStart: dayjs(range.startDate).format("YYYY-MM-DD"), dateEnd: dayjs(range.endDate).format("YYYY-MM-DD"), user: hasil }, id });
if (response.success) {
dispatch(setUpdateProject({ ...update, task: !update.task, progress: !update.progress }))
Toast.show({ type: 'small', text1: 'Berhasil menambah data', })
router.back();
}else{
Toast.show({ type: 'small', text1: response.message, })
}
} catch (error) {
console.error(error);
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
} finally {
setLoading(false)
}
}
@@ -96,7 +103,7 @@ export default function ProjectAddTask() {
headerTitleAlign: "center",
headerRight: () => (
<ButtonSaveHeader
disable={disable}
disable={disable || loading}
category="create"
onPress={() => { handleCreate() }}
/>