fix: project
Deskripsi: - ganti warna sesuai temq - pencarian anggota - realtime edit tugas - loading saat upload file - order list file by created at - tidak menampilkan anggota dg user role selain coadmin dan user pada tambah anggota project - perbaikan link roouter tombol back pada detail project - memberikan loading pada cancel kegiatan No Issues
This commit is contained in:
@@ -13,6 +13,7 @@ export default function CancelProject() {
|
||||
const router = useRouter()
|
||||
const [alasan, setAlasan] = useState("")
|
||||
const [openModal, setOpenModal] = useState(false)
|
||||
const [loadingModal, setLoadingModal] = useState(false)
|
||||
const param = useParams<{ id: string }>()
|
||||
const tema = useHookstate(TEMA)
|
||||
const [touched, setTouched] = useState({
|
||||
@@ -23,15 +24,38 @@ export default function CancelProject() {
|
||||
project: "sdm"
|
||||
})
|
||||
|
||||
function onVerification() {
|
||||
if (alasan == "")
|
||||
return toast.error("Error! harus memasukkan alasan pembatalan Kegiatan")
|
||||
function onCheck() {
|
||||
const cek = checkAll()
|
||||
if (!cek)
|
||||
return false
|
||||
|
||||
setOpenModal(true)
|
||||
}
|
||||
|
||||
function checkAll() {
|
||||
let nilai = true
|
||||
if (alasan == "") {
|
||||
setTouched(touched => ({ ...touched, reason: true }))
|
||||
nilai = false
|
||||
}
|
||||
return nilai
|
||||
}
|
||||
|
||||
|
||||
function onValidation(kategori: string, val: string) {
|
||||
if (kategori == 'reason') {
|
||||
setAlasan(val)
|
||||
if (val == "") {
|
||||
setTouched({ ...touched, reason: true })
|
||||
} else {
|
||||
setTouched({ ...touched, reason: false })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function onSubmit() {
|
||||
try {
|
||||
setLoadingModal(true)
|
||||
const res = await funCancelProject(param.id, { reason: alasan })
|
||||
if (res.success) {
|
||||
setDataRealtime([{
|
||||
@@ -39,13 +63,16 @@ export default function CancelProject() {
|
||||
id: param.id,
|
||||
}])
|
||||
toast.success(res.message)
|
||||
router.push("/project")
|
||||
router.push("/project/" + param.id)
|
||||
} else {
|
||||
toast.error(res.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
toast.error("Gagal membatalkan Kegiatan, coba lagi nanti")
|
||||
} finally {
|
||||
setLoadingModal(false)
|
||||
setOpenModal(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +90,7 @@ export default function CancelProject() {
|
||||
value={alasan}
|
||||
size="md" placeholder='Contoh : Kegiatan tidak sesuai' label="Alasan Pembatalan"
|
||||
onChange={(event) => {
|
||||
setAlasan(event.target.value)
|
||||
setTouched({ ...touched, reason: false })
|
||||
onValidation('reason', event.target.value)
|
||||
}}
|
||||
error={
|
||||
touched.reason && (
|
||||
@@ -86,20 +112,21 @@ export default function CancelProject() {
|
||||
size="lg"
|
||||
radius={30}
|
||||
fullWidth
|
||||
onClick={() => { onVerification() }}
|
||||
onClick={() => { onCheck() }}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Box>
|
||||
|
||||
|
||||
<LayoutModal opened={openModal} onClose={() => setOpenModal(false)}
|
||||
description="Apakah Anda yakin ingin membatalkan Kegiatan ini? Pembatalan Kegiatan bersifat permanen"
|
||||
<LayoutModal loading={loadingModal} opened={openModal} onClose={() => setOpenModal(false)}
|
||||
description="Apakah Anda yakin ingin membatalkan kegiatan ini? Pembatalan kegiatan bersifat permanen"
|
||||
onYes={(val) => {
|
||||
if (val) {
|
||||
onSubmit()
|
||||
} else {
|
||||
setOpenModal(false)
|
||||
}
|
||||
setOpenModal(false)
|
||||
}} />
|
||||
</Box>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user