2022-02-27 20:05:21 +00:00
|
|
|
|
|
|
|
import React, { useState, useEffect, useRef } from 'react';
|
2022-02-27 04:35:56 +00:00
|
|
|
import Button from '@mui/material/Button';
|
|
|
|
import Dialog from '@mui/material/Dialog';
|
|
|
|
import DialogActions from '@mui/material/DialogActions';
|
|
|
|
|
|
|
|
import DialogContent from '@mui/material/DialogContent';
|
|
|
|
import DialogContentText from '@mui/material/DialogContentText';
|
|
|
|
import DialogTitle from '@mui/material/DialogTitle';
|
|
|
|
|
|
|
|
import TextField from '@mui/material/TextField';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import Box from '@mui/material/Box';
|
|
|
|
|
|
|
|
import SelectField from "../../Report/SelectField";
|
|
|
|
import DatePicker from '../../Report/DatePicker'
|
|
|
|
|
|
|
|
import TimerPickerSelect from '../TimerPickerSelect'
|
|
|
|
import TextArea1 from '../TextArea'
|
|
|
|
import TextArea2 from '../TextArea'
|
|
|
|
|
|
|
|
|
2022-02-27 20:05:21 +00:00
|
|
|
const Item = (props) => {
|
|
|
|
|
2022-02-27 04:35:56 +00:00
|
|
|
const { sx, ...other } = props;
|
|
|
|
return (
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
bgcolor: (theme) => (theme.palette.mode === 'dark' ? '#101010' : '#fff'),
|
|
|
|
color: (theme) => (theme.palette.mode === 'dark' ? 'grey.300' : 'grey.800'),
|
|
|
|
border: '1px solid',
|
|
|
|
borderColor: (theme) =>
|
|
|
|
theme.palette.mode === 'dark' ? 'grey.800' : 'grey.300',
|
|
|
|
p: 1,
|
|
|
|
m: 1,
|
|
|
|
borderRadius: 2,
|
|
|
|
fontSize: '0.875rem',
|
|
|
|
fontWeight: '700',
|
|
|
|
...sx,
|
|
|
|
}}
|
|
|
|
{...other}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Item.propTypes = {
|
|
|
|
sx: PropTypes.oneOfType([
|
|
|
|
PropTypes.arrayOf(
|
|
|
|
PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool]),
|
|
|
|
),
|
|
|
|
PropTypes.func,
|
|
|
|
PropTypes.object,
|
|
|
|
]),
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Modal = (props) => {
|
2022-02-27 20:05:21 +00:00
|
|
|
const [open, setOpen] = useState(true);
|
|
|
|
const [scroll, /*setScroll*/] = useState('body');
|
|
|
|
const [schedulingId, setScheduling] = useState(null)
|
|
|
|
const [startDate, setDatePicker] = useState(new Date())
|
|
|
|
const [timerPicker, setTimerPicker] = useState(new Date())
|
|
|
|
const [textArea1, setTextArea1] = useState()
|
|
|
|
const [textArea2, setTextArea2] = useState()
|
2022-02-28 13:51:11 +00:00
|
|
|
const [textFieldCpfCnpj, setTextField] = useState()
|
|
|
|
|
|
|
|
const [data] = useState(props.schedules)
|
|
|
|
const [chatEnd, setChatEnd] = useState(false)
|
2022-02-27 04:35:56 +00:00
|
|
|
|
2022-02-28 13:51:11 +00:00
|
|
|
const handleCancel = (event, reason) => {
|
2022-02-27 04:35:56 +00:00
|
|
|
|
2022-02-27 20:05:21 +00:00
|
|
|
if (reason && reason === "backdropClick")
|
2022-02-27 04:35:56 +00:00
|
|
|
return;
|
|
|
|
|
2022-02-28 13:51:11 +00:00
|
|
|
setChatEnd(null)
|
2022-02-27 04:35:56 +00:00
|
|
|
setOpen(false);
|
|
|
|
};
|
2022-02-28 13:51:11 +00:00
|
|
|
|
2022-02-27 04:35:56 +00:00
|
|
|
|
2022-02-27 21:04:31 +00:00
|
|
|
const handleChatEnd = (event, reason) => {
|
|
|
|
|
|
|
|
if (reason && reason === "backdropClick")
|
|
|
|
return;
|
2022-02-28 13:51:11 +00:00
|
|
|
|
|
|
|
setChatEnd({
|
|
|
|
|
|
|
|
'schedulingId': schedulingId,
|
|
|
|
'cpf_cnpj': textFieldCpfCnpj,
|
|
|
|
'schedulingDate': `${startDate} ${timerPicker.getHours()}:${timerPicker.getMinutes()}:${timerPicker.getSeconds()}`,
|
|
|
|
'reminder': textArea1,
|
|
|
|
'message': textArea2,
|
|
|
|
'status': ''
|
|
|
|
|
|
|
|
})
|
2022-02-27 21:04:31 +00:00
|
|
|
|
|
|
|
setOpen(false);
|
|
|
|
};
|
|
|
|
|
2022-02-28 13:51:11 +00:00
|
|
|
useEffect(()=>{
|
|
|
|
|
|
|
|
props.func(chatEnd);
|
|
|
|
|
|
|
|
}, [chatEnd])
|
|
|
|
|
2022-02-27 21:04:31 +00:00
|
|
|
|
2022-02-27 20:05:21 +00:00
|
|
|
const descriptionElementRef = useRef(null);
|
|
|
|
useEffect(() => {
|
2022-02-27 04:35:56 +00:00
|
|
|
if (open) {
|
|
|
|
const { current: descriptionElement } = descriptionElementRef;
|
|
|
|
if (descriptionElement !== null) {
|
|
|
|
descriptionElement.focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [open]);
|
|
|
|
|
|
|
|
|
|
|
|
// Get from child 1
|
|
|
|
const textFieldSelect = (data) => {
|
|
|
|
console.log('textFieldSelect: ',data);
|
|
|
|
setScheduling(data)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get from child 2
|
|
|
|
const datePickerValue = (data) => {
|
|
|
|
console.log('datePickerValue: ',(data));
|
|
|
|
setDatePicker(data)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get from child 3
|
|
|
|
const timerPickerValue = (data) => {
|
|
|
|
console.log('timerPickerValue: ',(data));
|
|
|
|
setTimerPicker(data)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get from child 4
|
|
|
|
const textArea1Value = (data) => {
|
|
|
|
console.log('textArea1Value: ',(data));
|
|
|
|
setTextArea1(data)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get from child 5
|
|
|
|
const textArea2Value = (data) => {
|
|
|
|
console.log('textArea2Value: ',(data));
|
|
|
|
setTextArea2(data)
|
|
|
|
}
|
|
|
|
|
2022-02-27 21:04:31 +00:00
|
|
|
|
|
|
|
const handleTextFieldChange = (event) => {
|
|
|
|
|
|
|
|
console.log('CPF/CNPJ: ',(event.target.value));
|
|
|
|
setTextField(event.target.value);
|
|
|
|
};
|
2022-02-27 20:05:21 +00:00
|
|
|
|
2022-02-27 04:35:56 +00:00
|
|
|
|
2022-02-27 20:05:21 +00:00
|
|
|
return (
|
|
|
|
|
|
|
|
|
|
|
|
<Dialog
|
2022-02-27 04:35:56 +00:00
|
|
|
open={open}
|
2022-02-28 13:51:11 +00:00
|
|
|
onClose={handleCancel}
|
2022-02-27 04:35:56 +00:00
|
|
|
// fullWidth={true}
|
|
|
|
// maxWidth={true}
|
|
|
|
disableEscapeKeyDown
|
|
|
|
|
|
|
|
scroll={scroll}
|
|
|
|
aria-labelledby="scroll-dialog-title"
|
|
|
|
aria-describedby="scroll-dialog-description"
|
|
|
|
>
|
|
|
|
|
|
|
|
<DialogTitle id="scroll-dialog-title">{props.modal_header}</DialogTitle>
|
|
|
|
<DialogContent dividers={scroll === 'body'}>
|
2022-02-27 20:05:21 +00:00
|
|
|
|
2022-02-27 04:35:56 +00:00
|
|
|
<DialogContentText
|
|
|
|
id="scroll-dialog-description"
|
|
|
|
ref={descriptionElementRef}
|
|
|
|
tabIndex={-1}
|
|
|
|
>
|
2022-02-27 20:05:21 +00:00
|
|
|
|
|
|
|
</DialogContentText>
|
2022-02-27 04:35:56 +00:00
|
|
|
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
width: 500,
|
|
|
|
height: 430,
|
|
|
|
// backgroundColor: 'primary.dark',
|
|
|
|
// '&:hover': {backgroundColor: 'primary.main', opacity: [0.9, 0.8, 0.7],},
|
2022-02-27 21:04:31 +00:00
|
|
|
}}>
|
2022-02-27 20:05:21 +00:00
|
|
|
|
|
|
|
<Box sx={{
|
2022-02-27 04:35:56 +00:00
|
|
|
display: 'grid',
|
|
|
|
}}>
|
|
|
|
<Item>
|
2022-02-27 20:05:21 +00:00
|
|
|
<span>Selecione um status para encerrar o Atendimento</span>
|
2022-02-27 04:35:56 +00:00
|
|
|
|
|
|
|
<Item>
|
|
|
|
<SelectField func={textFieldSelect} header={'Status de atendimento'} currencies={data.map((obj)=>{
|
|
|
|
return {'value': obj.id, 'label': obj.name}
|
|
|
|
})}/>
|
|
|
|
</Item>
|
|
|
|
|
|
|
|
<Item>
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
maxWidth: '100%',
|
|
|
|
}}
|
|
|
|
>
|
2022-02-27 21:04:31 +00:00
|
|
|
<TextField
|
|
|
|
fullWidth
|
|
|
|
label="CPF/CNPJ"
|
|
|
|
id="fullWidth"
|
|
|
|
size="small"
|
|
|
|
margin="dense"
|
|
|
|
onChange={handleTextFieldChange}
|
|
|
|
|
|
|
|
/>
|
2022-02-27 04:35:56 +00:00
|
|
|
</Box>
|
|
|
|
</Item>
|
|
|
|
|
|
|
|
</Item>
|
|
|
|
|
2022-02-27 20:05:21 +00:00
|
|
|
</Box>
|
2022-02-27 04:35:56 +00:00
|
|
|
|
|
|
|
|
2022-02-27 20:05:21 +00:00
|
|
|
<Item>
|
|
|
|
|
|
|
|
<span>Lembrete de retorno</span>
|
2022-02-27 04:35:56 +00:00
|
|
|
|
|
|
|
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)' }}>
|
|
|
|
|
|
|
|
<Item><DatePicker func={datePickerValue} title={'Data'}/></Item>
|
|
|
|
|
|
|
|
<Item><TimerPickerSelect func={timerPickerValue} title={'Data inicio'}/></Item>
|
|
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
|
|
|
2022-02-27 21:04:31 +00:00
|
|
|
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)' }}>
|
2022-02-27 04:35:56 +00:00
|
|
|
|
|
|
|
<Item><TextArea1 func={textArea1Value} hint={'Lembrete'}/> </Item>
|
|
|
|
|
|
|
|
<Item><TextArea2 func={textArea2Value} hint={'Mensagem para cliente'}/></Item>
|
|
|
|
|
2022-02-27 21:04:31 +00:00
|
|
|
</Box>
|
2022-02-27 04:35:56 +00:00
|
|
|
|
|
|
|
</Item>
|
|
|
|
|
2022-02-27 20:05:21 +00:00
|
|
|
</Box>
|
2022-02-27 04:35:56 +00:00
|
|
|
</DialogContent>
|
|
|
|
|
|
|
|
|
|
|
|
<DialogActions>
|
|
|
|
<div style={{marginRight:'50px'}}>
|
2022-02-28 13:51:11 +00:00
|
|
|
<Button onClick={handleCancel}>Cancelar</Button>
|
2022-02-27 04:35:56 +00:00
|
|
|
</div>
|
2022-02-27 21:04:31 +00:00
|
|
|
<Button onClick={handleChatEnd}>Ok</Button>
|
2022-02-27 04:35:56 +00:00
|
|
|
</DialogActions>
|
2022-02-27 20:05:21 +00:00
|
|
|
</Dialog>
|
|
|
|
|
2022-02-27 04:35:56 +00:00
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Modal
|