upd: button save
Deskripsi: - disable button saat udh submit No Issues
This commit is contained in:
@@ -31,6 +31,7 @@ export default function AddMemberProject() {
|
||||
const [idGroup, setIdGroup] = useState('')
|
||||
const [selectMember, setSelectMember] = useState<any[]>([])
|
||||
const [search, setSearch] = useState('')
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
async function handleLoad() {
|
||||
try {
|
||||
@@ -43,6 +44,7 @@ export default function AddMemberProject() {
|
||||
setData(responsemember.data.filter((i: any) => i.idUserRole != 'supadmin'))
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +75,7 @@ export default function AddMemberProject() {
|
||||
|
||||
async function handleAddMember() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiAddMemberProject({ id: id, data: { user: hasil, member: selectMember } })
|
||||
if (response.success) {
|
||||
@@ -82,6 +85,9 @@ export default function AddMemberProject() {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +102,7 @@ export default function AddMemberProject() {
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
category="update"
|
||||
disable={selectMember.length > 0 ? false : true}
|
||||
disable={selectMember.length == 0 || loading ? true : false}
|
||||
onPress={() => {
|
||||
handleAddMember()
|
||||
}}
|
||||
|
||||
@@ -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() }}
|
||||
/>
|
||||
|
||||
@@ -19,6 +19,7 @@ export default function ProjectCancel() {
|
||||
const [reason, setReason] = useState("");
|
||||
const [error, setError] = useState(false);
|
||||
const [disable, setDisable] = useState(false);
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
|
||||
function onValidation(val: string) {
|
||||
@@ -44,6 +45,7 @@ export default function ProjectCancel() {
|
||||
|
||||
async function handleCancel() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const hasil = await decryptToken(String(token?.current));
|
||||
const response = await apiCancelProject({
|
||||
reason: reason,
|
||||
@@ -56,6 +58,9 @@ export default function ProjectCancel() {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +79,7 @@ export default function ProjectCancel() {
|
||||
headerTitleAlign: "center",
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
disable={disable}
|
||||
disable={disable || loading}
|
||||
category="cancel"
|
||||
onPress={() => {
|
||||
handleCancel();
|
||||
|
||||
@@ -19,6 +19,7 @@ export default function EditProject() {
|
||||
const [judul, setJudul] = useState("");
|
||||
const [error, setError] = useState(false);
|
||||
const [disable, setDisable] = useState(false);
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
async function handleLoad() {
|
||||
try {
|
||||
@@ -59,6 +60,7 @@ export default function EditProject() {
|
||||
|
||||
async function handleUpdate() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const hasil = await decryptToken(String(token?.current));
|
||||
const response = await apiEditProject({
|
||||
name: judul,
|
||||
@@ -68,9 +70,14 @@ export default function EditProject() {
|
||||
dispatch(setUpdateProject({ ...update, data: !update.data }))
|
||||
Toast.show({ type: 'small', text1: 'Berhasil mengubah 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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +98,7 @@ export default function EditProject() {
|
||||
headerTitleAlign: "center",
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
disable={disable}
|
||||
disable={disable || loading}
|
||||
category="update"
|
||||
onPress={() => { handleUpdate() }}
|
||||
/>
|
||||
|
||||
@@ -29,6 +29,7 @@ import Toast from "react-native-toast-message";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
export default function CreateProject() {
|
||||
const [loading, setLoading] =useState(false)
|
||||
const { token, decryptToken } = useAuthSession();
|
||||
const [chooseGroup, setChooseGroup] = useState({ val: "", label: "" });
|
||||
const dispatch = useDispatch();
|
||||
@@ -102,6 +103,7 @@ export default function CreateProject() {
|
||||
|
||||
async function handleCreate() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const fd = new FormData()
|
||||
|
||||
@@ -127,6 +129,9 @@ export default function CreateProject() {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
|
||||
}finally{
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +183,7 @@ export default function CreateProject() {
|
||||
headerTitleAlign: "center",
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
disable={disableBtn}
|
||||
disable={disableBtn || loading}
|
||||
category="create"
|
||||
onPress={() => {
|
||||
handleCreate()
|
||||
|
||||
@@ -24,6 +24,7 @@ export default function UpdateProjectTask() {
|
||||
const [year, setYear] = useState<any>()
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [disableBtn, setDisableBtn] = useState(false)
|
||||
const [loadingSubmit, setLoadingSubmit] = useState(false)
|
||||
|
||||
const [title, setTitle] = useState('')
|
||||
const [error, setError] = useState({
|
||||
@@ -65,15 +66,21 @@ export default function UpdateProjectTask() {
|
||||
|
||||
async function handleEdit() {
|
||||
try {
|
||||
setLoadingSubmit(true)
|
||||
const hasil = await decryptToken(String(token?.current));
|
||||
const response = await apiEditProjectTask({ data: { title, dateStart: dayjs(range.startDate).format("YYYY-MM-DD"), dateEnd: dayjs(range.endDate).format("YYYY-MM-DD"), user: hasil }, id: detail });
|
||||
if (response.success) {
|
||||
dispatch(setUpdateProject({ ...update, task: !update.task, progress: !update.progress }))
|
||||
Toast.show({ type: 'small', text1: 'Berhasil mengubah data', })
|
||||
router.back();
|
||||
} else {
|
||||
Toast.show({ type: 'small', text1: response.message, })
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
|
||||
} finally {
|
||||
setLoadingSubmit(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +115,7 @@ export default function UpdateProjectTask() {
|
||||
headerTitle: 'Edit Tanggal dan Tugas',
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => <ButtonSaveHeader
|
||||
disable={disableBtn}
|
||||
disable={disableBtn || loadingSubmit}
|
||||
category="update"
|
||||
onPress={() => { handleEdit() }}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user