validasi wajib type of member
This commit is contained in:
@@ -30,6 +30,7 @@ export default function DialogConfirmation({requestLog, setOpenDialog, openDialo
|
||||
penempatan_kamar: '',
|
||||
type_of_member: ''
|
||||
});
|
||||
const [error, setError] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
// Update formData setiap kali approve berubah
|
||||
@@ -57,16 +58,22 @@ export default function DialogConfirmation({requestLog, setOpenDialog, openDialo
|
||||
|
||||
|
||||
const handleSubmit = () => {
|
||||
axios
|
||||
.put(`customer-service/request/${requestLog?.id}`, formData)
|
||||
.then((response) => {
|
||||
enqueueSnackbar('Verification Request LOG Success', { variant: 'success' });
|
||||
setOpenDialog(false);
|
||||
navigate('/custormer-service/request')
|
||||
})
|
||||
.catch(({ response }) => {
|
||||
enqueueSnackbar(response.data.message ?? 'Something went wrong!', { variant: 'error' });
|
||||
});
|
||||
if (formData.type_of_member === "") {
|
||||
setError(true);
|
||||
alert('Silakan pilih Type Of Member sebelum mengirimkan data.');
|
||||
} else {
|
||||
axios
|
||||
.put(`customer-service/request/${requestLog?.id}`, formData)
|
||||
.then((response) => {
|
||||
enqueueSnackbar('Verification Request LOG Success', { variant: 'success' });
|
||||
setOpenDialog(false);
|
||||
navigate('/custormer-service/request')
|
||||
})
|
||||
.catch(({ response }) => {
|
||||
enqueueSnackbar(response.data.message ?? 'Something went wrong!', { variant: 'error' });
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const style1 = {
|
||||
@@ -200,13 +207,15 @@ export default function DialogConfirmation({requestLog, setOpenDialog, openDialo
|
||||
/>
|
||||
</Stack>
|
||||
<Stack direction='row' spacing={2} sx={marginBottom2}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Type Of Member</Typography>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Type Of Member*</Typography>
|
||||
<Select
|
||||
fullWidth
|
||||
value={formData.type_of_member}
|
||||
onChange={(e) => handleChange('type_of_member', e.target.value)}
|
||||
variant="outlined"
|
||||
displayEmpty
|
||||
required
|
||||
error={error}
|
||||
>
|
||||
<MenuItem value="" disabled>
|
||||
Type Member
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import MuiDialog from "@/components/MuiDialog";
|
||||
import { Button, Card, Checkbox, DialogActions, Grid, TextField, TextareaAutosize, Typography, Select } from "@mui/material";
|
||||
import { Button, Card, Checkbox, DialogActions, Grid, TextField, TextareaAutosize, Typography, Select, FormHelperText } from "@mui/material";
|
||||
import { Paper } from "@mui/material";
|
||||
import { Stack, MenuItem } from '@mui/material';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
@@ -31,6 +31,7 @@ export default function DialogEditInformation({requestLog, setOpenDialog, openDi
|
||||
type_of_member: '',
|
||||
reason: requestLog?.reason
|
||||
});
|
||||
const [error, setError] = useState(false);
|
||||
|
||||
const [isReasonSelected, setIsReasonSelected] = useState(true);
|
||||
|
||||
@@ -67,7 +68,10 @@ export default function DialogEditInformation({requestLog, setOpenDialog, openDi
|
||||
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (isReasonSelected && formData.reason !== '') {
|
||||
if (formData.type_of_member === "") {
|
||||
setError(true);
|
||||
alert('Silakan pilih Type Of Member sebelum mengirimkan data.');
|
||||
} else if (isReasonSelected && formData.reason !== '') {
|
||||
axios
|
||||
.put(`customer-service/request/${requestLog?.id}`, formData)
|
||||
.then((response) => {
|
||||
@@ -83,6 +87,8 @@ export default function DialogEditInformation({requestLog, setOpenDialog, openDi
|
||||
setIsReasonSelected(false);
|
||||
alert('Silakan pilih alasan sebelum mengirimkan data.');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
const style1 = {
|
||||
@@ -196,13 +202,15 @@ export default function DialogEditInformation({requestLog, setOpenDialog, openDi
|
||||
/>
|
||||
</Stack>
|
||||
<Stack direction='row' spacing={2} sx={marginBottom2}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Type Of Member</Typography>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Type Of Member*</Typography>
|
||||
<Select
|
||||
fullWidth
|
||||
value={formData.type_of_member}
|
||||
onChange={(e) => handleChange('type_of_member', e.target.value)}
|
||||
variant="outlined"
|
||||
displayEmpty
|
||||
required
|
||||
error={error}
|
||||
>
|
||||
<MenuItem value="" disabled>
|
||||
Type Member
|
||||
|
||||
Reference in New Issue
Block a user