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

@@ -41,6 +41,7 @@ export default function CreateMember() {
const [disableBtn, setDisableBtn] = useState(true)
const [valChoose, setValChoose] = useState("")
const [imgForm, setImgForm] = useState<any>()
const [loading, setLoading] = useState(false)
const [error, setError] = useState({
group: false,
position: false,
@@ -152,6 +153,7 @@ export default function CreateMember() {
async function handleCreate() {
try {
setLoading(true)
const hasil = await decryptToken(String(token?.current))
const fd = new FormData()
@@ -179,6 +181,9 @@ export default function CreateMember() {
}
} catch (error) {
console.error(error)
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
}finally{
setLoading(false)
}
}
@@ -215,7 +220,7 @@ export default function CreateMember() {
headerTitleAlign: "center",
headerRight: () => (
<ButtonSaveHeader
disable={disableBtn}
disable={disableBtn || loading}
category="create"
onPress={() => { handleCreate() }}
/>

View File

@@ -52,6 +52,7 @@ export default function EditMember() {
const [disableBtn, setDisableBtn] = useState(false)
const [valChoose, setValChoose] = useState("")
const [imgForm, setImgForm] = useState<any>();
const [loading, setLoading] = useState(false)
const [data, setData] = useState<Props>({
id: "",
name: "",
@@ -175,6 +176,7 @@ export default function EditMember() {
async function handleEdit() {
try {
setLoading(true)
const hasil = await decryptToken(String(token?.current))
const fd = new FormData()
@@ -203,7 +205,9 @@ export default function EditMember() {
}
} catch (error) {
console.error(error)
Toast.show({ type: 'small', text1: 'Gagal mengupdate data', })
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
}finally{
setLoading(false)
}
}
@@ -242,7 +246,7 @@ export default function EditMember() {
headerTitleAlign: "center",
headerRight: () => (
<ButtonSaveHeader
disable={disableBtn}
disable={disableBtn || loading}
category="update"
onPress={() => {
handleEdit()