upd : position
Deskripsi: - validasi button form tambah jabatan - validasi disable button form edit jabatan No Issues
This commit is contained in:
@@ -251,7 +251,7 @@ export default function Index() {
|
|||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View style={Styles.mb30}>
|
<View style={Styles.mb30}>
|
||||||
<ButtonForm text="SIMPAN" onPress={() => { checkForm() }} />
|
<ButtonForm text="SIMPAN" onPress={() => { handleEdit() }} disabled={Object.values(error).some((v) => v == true) || chooseData.name == ""} />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</DrawerBottom>
|
</DrawerBottom>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { apiCreatePosition } from "@/lib/api"
|
|||||||
import { setUpdatePosition } from "@/lib/positionSlice"
|
import { setUpdatePosition } from "@/lib/positionSlice"
|
||||||
import { useAuthSession } from "@/providers/AuthProvider"
|
import { useAuthSession } from "@/providers/AuthProvider"
|
||||||
import { AntDesign } from "@expo/vector-icons"
|
import { AntDesign } from "@expo/vector-icons"
|
||||||
import { useState } from "react"
|
import { useEffect, useState } from "react"
|
||||||
import { View } from "react-native"
|
import { View } from "react-native"
|
||||||
import Toast from "react-native-toast-message"
|
import Toast from "react-native-toast-message"
|
||||||
import { useDispatch, useSelector } from "react-redux"
|
import { useDispatch, useSelector } from "react-redux"
|
||||||
@@ -26,6 +26,7 @@ export default function HeaderRightPositionList() {
|
|||||||
const [isFilter, setFilter] = useState(false)
|
const [isFilter, setFilter] = useState(false)
|
||||||
const [isSelect, setSelect] = useState(false)
|
const [isSelect, setSelect] = useState(false)
|
||||||
const [choose, setChoose] = useState({ val: '', label: '' })
|
const [choose, setChoose] = useState({ val: '', label: '' })
|
||||||
|
const [disable, setDisable] = useState(true)
|
||||||
const [dataForm, setDataForm] = useState({
|
const [dataForm, setDataForm] = useState({
|
||||||
name: "",
|
name: "",
|
||||||
idGroup: "",
|
idGroup: "",
|
||||||
@@ -54,27 +55,21 @@ export default function HeaderRightPositionList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function checkAll() {
|
function checkAll() {
|
||||||
let nilai = true
|
let nilai = false
|
||||||
if (dataForm.name == "") {
|
if (dataForm.name == "") {
|
||||||
setError(error => ({ ...error, name: true }))
|
nilai = true
|
||||||
nilai = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((entityUser.role == "supadmin" || entityUser.role == "developer") && (dataForm.idGroup == "" || String(dataForm.idGroup) == "null")) {
|
if ((entityUser.role == "supadmin" || entityUser.role == "developer") && (dataForm.idGroup == "" || String(dataForm.idGroup) == "null")) {
|
||||||
setError(error => ({ ...error, idGroup: true }))
|
nilai = true
|
||||||
nilai = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nilai
|
setDisable(nilai)
|
||||||
}
|
|
||||||
|
|
||||||
function onCheck() {
|
|
||||||
const check = checkAll()
|
|
||||||
if (!check)
|
|
||||||
return false
|
|
||||||
handleTambah()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
checkAll()
|
||||||
|
}, [dataForm])
|
||||||
|
|
||||||
async function handleTambah() {
|
async function handleTambah() {
|
||||||
try {
|
try {
|
||||||
@@ -155,7 +150,10 @@ export default function HeaderRightPositionList() {
|
|||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View style={Styles.mb30}>
|
<View style={Styles.mb30}>
|
||||||
<ButtonForm text="SIMPAN" onPress={() => { onCheck() }} />
|
<ButtonForm
|
||||||
|
text="SIMPAN"
|
||||||
|
onPress={() => { handleTambah() }}
|
||||||
|
disabled={disable} />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</DrawerBottom>
|
</DrawerBottom>
|
||||||
|
|||||||
Reference in New Issue
Block a user