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