From d0be6729fe0ab69bfda8121cbe0bd7c1506daf72 Mon Sep 17 00:00:00 2001 From: adriano Date: Thu, 10 Mar 2022 08:24:10 -0300 Subject: [PATCH 1/5] =?UTF-8?q?Altera=C3=A7=C3=A3o=20do=20hor=C3=A1rio=20c?= =?UTF-8?q?omercial=20para=20t=C3=A9=20=C3=A0s=2020?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/controllers/TicketController.ts | 10 +- backend/src/models/Ticket.ts | 4 +- .../ListSchedulingNotifyContactService.ts | 43 +++++ .../components/ChatEnd/ModalChatEnd/index.js | 159 ++++++++++++++++-- .../src/components/Report/DatePicker/index.js | 3 + frontend/src/components/Ticket/index.js | 6 +- .../components/TicketActionButtons/index.js | 3 +- 8 files changed, 207 insertions(+), 23 deletions(-) create mode 100644 backend/src/services/SchedulingNotifyServices/ListSchedulingNotifyContactService.ts diff --git a/backend/package.json b/backend/package.json index 61d065e..6098b4e 100644 --- a/backend/package.json +++ b/backend/package.json @@ -37,7 +37,7 @@ "sequelize-cli": "^5.5.1", "sequelize-typescript": "^1.1.0", "socket.io": "^3.0.5", - "whatsapp-web.js": "^1.15.5", + "whatsapp-web.js": "^1.15.6", "yup": "^0.32.8" }, "devDependencies": { diff --git a/backend/src/controllers/TicketController.ts b/backend/src/controllers/TicketController.ts index 643141b..104972f 100644 --- a/backend/src/controllers/TicketController.ts +++ b/backend/src/controllers/TicketController.ts @@ -10,6 +10,7 @@ import SendWhatsAppMessage from "../services/WbotServices/SendWhatsAppMessage"; import ShowWhatsAppService from "../services/WhatsappService/ShowWhatsAppService"; import CreateSchedulingNotifyService from "../services/SchedulingNotifyServices/CreateSchedulingNotifyService"; +import ListSchedulingNotifyContactService from "../services/SchedulingNotifyServices/ListSchedulingNotifyContactService"; @@ -94,9 +95,16 @@ export const show = async (req: Request, res: Response): Promise => { const { schedules, count, hasMore } = await ListScheduleService({ searchParam: "", pageNumber: "1" }); + ////////////////// + const schedulesContact = await ListSchedulingNotifyContactService(contact.contact.number); + ///////////////// + + // console.log('############### schedulesContact: ', schedulesContact) + // console.log('############### contact.contact.number: ',contact.contact.number) + // return res.status(200).json(contact); - return res.status(200).json({contact, schedules}); + return res.status(200).json({contact, schedules, schedulesContact}); }; diff --git a/backend/src/models/Ticket.ts b/backend/src/models/Ticket.ts index 41ae739..72370e5 100644 --- a/backend/src/models/Ticket.ts +++ b/backend/src/models/Ticket.ts @@ -78,8 +78,8 @@ class Ticket extends Model { @HasMany(() => Message) messages: Message[]; - @HasOne(() => SchedulingNotify) - schedulingNotify: SchedulingNotify + @HasMany(() => SchedulingNotify) + schedulingNotify: SchedulingNotify[]; } export default Ticket; diff --git a/backend/src/services/SchedulingNotifyServices/ListSchedulingNotifyContactService.ts b/backend/src/services/SchedulingNotifyServices/ListSchedulingNotifyContactService.ts new file mode 100644 index 0000000..5313116 --- /dev/null +++ b/backend/src/services/SchedulingNotifyServices/ListSchedulingNotifyContactService.ts @@ -0,0 +1,43 @@ +import Ticket from "../../models/Ticket"; +import Contact from "../../models/Contact"; +import SchedulingNotify from "../../models/SchedulingNotify"; +import { Op, where, Sequelize } from "sequelize"; +import AppError from "../../errors/AppError"; + +const ListSchedulingNotifyContactService = async (contactNumber: string): Promise => { + + + const ticket = await SchedulingNotify.findAll({ + + attributes:['id', [Sequelize.fn("DATE_FORMAT",Sequelize.col("schedulingDate"),"%d/%m/%Y %H:%i:%s"),"schedulingDate"], 'message'], + + include: [ + { + model: Ticket, + required:true, + attributes: [], + include: [ + { + model: Contact, + where:{ + number: contactNumber, + }, + attributes: ['name', 'number'] + }, + ] + }, + + ], + + }); + + + if (!ticket) { + throw new AppError("ERR_NO_TICKET_FOUND", 404); + } + + return ticket; + }; + + export default ListSchedulingNotifyContactService; + \ No newline at end of file diff --git a/frontend/src/components/ChatEnd/ModalChatEnd/index.js b/frontend/src/components/ChatEnd/ModalChatEnd/index.js index db9d91b..f098441 100644 --- a/frontend/src/components/ChatEnd/ModalChatEnd/index.js +++ b/frontend/src/components/ChatEnd/ModalChatEnd/index.js @@ -6,22 +6,50 @@ 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 DialogTitle from '@mui/material/DialogTitle'; import PropTypes from 'prop-types'; -import Box from '@mui/material/Box'; - +import Box from '@mui/material/Box'; import SelectField from "../../Report/SelectField"; -import DatePicker from '../../Report/DatePicker' - +import DatePicker from '../../Report/DatePicker' import TimerPickerSelect from '../TimerPickerSelect' - + +// import MainHeader from "../../components/MainHeader"; +// import MainHeaderButtonsWrapper from "../../components/MainHeaderButtonsWrapper"; +// import TableRowSkeleton from "../../components/TableRowSkeleton"; +// import Title from "../../components/Title"; import TextareaAutosize from '@mui/material/TextareaAutosize'; -import { addHours } from "date-fns"; +import { addHours, subHours } from "date-fns"; + + + +import { + IconButton, + makeStyles, + Paper, + Table, + TableBody, + TableCell, + TableHead, + TableRow, + Typography, +} from "@material-ui/core"; + +const useStyles = makeStyles((theme) => ({ + mainPaper: { + flex: 1, + padding: theme.spacing(1), + overflowY: "scroll", + ...theme.scrollbarStyles, + }, + customTableCell: { + display: "flex", + alignItems: "center", + justifyContent: "center", + }, +})); const Item = (props) => { @@ -59,6 +87,7 @@ Item.propTypes = { const Modal = (props) => { + const classes = useStyles(); const [open, setOpen] = useState(true); const [scroll, /*setScroll*/] = useState('body'); @@ -69,6 +98,7 @@ const Modal = (props) => { const [data] = useState(props.schedules) + const [schedulesContact] = useState(props.schedulesContact) const handleCancel = (event, reason) => { @@ -123,9 +153,9 @@ const dateCurrentFormated = () => { alert('Mensagem muito curta!\nMínimo 10 caracteres.') return } - else if((new Date(timerPicker).getHours() > 16 && new Date(timerPicker).getMinutes() > 0) || + else if((new Date(timerPicker).getHours() > 20 && new Date(timerPicker).getMinutes() > 0) || (new Date(timerPicker).getHours() < 7)){ - alert('Horário comercial inválido!\n Selecione um horário de lembrete válido entre às 07:00 e 17:00') + alert('Horário comercial inválido!\n Selecione um horário de lembrete válido entre às 07:00 e 20:00') return } else if(startDate === dateCurrentFormated()){ @@ -138,14 +168,19 @@ const dateCurrentFormated = () => { return } } + + // console.log('NEW DATE: ', formatedTimeHour(subHours(new Date(`${startDate} ${timerPicker.getHours()}:${timerPicker.getMinutes()}:${timerPicker.getSeconds()}`), 1))+':00') props.func({ 'scheduleId': scheduleId, - 'schedulingDate': `${startDate} ${timerPicker.getHours()}:${timerPicker.getMinutes()}:${timerPicker.getSeconds()}`, + // 'schedulingDate': `${startDate} ${timerPicker.getHours()}:${timerPicker.getMinutes()}:${timerPicker.getSeconds()}`, + 'schedulingDate': startDate+' '+formatedTimeHour(subHours(new Date(`${startDate} ${timerPicker.getHours()}:${timerPicker.getMinutes()}:${timerPicker.getSeconds()}`), 1))+':00', 'message': textArea1 }); + + setOpen(false); }; @@ -177,15 +212,18 @@ const textFieldSelect = (data) => { useEffect(()=>{ - if (parseInt(timerPicker.getHours()) > 12 && parseInt(timerPicker.getHours()) < 18){ - setTextArea1('Boa tarde, '+greetMessageSchedule( formatedTimeHour(addHours(new Date(timerPicker), 1)))) + if (parseInt(timerPicker.getHours()) > 11 && parseInt(timerPicker.getHours()) < 18){ + // setTextArea1('Boa tarde, '+greetMessageSchedule( formatedTimeHour(addHours(new Date(timerPicker), 1)))) + setTextArea1('Boa tarde, '+greetMessageSchedule( formatedTimeHour(new Date(timerPicker), 1))) } else if(parseInt(timerPicker.getHours()) < 12){ - setTextArea1('Bom dia, '+greetMessageSchedule( formatedTimeHour(addHours(new Date(timerPicker), 1)))) + // setTextArea1('Bom dia, '+greetMessageSchedule( formatedTimeHour(addHours(new Date(timerPicker), 1)))) + setTextArea1('Bom dia, '+greetMessageSchedule( formatedTimeHour(new Date(timerPicker), 1))) } - else if(parseInt(timerPicker.getHours()) > 18){ + else if(parseInt(timerPicker.getHours()) > 17){ - setTextArea1('Boa noite, '+greetMessageSchedule( formatedTimeHour(addHours(new Date(timerPicker), 1)))) + // setTextArea1('Boa noite, '+greetMessageSchedule( formatedTimeHour(addHours(new Date(timerPicker), 1)))) + setTextArea1('Boa noite, '+greetMessageSchedule( formatedTimeHour(new Date(timerPicker), 1))) } @@ -281,6 +319,93 @@ const handleChange = (event) => { } + + {/* + + Titulo 1 + + + + + + + + + + table name + + + table color + + + table greeting + + + table actions + + + + + <> + {schedulesContact.map((queue) => ( + + {queue.name} + +
+ +
+
+ +
+ + {queue.greetingMessage} + +
+
+ + handleEditQueue(queue)} + > + + + + { + setSelectedQueue(queue); + setConfirmModalOpen(true); + }} + > + + + +
+ ))} + {loading && } + +
+
+
+ +
*/} diff --git a/frontend/src/components/Report/DatePicker/index.js b/frontend/src/components/Report/DatePicker/index.js index ee7e2ee..7f0597c 100644 --- a/frontend/src/components/Report/DatePicker/index.js +++ b/frontend/src/components/Report/DatePicker/index.js @@ -8,6 +8,9 @@ import { KeyboardDatePicker, MuiPickersUtilsProvider, } from '@material-ui/pickers'; + + + import ptBrLocale from "date-fns/locale/pt-BR"; diff --git a/frontend/src/components/Ticket/index.js b/frontend/src/components/Ticket/index.js index 8f74035..da72e66 100644 --- a/frontend/src/components/Ticket/index.js +++ b/frontend/src/components/Ticket/index.js @@ -84,6 +84,7 @@ const Ticket = () => { const [ticket, setTicket] = useState({}); const [schedule, setSchedule] = useState({}) + const [schedulesContact, setSchedulesContact] = useState({}) useEffect(() => { setLoading(true); @@ -98,10 +99,13 @@ const Ticket = () => { // setContact(data.contact); // setTicket(data); + console.log('SCHEDULE CONTACT: ',data.schedulesContact) + setContact(data.contact.contact); setTicket(data.contact); setSchedule(data.schedules) + setSchedulesContact(data.schedulesContact) setLoading(false); } catch (err) { @@ -172,7 +176,7 @@ const Ticket = () => { />
- +
diff --git a/frontend/src/components/TicketActionButtons/index.js b/frontend/src/components/TicketActionButtons/index.js index 9827fab..d2a1ad0 100644 --- a/frontend/src/components/TicketActionButtons/index.js +++ b/frontend/src/components/TicketActionButtons/index.js @@ -27,7 +27,7 @@ const useStyles = makeStyles(theme => ({ }, })); -const TicketActionButtons = ({ ticket, schedule }) => { +const TicketActionButtons = ({ ticket, schedule, schedulesContact }) => { const classes = useStyles(); const history = useHistory(); const [anchorEl, setAnchorEl] = useState(null); @@ -65,6 +65,7 @@ const TicketActionButtons = ({ ticket, schedule }) => { modal_header={'Finalização de Atendimento'} func={chatEndVal} schedules={schedule} + schedulesContact={schedulesContact} />) }; From f9ffa37b730e1f95da960cb50b7abd1fc226d94c Mon Sep 17 00:00:00 2001 From: adriano Date: Fri, 11 Mar 2022 00:00:59 -0300 Subject: [PATCH 2/5] =?UTF-8?q?Codifica=C3=A7=C3=A3o=20para=20o=20usu?= =?UTF-8?q?=C3=A1rio=20poder=20selecionar=20hora=20de=20envio=20de=20lembr?= =?UTF-8?q?ete=20de=20agedamento=20para=20cliente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/controllers/TicketController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/controllers/TicketController.ts b/backend/src/controllers/TicketController.ts index 104972f..3b05732 100644 --- a/backend/src/controllers/TicketController.ts +++ b/backend/src/controllers/TicketController.ts @@ -142,7 +142,7 @@ export const update = async ( req: Request, res: Response ): Promise = // agendamento const scheduleData = JSON.parse(schedulingNotifyData) - if( scheduleData.scheduleId != '1'){ + if( scheduleData.scheduleId === '2'){ const schedulingNotifyCreate = await CreateSchedulingNotifyService( { ticketId: scheduleData.ticketId, From 68a421c567370be923d92d265008dbded88d23d6 Mon Sep 17 00:00:00 2001 From: adriano Date: Fri, 11 Mar 2022 00:01:58 -0300 Subject: [PATCH 3/5] =?UTF-8?q?Codigifica=C3=A7=C3=A3o=20para=20atendente?= =?UTF-8?q?=20poder=20escolher=20hora=20de=20envio=20de=20mensagem=20como?= =?UTF-8?q?=20lembrete=20para=20retorno=20de=20agendamento?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ChatEnd/ModalChatEnd/index.js | 156 +++++++++++++----- .../components/Report/SelectField/index.js | 2 +- 2 files changed, 120 insertions(+), 38 deletions(-) diff --git a/frontend/src/components/ChatEnd/ModalChatEnd/index.js b/frontend/src/components/ChatEnd/ModalChatEnd/index.js index f098441..d220238 100644 --- a/frontend/src/components/ChatEnd/ModalChatEnd/index.js +++ b/frontend/src/components/ChatEnd/ModalChatEnd/index.js @@ -10,6 +10,10 @@ import DialogTitle from '@mui/material/DialogTitle'; import PropTypes from 'prop-types'; import Box from '@mui/material/Box'; import SelectField from "../../Report/SelectField"; + +import TextFieldSelectHourBefore from '@mui/material/TextField'; +import MenuItem from '@mui/material/MenuItem'; + import DatePicker from '../../Report/DatePicker' import TimerPickerSelect from '../TimerPickerSelect' @@ -21,7 +25,7 @@ import TimerPickerSelect from '../TimerPickerSelect' import TextareaAutosize from '@mui/material/TextareaAutosize'; -import { addHours, subHours } from "date-fns"; +import { addHours, subHours, subMinutes } from "date-fns"; @@ -84,6 +88,7 @@ Item.propTypes = { ]), }; + const Modal = (props) => { @@ -98,7 +103,12 @@ const Modal = (props) => { const [data] = useState(props.schedules) + const [schedulesContact] = useState(props.schedulesContact) + + const [currencyHourBefore, setCurrency] = useState(formatedTimeHour(subHours(timerPicker,1))); + const [currenciesTimeBefore, setCurrenciesTimeBefore] = useState( ); + const [test, setTest] = useState(null); const handleCancel = (event, reason) => { @@ -109,6 +119,7 @@ const Modal = (props) => { }; + function greetMessageSchedule(scheduleDate){ return `podemos confirmar sua consulta agendada para hoje às ${scheduleDate}?` @@ -118,6 +129,35 @@ const Modal = (props) => { return `${timer.getHours().toString().padStart(2, '0')}:${timer.getMinutes().toString().padStart(2, '0')}` } + function hoursBeforeAvalible(timer){ + + + let hours = [] + let hour = 1 + + while(subHours(timer, hour).getHours()>=6 /*&& subHours(timer, hour).getHours()>=new Date().getHours()*/){ + + console.log('******** TIMER: ', formatedTimeHour(subHours(timer,hour))) + + hours.push( + {value: formatedTimeHour(subHours(timer,hour)), + label: `${hour} HORA ANTES DO HORÁRIO DO AGENDAMENTO`}) + + hour++; + } + + if(hours){ + setCurrency(hours[0].value) + } + + + return hours + + console.log('HOURS: ',hours) + + } + + // Get from child 2 const datePickerValue = (data) => { @@ -143,6 +183,7 @@ const dateCurrentFormated = () => { } const handleChatEnd = (event, reason) => { + if (reason && reason === "backdropClick") return; @@ -158,28 +199,35 @@ const dateCurrentFormated = () => { alert('Horário comercial inválido!\n Selecione um horário de lembrete válido entre às 07:00 e 20:00') return } - else if(startDate === dateCurrentFormated()){ + // else if(startDate === dateCurrentFormated()){ + // if( + // (new Date(subHours(timerPicker, 1)).getHours() <= new Date().getHours() && + // new Date(subHours(timerPicker, 1)).getMinutes() <= new Date().getMinutes()) || - if(((new Date(timerPicker).getHours() === new Date().getHours()) && - (new Date(timerPicker).getMinutes() <= new Date().getMinutes())) || - (new Date(timerPicker).getHours() < new Date().getHours()) - ){ - alert('Para agendamentos do dia, é necessário que o horário do lembrete seja maior que o horário atual!') - return - } - } + // (new Date(subHours(timerPicker, 1)).getHours() == new Date().getHours() && + // new Date(subHours(timerPicker, 1)).getMinutes() <= new Date().getMinutes()) + + // ) + // { - // console.log('NEW DATE: ', formatedTimeHour(subHours(new Date(`${startDate} ${timerPicker.getHours()}:${timerPicker.getMinutes()}:${timerPicker.getSeconds()}`), 1))+':00') - + // alert('Para agendamentos do dia, é necessário que o horário do lembrete seja no mínimo uma hora adiantado!') + + // return + // } + // } + + + + props.func({ - 'scheduleId': scheduleId, + 'scheduleId': scheduleId, + // 'schedulingDate': startDate+' '+formatedTimeHour(subHours(new Date(`${startDate} ${timerPicker.getHours()}:${timerPicker.getMinutes()}:${timerPicker.getSeconds()}`), 1))+':00', // 'schedulingDate': `${startDate} ${timerPicker.getHours()}:${timerPicker.getMinutes()}:${timerPicker.getSeconds()}`, - 'schedulingDate': startDate+' '+formatedTimeHour(subHours(new Date(`${startDate} ${timerPicker.getHours()}:${timerPicker.getMinutes()}:${timerPicker.getSeconds()}`), 1))+':00', + 'schedulingDate': `${startDate} ${currencyHourBefore}:00`, 'message': textArea1 - }); - - + }); + setOpen(false); }; @@ -203,6 +251,17 @@ const textFieldSelect = (data) => { } +const handleChangeHourBefore = (event) => { + + console.log('textFihandleChangeHourBefore: ',event.target.value); + + setCurrency(event.target.value); +}; + + + + + // Get from child 4 // const textArea1Value = (data) => { @@ -225,7 +284,9 @@ useEffect(()=>{ // setTextArea1('Boa noite, '+greetMessageSchedule( formatedTimeHour(addHours(new Date(timerPicker), 1)))) setTextArea1('Boa noite, '+greetMessageSchedule( formatedTimeHour(new Date(timerPicker), 1))) } - + + setCurrenciesTimeBefore(hoursBeforeAvalible(timerPicker)) + },[timerPicker]) @@ -235,6 +296,8 @@ const handleChange = (event) => { setTextArea1(event.target.value); }; + + return ( @@ -275,13 +338,15 @@ const handleChange = (event) => { display: 'grid', }}> - Selecione uma opção para encerrar o Atendimento - - - { + Selecione uma opção para encerrar o Atendimento + + { return {'value': obj.id, 'label': obj.name} })}/> - + @@ -295,26 +360,43 @@ const handleChange = (event) => { - + - + - + + + + + {currenciesTimeBefore.map((option) => ( + + {option.label} + + ))} + + + - {/* */} - - - + + + diff --git a/frontend/src/components/Report/SelectField/index.js b/frontend/src/components/Report/SelectField/index.js index 0993b4d..5dd4cdc 100644 --- a/frontend/src/components/Report/SelectField/index.js +++ b/frontend/src/components/Report/SelectField/index.js @@ -15,7 +15,7 @@ const SelectTextFields = (props) => { useEffect(()=>{ - + props.func(currency); },[currency, props]) From e8eb00e96c6febb05238887513ed8102c91d77fa Mon Sep 17 00:00:00 2001 From: adriano Date: Sat, 12 Mar 2022 02:13:15 -0300 Subject: [PATCH 4/5] =?UTF-8?q?Cria=C3=A7=C3=A3o=20do=20agendamento=20com?= =?UTF-8?q?=20op=C3=A7=C3=A3o=20de=20excluira=20agendametnos=20anteriores?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/SchedulingNotifyController.ts | 15 + backend/src/controllers/TicketController.ts | 1 + ...20220224003939-create-scheduling-notify.ts | 4 + backend/src/models/SchedulingNotify.ts | 3 + backend/src/routes/SchedulingNotifyRoutes.ts | 10 + backend/src/routes/index.ts | 2 + .../CreateSchedulingNotifyService.ts | 3 + .../ListSchedulingNotifyContactService.ts | 3 +- .../components/ChatEnd/ModalChatEnd/index.js | 428 ++++++++++-------- frontend/src/components/Ticket/index.js | 12 +- .../components/TicketActionButtons/index.js | 6 +- 11 files changed, 297 insertions(+), 190 deletions(-) create mode 100644 backend/src/controllers/SchedulingNotifyController.ts create mode 100644 backend/src/routes/SchedulingNotifyRoutes.ts diff --git a/backend/src/controllers/SchedulingNotifyController.ts b/backend/src/controllers/SchedulingNotifyController.ts new file mode 100644 index 0000000..4185686 --- /dev/null +++ b/backend/src/controllers/SchedulingNotifyController.ts @@ -0,0 +1,15 @@ +import { Request, Response } from "express"; + +import DeleteSchedulingNotifyService from "../services/SchedulingNotifyServices/DeleteSchedulingNotifyService"; + + +export const remove = async ( req: Request, res: Response ): Promise => { + + console.log('EEEEEEEEEEEEEEEEEEEEEEEEEEE') + + const { scheduleId } = req.params; + + await DeleteSchedulingNotifyService(scheduleId); + + return res.status(200).send(); +}; diff --git a/backend/src/controllers/TicketController.ts b/backend/src/controllers/TicketController.ts index 3b05732..639de72 100644 --- a/backend/src/controllers/TicketController.ts +++ b/backend/src/controllers/TicketController.ts @@ -148,6 +148,7 @@ export const update = async ( req: Request, res: Response ): Promise = ticketId: scheduleData.ticketId, scheduleId: scheduleData.scheduleId, schedulingDate: scheduleData.schedulingDate, + schedulingTime: scheduleData.schedulingTime, message: scheduleData.message } ) diff --git a/backend/src/database/migrations/20220224003939-create-scheduling-notify.ts b/backend/src/database/migrations/20220224003939-create-scheduling-notify.ts index 765d4d1..1d65dd1 100644 --- a/backend/src/database/migrations/20220224003939-create-scheduling-notify.ts +++ b/backend/src/database/migrations/20220224003939-create-scheduling-notify.ts @@ -27,6 +27,10 @@ module.exports = { type: DataTypes.DATE, allowNull: false }, + schedulingTime: { + type: DataTypes.DATE, + allowNull: false + }, message: { type: DataTypes.STRING, allowNull: false diff --git a/backend/src/models/SchedulingNotify.ts b/backend/src/models/SchedulingNotify.ts index c8eff6d..af94607 100644 --- a/backend/src/models/SchedulingNotify.ts +++ b/backend/src/models/SchedulingNotify.ts @@ -38,6 +38,9 @@ import { @Column schedulingDate: Date; + @Column + schedulingTime: Date; + @Column message: string diff --git a/backend/src/routes/SchedulingNotifyRoutes.ts b/backend/src/routes/SchedulingNotifyRoutes.ts new file mode 100644 index 0000000..975b5a1 --- /dev/null +++ b/backend/src/routes/SchedulingNotifyRoutes.ts @@ -0,0 +1,10 @@ +import { Router } from "express"; +import isAuth from "../middleware/isAuth"; + +import * as SchedulingNotifyController from "../controllers/SchedulingNotifyController"; + +const schedulingNotifiyRoutes = Router(); + +schedulingNotifiyRoutes.delete("/schedule/:scheduleId", isAuth, SchedulingNotifyController.remove); + +export default schedulingNotifiyRoutes; diff --git a/backend/src/routes/index.ts b/backend/src/routes/index.ts index ab2d36e..98bcf6b 100644 --- a/backend/src/routes/index.ts +++ b/backend/src/routes/index.ts @@ -11,6 +11,7 @@ import whatsappSessionRoutes from "./whatsappSessionRoutes"; import queueRoutes from "./queueRoutes"; import quickAnswerRoutes from "./quickAnswerRoutes"; import reportRoutes from "./reportRoutes"; +import schedulingNotifiyRoutes from "./SchedulingNotifyRoutes"; const routes = Router(); @@ -26,6 +27,7 @@ routes.use(whatsappSessionRoutes); routes.use(queueRoutes); routes.use(quickAnswerRoutes); +routes.use(schedulingNotifiyRoutes) routes.use(reportRoutes); diff --git a/backend/src/services/SchedulingNotifyServices/CreateSchedulingNotifyService.ts b/backend/src/services/SchedulingNotifyServices/CreateSchedulingNotifyService.ts index 8f6252e..70ec9e1 100644 --- a/backend/src/services/SchedulingNotifyServices/CreateSchedulingNotifyService.ts +++ b/backend/src/services/SchedulingNotifyServices/CreateSchedulingNotifyService.ts @@ -6,6 +6,7 @@ interface Request { ticketId: string, scheduleId: string, schedulingDate: string, + schedulingTime: string, message: string } @@ -15,6 +16,7 @@ const CreateSchedulingNotifyService = async ( ticketId, scheduleId, schedulingDate, + schedulingTime, message }: Request): Promise => { @@ -24,6 +26,7 @@ const CreateSchedulingNotifyService = async ( ticketId, scheduleId, schedulingDate, + schedulingTime, message }) diff --git a/backend/src/services/SchedulingNotifyServices/ListSchedulingNotifyContactService.ts b/backend/src/services/SchedulingNotifyServices/ListSchedulingNotifyContactService.ts index 5313116..2a20ee0 100644 --- a/backend/src/services/SchedulingNotifyServices/ListSchedulingNotifyContactService.ts +++ b/backend/src/services/SchedulingNotifyServices/ListSchedulingNotifyContactService.ts @@ -9,7 +9,8 @@ const ListSchedulingNotifyContactService = async (contactNumber: string): Promis const ticket = await SchedulingNotify.findAll({ - attributes:['id', [Sequelize.fn("DATE_FORMAT",Sequelize.col("schedulingDate"),"%d/%m/%Y %H:%i:%s"),"schedulingDate"], 'message'], + attributes:['id', [Sequelize.fn("DATE_FORMAT",Sequelize.col("schedulingDate"),"%d/%m/%Y %H:%i:%s"),"schedulingDate"], + [Sequelize.fn("DATE_FORMAT",Sequelize.col("schedulingTime"),"%d/%m/%Y %H:%i:%s"),"schedulingTime"], 'message'], include: [ { diff --git a/frontend/src/components/ChatEnd/ModalChatEnd/index.js b/frontend/src/components/ChatEnd/ModalChatEnd/index.js index d220238..b2346fe 100644 --- a/frontend/src/components/ChatEnd/ModalChatEnd/index.js +++ b/frontend/src/components/ChatEnd/ModalChatEnd/index.js @@ -1,59 +1,73 @@ -import React, { useState, useEffect, useRef } from 'react'; +import React, { useState, useEffect, useRef, useReducer } from 'react'; import Button from '@mui/material/Button'; import Dialog from '@mui/material/Dialog'; -import DialogActions from '@mui/material/DialogActions'; - +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 PropTypes from 'prop-types'; import Box from '@mui/material/Box'; -import SelectField from "../../Report/SelectField"; - +import SelectField from "../../Report/SelectField"; import TextFieldSelectHourBefore from '@mui/material/TextField'; -import MenuItem from '@mui/material/MenuItem'; - +import MenuItem from '@mui/material/MenuItem'; import DatePicker from '../../Report/DatePicker' -import TimerPickerSelect from '../TimerPickerSelect' - -// import MainHeader from "../../components/MainHeader"; -// import MainHeaderButtonsWrapper from "../../components/MainHeaderButtonsWrapper"; -// import TableRowSkeleton from "../../components/TableRowSkeleton"; -// import Title from "../../components/Title"; - - -import TextareaAutosize from '@mui/material/TextareaAutosize'; - -import { addHours, subHours, subMinutes } from "date-fns"; - +import TimerPickerSelect from '../TimerPickerSelect' +import TextareaAutosize from '@mui/material/TextareaAutosize'; +import { subHours } from "date-fns"; + import { - IconButton, - makeStyles, + IconButton, Paper, Table, TableBody, TableCell, TableHead, - TableRow, - Typography, -} from "@material-ui/core"; + TableRow, +} from "@material-ui/core"; + +import { DeleteOutline } from "@material-ui/icons"; +import { toast } from "react-toastify"; import api from "../../../services/api"; +import toastError from "../../../errors/toastError"; +import ConfirmationModal from "../../ConfirmationModal"; -const useStyles = makeStyles((theme) => ({ - mainPaper: { - flex: 1, - padding: theme.spacing(1), - overflowY: "scroll", - ...theme.scrollbarStyles, - }, - customTableCell: { - display: "flex", - alignItems: "center", - justifyContent: "center", - }, -})); + +const reducer = (state, action) => { + + + if (action.type === "LOAD_SCHEDULES") { + const schedulesContact = action.payload; + const newSchedules= []; + + schedulesContact.forEach((schedule) => { + const scheduleIndex = state.findIndex((s) => s.id === schedule.id); + if (scheduleIndex !== -1) { + state[scheduleIndex] = schedule; + } else { + newSchedules.push(schedule); + } + }); + + return [...state, ...newSchedules]; + } + + if (action.type === "DELETE_SCHEDULE") { + const scheduleId = action.payload; + const scheduleIndex = state.findIndex((q) => q.id === scheduleId); + if (scheduleIndex !== -1) { + state.splice(scheduleIndex, 1); + } + return [...state]; + } + + if (action.type === "RESET") { + return []; + } +}; + + const Item = (props) => { @@ -90,9 +104,11 @@ Item.propTypes = { -const Modal = (props) => { +const Modal = (props) => { - const classes = useStyles(); + // const [clientSchedules, dispatch] = useReducer(reducer, []); + const [selectedSchedule, setSelectedSchedule] = useState(null); + const [confirmModalOpen, setConfirmModalOpen] = useState(false); const [open, setOpen] = useState(true); const [scroll, /*setScroll*/] = useState('body'); @@ -104,11 +120,10 @@ const Modal = (props) => { const [data] = useState(props.schedules) - const [schedulesContact] = useState(props.schedulesContact) + const [schedulesContact, dispatch] = useReducer(reducer, []); - const [currencyHourBefore, setCurrency] = useState(formatedTimeHour(subHours(timerPicker,1))); - const [currenciesTimeBefore, setCurrenciesTimeBefore] = useState( ); - const [test, setTest] = useState(null); + const [currencyHourBefore, setCurrency] = useState(null); + const [currenciesTimeBefore, setCurrenciesTimeBefore] = useState( ); const handleCancel = (event, reason) => { @@ -119,6 +134,22 @@ const Modal = (props) => { }; + + useEffect(() => { + + (async () => { + try { + + const { data } = await api.get("/tickets/" + props.ticketId); + + dispatch({ type: "LOAD_SCHEDULES", payload: data.schedulesContact }); + + } catch (err) { + toastError(err); + } + })(); + }, [props]); + function greetMessageSchedule(scheduleDate){ @@ -129,35 +160,84 @@ const Modal = (props) => { return `${timer.getHours().toString().padStart(2, '0')}:${timer.getMinutes().toString().padStart(2, '0')}` } - function hoursBeforeAvalible(timer){ - + const hoursBeforeAvalible = (timer) =>{ let hours = [] - let hour = 1 + let hour = 1 - while(subHours(timer, hour).getHours()>=6 /*&& subHours(timer, hour).getHours()>=new Date().getHours()*/){ + if(startDate === dateCurrentFormated()){ - console.log('******** TIMER: ', formatedTimeHour(subHours(timer,hour))) + console.log('HOJE++++') - hours.push( - {value: formatedTimeHour(subHours(timer,hour)), - label: `${hour} HORA ANTES DO HORÁRIO DO AGENDAMENTO`}) + while(subHours(timer, hour).getHours()>=6 && + subHours(timer, hour).getHours()>=new Date().getHours() && + subHours(timer, hour).getHours()<=19){ + + console.log('******** TIMER: ', formatedTimeHour(subHours(timer,hour))) + + hours.push( + {value: formatedTimeHour(subHours(timer,hour)), + label: `${hour} HORA ANTES DO HORÁRIO DO AGENDAMENTO`}) + + hour++; + } + + if(hours.length>1){ + console.log('entrou----------------------: ', hours.length) + hours.pop() + setCurrency(hours[0].value) + } + else{ + setCurrency(null) + } - hour++; } + else{ + + while(subHours(timer, hour).getHours()>=6 && subHours(timer, hour).getHours()<=19){ + + console.log('******** another day TIMER: ', formatedTimeHour(subHours(timer,hour))) + + hours.push( + {value: formatedTimeHour(subHours(timer,hour)), + label: `${hour} HORA ANTES DO HORÁRIO DO AGENDAMENTO`}) + + hour++; + } + + if(hours.length>0){ + console.log('entrou----------------------: ', hours.length) + setCurrency(hours[0].value) + } + else{ + setCurrency(null) + } - if(hours){ - setCurrency(hours[0].value) } - + - return hours - - console.log('HOURS: ',hours) + return {time: hours, hour:hour} } - + + + const handleCloseConfirmationModal = () => { + setConfirmModalOpen(false); + setSelectedSchedule(null); + }; + + + const handleDeleteSchedule = async (scheduleId) => { + try { + await api.delete(`/schedule/${scheduleId}`); + toast.success(("Agendamento deletado com sucesso!")); + dispatch({ type: "DELETE_SCHEDULE", payload: scheduleId }); + } catch (err) { + toastError(err); + } + setSelectedSchedule(null); + }; // Get from child 2 const datePickerValue = (data) => { @@ -190,7 +270,7 @@ const dateCurrentFormated = () => { if (scheduleId === '1'){ } - else if(textArea1.trim().length<10){ + else if(textArea1 && textArea1.trim().length<10){ alert('Mensagem muito curta!\nMínimo 10 caracteres.') return } @@ -199,6 +279,13 @@ const dateCurrentFormated = () => { alert('Horário comercial inválido!\n Selecione um horário de lembrete válido entre às 07:00 e 20:00') return } + else if(!currencyHourBefore){ + + alert('Para agendamentos do dia corrente, essa funcionalidade atende a agendeamentos com no mínimo 2 horas adiantado a partir da hora atual!') + + return + + } // else if(startDate === dateCurrentFormated()){ // if( // (new Date(subHours(timerPicker, 1)).getHours() <= new Date().getHours() && @@ -225,6 +312,7 @@ const dateCurrentFormated = () => { // 'schedulingDate': startDate+' '+formatedTimeHour(subHours(new Date(`${startDate} ${timerPicker.getHours()}:${timerPicker.getMinutes()}:${timerPicker.getSeconds()}`), 1))+':00', // 'schedulingDate': `${startDate} ${timerPicker.getHours()}:${timerPicker.getMinutes()}:${timerPicker.getSeconds()}`, 'schedulingDate': `${startDate} ${currencyHourBefore}:00`, + 'schedulingTime': startDate+' '+formatedTimeHour(new Date(`${startDate} ${timerPicker.getHours()}:${timerPicker.getMinutes()}:00`)), 'message': textArea1 }); @@ -255,7 +343,8 @@ const handleChangeHourBefore = (event) => { console.log('textFihandleChangeHourBefore: ',event.target.value); - setCurrency(event.target.value); + setCurrency(event.target.value); + }; @@ -271,24 +360,29 @@ const handleChangeHourBefore = (event) => { useEffect(()=>{ - if (parseInt(timerPicker.getHours()) > 11 && parseInt(timerPicker.getHours()) < 18){ - // setTextArea1('Boa tarde, '+greetMessageSchedule( formatedTimeHour(addHours(new Date(timerPicker), 1)))) + setCurrenciesTimeBefore(hoursBeforeAvalible(timerPicker).time) + +},[timerPicker, startDate]) + + +useEffect(()=>{ + + console.log('CURRENCY HOUR BEFORE: ', `${startDate} ${currencyHourBefore}:00`) + + let auxDate = new Date(`${startDate} ${currencyHourBefore}:00`) + + if (parseInt(auxDate.getHours()) > 11 && parseInt(auxDate.getHours()) < 18){ + setTextArea1('Boa tarde, '+greetMessageSchedule( formatedTimeHour(new Date(timerPicker), 1))) } - else if(parseInt(timerPicker.getHours()) < 12){ - // setTextArea1('Bom dia, '+greetMessageSchedule( formatedTimeHour(addHours(new Date(timerPicker), 1)))) + else if(parseInt(auxDate.getHours()) < 12){ setTextArea1('Bom dia, '+greetMessageSchedule( formatedTimeHour(new Date(timerPicker), 1))) } - else if(parseInt(timerPicker.getHours()) > 17){ - - // setTextArea1('Boa noite, '+greetMessageSchedule( formatedTimeHour(addHours(new Date(timerPicker), 1)))) + else if(parseInt(auxDate.getHours()) > 17){ setTextArea1('Boa noite, '+greetMessageSchedule( formatedTimeHour(new Date(timerPicker), 1))) - } - - setCurrenciesTimeBefore(hoursBeforeAvalible(timerPicker)) - - -},[timerPicker]) + } + +},[currencyHourBefore, startDate]) const handleChange = (event) => { @@ -300,6 +394,8 @@ const handleChange = (event) => { return ( + + { - - - - {currenciesTimeBefore.map((option) => ( - - {option.label} - - ))} - - + + {currencyHourBefore && + + + {currenciesTimeBefore.map((option) => ( + + {option.label} + + ))} + + + } { - } + } - {/* - - Titulo 1 - - - - - - - - - - table name - - - table color - - - table greeting - - - table actions - - - - - <> - {schedulesContact.map((queue) => ( - - {queue.name} - -
- -
-
- -
- - {queue.greetingMessage} - -
-
- - handleEditQueue(queue)} - > - - - - { - setSelectedQueue(queue); - setConfirmModalOpen(true); - }} - > - - - -
- ))} - {loading && } - -
-
-
+ {schedulesContact.length>0 && -
*/} + + + + + handleDeleteSchedule(selectedSchedule.id)} + > + Deseja realmente deletar esse Agendamento? + + Agendamentos + + + + + + + Data + + + Hora + + + Deletar + + + + + + <> + {schedulesContact.map((scheduleData, index) => ( + + {scheduleData.schedulingDate.split(' ')[0]} + {scheduleData.schedulingTime.split(' ')[1]} + + + { + setSelectedSchedule(scheduleData); + setConfirmModalOpen(true); + + }} + > + + + + + + ))} + + +
+
+
} +
diff --git a/frontend/src/components/Ticket/index.js b/frontend/src/components/Ticket/index.js index da72e66..fe0dd8f 100644 --- a/frontend/src/components/Ticket/index.js +++ b/frontend/src/components/Ticket/index.js @@ -83,8 +83,7 @@ const Ticket = () => { const [contact, setContact] = useState({}); const [ticket, setTicket] = useState({}); - const [schedule, setSchedule] = useState({}) - const [schedulesContact, setSchedulesContact] = useState({}) + const [schedule, setSchedule] = useState({}) useEffect(() => { setLoading(true); @@ -97,15 +96,12 @@ const Ticket = () => { const { data } = await api.get("/tickets/" + ticketId); // setContact(data.contact); - // setTicket(data); - - console.log('SCHEDULE CONTACT: ',data.schedulesContact) + // setTicket(data); setContact(data.contact.contact); setTicket(data.contact); - setSchedule(data.schedules) - setSchedulesContact(data.schedulesContact) + setSchedule(data.schedules) setLoading(false); } catch (err) { @@ -176,7 +172,7 @@ const Ticket = () => { />
- +
diff --git a/frontend/src/components/TicketActionButtons/index.js b/frontend/src/components/TicketActionButtons/index.js index d2a1ad0..cb01b61 100644 --- a/frontend/src/components/TicketActionButtons/index.js +++ b/frontend/src/components/TicketActionButtons/index.js @@ -27,7 +27,7 @@ const useStyles = makeStyles(theme => ({ }, })); -const TicketActionButtons = ({ ticket, schedule, schedulesContact }) => { +const TicketActionButtons = ({ ticket, schedule }) => { const classes = useStyles(); const history = useHistory(); const [anchorEl, setAnchorEl] = useState(null); @@ -64,8 +64,8 @@ const TicketActionButtons = ({ ticket, schedule, schedulesContact }) => { render() }; From 0f3a0cdc0eaf2ab54f2a395bea83782937ed273f Mon Sep 17 00:00:00 2001 From: adriano Date: Mon, 14 Mar 2022 10:21:50 -0300 Subject: [PATCH 5/5] =?UTF-8?q?Corre=C3=A7=C3=A3o=20do=20useEffect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ChatEnd/ModalChatEnd/index.js | 488 ++++++++---------- 1 file changed, 229 insertions(+), 259 deletions(-) diff --git a/frontend/src/components/ChatEnd/ModalChatEnd/index.js b/frontend/src/components/ChatEnd/ModalChatEnd/index.js index b2346fe..64036ee 100644 --- a/frontend/src/components/ChatEnd/ModalChatEnd/index.js +++ b/frontend/src/components/ChatEnd/ModalChatEnd/index.js @@ -123,7 +123,7 @@ const Modal = (props) => { const [schedulesContact, dispatch] = useReducer(reducer, []); const [currencyHourBefore, setCurrency] = useState(null); - const [currenciesTimeBefore, setCurrenciesTimeBefore] = useState( ); + const [currenciesTimeBefore, setCurrenciesTimeBefore] = useState(null); const handleCancel = (event, reason) => { @@ -159,68 +159,8 @@ const Modal = (props) => { function formatedTimeHour(timer){ return `${timer.getHours().toString().padStart(2, '0')}:${timer.getMinutes().toString().padStart(2, '0')}` } - - const hoursBeforeAvalible = (timer) =>{ - - let hours = [] - let hour = 1 - - if(startDate === dateCurrentFormated()){ - - console.log('HOJE++++') - - while(subHours(timer, hour).getHours()>=6 && - subHours(timer, hour).getHours()>=new Date().getHours() && - subHours(timer, hour).getHours()<=19){ - - console.log('******** TIMER: ', formatedTimeHour(subHours(timer,hour))) - - hours.push( - {value: formatedTimeHour(subHours(timer,hour)), - label: `${hour} HORA ANTES DO HORÁRIO DO AGENDAMENTO`}) - - hour++; - } - - if(hours.length>1){ - console.log('entrou----------------------: ', hours.length) - hours.pop() - setCurrency(hours[0].value) - } - else{ - setCurrency(null) - } - - } - else{ - - while(subHours(timer, hour).getHours()>=6 && subHours(timer, hour).getHours()<=19){ - - console.log('******** another day TIMER: ', formatedTimeHour(subHours(timer,hour))) - - hours.push( - {value: formatedTimeHour(subHours(timer,hour)), - label: `${hour} HORA ANTES DO HORÁRIO DO AGENDAMENTO`}) - - hour++; - } - - if(hours.length>0){ - console.log('entrou----------------------: ', hours.length) - setCurrency(hours[0].value) - } - else{ - setCurrency(null) - } - - } - return {time: hours, hour:hour} - - } - - const handleCloseConfirmationModal = () => { setConfirmModalOpen(false); @@ -243,12 +183,16 @@ const Modal = (props) => { const datePickerValue = (data) => { console.log('datePickerValue: ',(data)); setDatePicker(data) + + } // Get from child 3 const timerPickerValue = (data) => { console.log('timerPickerValue: ',(data)); setTimerPicker(data) + + } const dateCurrentFormated = () => { @@ -285,32 +229,11 @@ const dateCurrentFormated = () => { return - } - // else if(startDate === dateCurrentFormated()){ - // if( - // (new Date(subHours(timerPicker, 1)).getHours() <= new Date().getHours() && - // new Date(subHours(timerPicker, 1)).getMinutes() <= new Date().getMinutes()) || - - // (new Date(subHours(timerPicker, 1)).getHours() == new Date().getHours() && - // new Date(subHours(timerPicker, 1)).getMinutes() <= new Date().getMinutes()) - - // ) - // { - - // alert('Para agendamentos do dia, é necessário que o horário do lembrete seja no mínimo uma hora adiantado!') - - // return - // } - // } - - - + } props.func({ - 'scheduleId': scheduleId, - // 'schedulingDate': startDate+' '+formatedTimeHour(subHours(new Date(`${startDate} ${timerPicker.getHours()}:${timerPicker.getMinutes()}:${timerPicker.getSeconds()}`), 1))+':00', - // 'schedulingDate': `${startDate} ${timerPicker.getHours()}:${timerPicker.getMinutes()}:${timerPicker.getSeconds()}`, + 'scheduleId': scheduleId, 'schedulingDate': `${startDate} ${currencyHourBefore}:00`, 'schedulingTime': startDate+' '+formatedTimeHour(new Date(`${startDate} ${timerPicker.getHours()}:${timerPicker.getMinutes()}:00`)), 'message': textArea1 @@ -347,20 +270,71 @@ const handleChangeHourBefore = (event) => { }; - - - - - -// Get from child 4 -// const textArea1Value = (data) => { -// console.log('textArea1Value: ',(data)); -// setTextArea1(data) -// } + useEffect(()=>{ - setCurrenciesTimeBefore(hoursBeforeAvalible(timerPicker).time) + const hoursBeforeAvalible = (timer) =>{ + + let hours = [] + let hour = 1 + + if(startDate === dateCurrentFormated()){ + + console.log('HOJE++++') + + while(subHours(timer, hour).getHours()>=6 && + subHours(timer, hour).getHours()>=new Date().getHours() && + subHours(timer, hour).getHours()<=19){ + + console.log('******** TIMER: ', formatedTimeHour(subHours(timer,hour))) + + hours.push( + {value: formatedTimeHour(subHours(timer,hour)), + label: `${hour} HORA ANTES DO HORÁRIO DO AGENDAMENTO`}) + + hour++; + } + + if(hours.length>1){ + console.log('entrou----------------------: ', hours.length) + hours.pop() + setCurrency(hours[0].value) + } + else{ + setCurrency(null) + } + + } + else{ + + while(subHours(timer, hour).getHours()>=6 && subHours(timer, hour).getHours()<=19){ + + console.log('******** another day TIMER: ', formatedTimeHour(subHours(timer,hour))) + + hours.push( + {value: formatedTimeHour(subHours(timer,hour)), + label: `${hour} HORA ANTES DO HORÁRIO DO AGENDAMENTO`}) + + hour++; + } + + if(hours.length>0){ + console.log('entrou----------------------: ', hours.length) + setCurrency(hours[0].value) + } + else{ + setCurrency(null) + } + + } + + + return {time: hours, hour:hour} + + } + + setCurrenciesTimeBefore(hoursBeforeAvalible(timerPicker).time) },[timerPicker, startDate]) @@ -382,7 +356,7 @@ useEffect(()=>{ setTextArea1('Boa noite, '+greetMessageSchedule( formatedTimeHour(new Date(timerPicker), 1))) } -},[currencyHourBefore, startDate]) +},[currencyHourBefore, startDate, timerPicker]) const handleChange = (event) => { @@ -393,186 +367,182 @@ const handleChange = (event) => { - return ( - + return ( - - - + scroll={scroll} + aria-labelledby="scroll-dialog-title" + aria-describedby="scroll-dialog-description" + > - {props.modal_header} - + {props.modal_header} + - - - + + + - - + + - - - Selecione uma opção para encerrar o Atendimento + + + Selecione uma opção para encerrar o Atendimento + + { + return {'value': obj.id, 'label': obj.name} + })}/> + + + + + + + {scheduleId==='2' && + + + + Lembrete de retorno + + - { - return {'value': obj.id, 'label': obj.name} - })}/> + - - - - - - {scheduleId==='2' && - - - - Lembrete de retorno - - - - - - - - + + + - - - {currencyHourBefore && - - - {currenciesTimeBefore.map((option) => ( - - {option.label} - - ))} - + + + {currencyHourBefore && + + + {currenciesTimeBefore.map((option) => ( + + {option.label} + + ))} + + + } + + + + + + + - } + } + + {schedulesContact.length>0 && - - - - - - } + - {schedulesContact.length>0 && - - - - - - handleDeleteSchedule(selectedSchedule.id)} - > - Deseja realmente deletar esse Agendamento? - - Agendamentos - - - - - - - Data - - - Hora - - - Deletar - - - - - - <> - {schedulesContact.map((scheduleData, index) => ( - - {scheduleData.schedulingDate.split(' ')[0]} - {scheduleData.schedulingTime.split(' ')[1]} - - - { - setSelectedSchedule(scheduleData); - setConfirmModalOpen(true); - - }} - > - - + handleDeleteSchedule(selectedSchedule.id)} + > + Deseja realmente deletar esse Agendamento? + + Agendamentos + +
+ + + + + Data + + + Hora + + + Deletar - - ))} - - -
-
-
} - - -
-
- - - -
- -
- -
-
- + + + + <> + {schedulesContact.map((scheduleData, index) => ( + + {scheduleData.schedulingDate.split(' ')[0]} + {scheduleData.schedulingTime.split(' ')[1]} + + + { + setSelectedSchedule(scheduleData); + setConfirmModalOpen(true); + + }} + > + + + + + + ))} + + + + + } + + + + + + + +
+ +
+ +
+ ); }