From 64cd15501650a8df3fbec9b0f467f3b8e207b5b3 Mon Sep 17 00:00:00 2001 From: adriano Date: Thu, 29 Jun 2023 19:57:51 -0300 Subject: [PATCH] =?UTF-8?q?Identa=C3=A7=C3=A3o=20de=20codigo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/controllers/TicketController.ts | 2 +- .../components/TransferTicketModal/index.js | 314 +++++++++--------- 2 files changed, 158 insertions(+), 158 deletions(-) diff --git a/backend/src/controllers/TicketController.ts b/backend/src/controllers/TicketController.ts index 5accffc..7312492 100644 --- a/backend/src/controllers/TicketController.ts +++ b/backend/src/controllers/TicketController.ts @@ -228,7 +228,7 @@ export const update = async (req: Request, res: Response): Promise => const defaultWhatsapp: any = await GetDefaultWhatsApp(ticketData.userId); - const _ticket: any = await Ticket.findByPk(ticketId) + const _ticket: any = await Ticket.findByPk(ticketId) if (defaultWhatsapp && ticketData.status != 'open') { diff --git a/frontend/src/components/TransferTicketModal/index.js b/frontend/src/components/TransferTicketModal/index.js index 2707969..a96483c 100644 --- a/frontend/src/components/TransferTicketModal/index.js +++ b/frontend/src/components/TransferTicketModal/index.js @@ -14,7 +14,7 @@ import DialogActions from "@material-ui/core/DialogActions"; import DialogContent from "@material-ui/core/DialogContent"; import DialogTitle from "@material-ui/core/DialogTitle"; import Autocomplete, { - createFilterOptions, + createFilterOptions, } from "@material-ui/lab/Autocomplete"; import CircularProgress from "@material-ui/core/CircularProgress"; @@ -31,177 +31,177 @@ const useStyles = makeStyles((theme) => ({ })); const filterOptions = createFilterOptions({ - trim: true, + trim: true, }); const TransferTicketModal = ({ modalOpen, onClose, ticketid }) => { - const history = useHistory(); - const [options, setOptions] = useState([]); - const [queues, setQueues] = useState([]); - const [allQueues, setAllQueues] = useState([]); - const [loading, setLoading] = useState(false); - const [searchParam, setSearchParam] = useState(""); - const [selectedUser, setSelectedUser] = useState(null); - const [selectedQueue, setSelectedQueue] = useState(''); - const classes = useStyles(); - const { findAll: findAllQueues } = useQueues(); + const history = useHistory(); + const [options, setOptions] = useState([]); + const [queues, setQueues] = useState([]); + const [allQueues, setAllQueues] = useState([]); + const [loading, setLoading] = useState(false); + const [searchParam, setSearchParam] = useState(""); + const [selectedUser, setSelectedUser] = useState(null); + const [selectedQueue, setSelectedQueue] = useState(''); + const classes = useStyles(); + const { findAll: findAllQueues } = useQueues(); - useEffect(() => { - const loadQueues = async () => { - const list = await findAllQueues(); - setAllQueues(list); - setQueues(list); - } - loadQueues(); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + useEffect(() => { + const loadQueues = async () => { + const list = await findAllQueues(); + setAllQueues(list); + setQueues(list); + } + loadQueues(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); - useEffect(() => { - if (!modalOpen || searchParam.length < 3) { - setLoading(false); - return; - } - setLoading(true); - const delayDebounceFn = setTimeout(() => { - const fetchUsers = async () => { - try { - const { data } = await api.get("/users/", { - params: { searchParam }, - }); - setOptions(data.users); - setLoading(false); - } catch (err) { - setLoading(false); - toastError(err); - } - }; + useEffect(() => { + if (!modalOpen || searchParam.length < 3) { + setLoading(false); + return; + } + setLoading(true); + const delayDebounceFn = setTimeout(() => { + const fetchUsers = async () => { + try { + const { data } = await api.get("/users/", { + params: { searchParam }, + }); + setOptions(data.users); + setLoading(false); + } catch (err) { + setLoading(false); + toastError(err); + } + }; - fetchUsers(); - }, 500); - return () => clearTimeout(delayDebounceFn); - }, [searchParam, modalOpen]); + fetchUsers(); + }, 500); + return () => clearTimeout(delayDebounceFn); + }, [searchParam, modalOpen]); - const handleClose = () => { - onClose(); - setSearchParam(""); - setSelectedUser(null); - }; + const handleClose = () => { + onClose(); + setSearchParam(""); + setSelectedUser(null); + }; - const handleSaveTicket = async e => { - e.preventDefault(); - if (!ticketid) return; - setLoading(true); - try { - let data = {}; + const handleSaveTicket = async e => { + e.preventDefault(); + if (!ticketid) return; + setLoading(true); + try { + let data = {}; - if (selectedUser) { - data.userId = selectedUser.id - } + if (selectedUser) { + data.userId = selectedUser.id + } - if (selectedQueue && selectedQueue !== null) { - data.queueId = selectedQueue + if (selectedQueue && selectedQueue !== null) { + data.queueId = selectedQueue - if (!selectedUser) { - data.status = 'pending'; - data.userId = null; - } - } + if (!selectedUser) { + data.status = 'pending'; + data.userId = null; + } + } - // test del PARA APARECER NA FILA DE OUTRO ATENDENTE E O MESMO CLICAR EM ACEITAR AO INVES DE ENVIAR PARA ATENDENDO - data.status = 'pending' + // test del PARA APARECER NA FILA DE OUTRO ATENDENTE E O MESMO CLICAR EM ACEITAR AO INVES DE ENVIAR PARA ATENDENDO + data.status = 'pending' - await api.put(`/tickets/${ticketid}`, data); + await api.put(`/tickets/${ticketid}`, data); - setLoading(false); - history.push(`/tickets`); - } catch (err) { - setLoading(false); - toastError(err); - } - }; + setLoading(false); + history.push(`/tickets`); + } catch (err) { + setLoading(false); + toastError(err); + } + }; - return ( - -
- - {i18n.t("transferTicketModal.title")} - - - `${option.name}`} - onChange={(e, newValue) => { - setSelectedUser(newValue); - if (newValue != null && Array.isArray(newValue.queues)) { - setQueues(newValue.queues); - } else { - setQueues(allQueues); - setSelectedQueue(''); - } - }} - options={options} - filterOptions={filterOptions} - freeSolo - autoHighlight - noOptionsText={i18n.t("transferTicketModal.noOptions")} - loading={loading} - renderInput={params => ( - setSearchParam(e.target.value)} - InputProps={{ - ...params.InputProps, - endAdornment: ( - - {loading ? ( - - ) : null} - {params.InputProps.endAdornment} - - ), - }} - /> - )} - /> - - {i18n.t("transferTicketModal.fieldQueueLabel")} - - - - - - - {i18n.t("transferTicketModal.buttons.ok")} - - -
-
- ); + return ( + +
+ + {i18n.t("transferTicketModal.title")} + + + `${option.name}`} + onChange={(e, newValue) => { + setSelectedUser(newValue); + if (newValue != null && Array.isArray(newValue.queues)) { + setQueues(newValue.queues); + } else { + setQueues(allQueues); + setSelectedQueue(''); + } + }} + options={options} + filterOptions={filterOptions} + freeSolo + autoHighlight + noOptionsText={i18n.t("transferTicketModal.noOptions")} + loading={loading} + renderInput={params => ( + setSearchParam(e.target.value)} + InputProps={{ + ...params.InputProps, + endAdornment: ( + + {loading ? ( + + ) : null} + {params.InputProps.endAdornment} + + ), + }} + /> + )} + /> + + {i18n.t("transferTicketModal.fieldQueueLabel")} + + + + + + + {i18n.t("transferTicketModal.buttons.ok")} + + +
+
+ ); }; export default TransferTicketModal;