-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fila Obrigatórias na Abertura e Aceite de Tickets
- Loading branch information
Showing
7 changed files
with
332 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
frontend/src/components/AcceptTicketWithoutQueueModal/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import React, { useState, useContext } from "react"; | ||
import { useHistory } from "react-router-dom"; | ||
|
||
import { | ||
Button, | ||
Dialog, | ||
DialogActions, | ||
DialogContent, | ||
DialogTitle, | ||
FormControl, | ||
InputLabel, | ||
makeStyles, | ||
MenuItem, | ||
Select | ||
} from "@material-ui/core"; | ||
|
||
|
||
import api from "../../services/api"; | ||
import { AuthContext } from "../../context/Auth/AuthContext"; | ||
import ButtonWithSpinner from "../ButtonWithSpinner"; | ||
import { i18n } from "../../translate/i18n"; | ||
import toastError from "../../errors/toastError"; | ||
|
||
// const filter = createFilterOptions({ | ||
// trim: true, | ||
// }); | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
autoComplete: { | ||
width: 300, | ||
// marginBottom: 20 | ||
}, | ||
maxWidth: { | ||
width: "100%", | ||
}, | ||
buttonColorError: { | ||
color: theme.palette.error.main, | ||
borderColor: theme.palette.error.main, | ||
}, | ||
})); | ||
|
||
const AcceptTicketWithouSelectQueue = ({ modalOpen, onClose, ticketId }) => { | ||
const history = useHistory(); | ||
const classes = useStyles(); | ||
const [selectedQueue, setSelectedQueue] = useState(''); | ||
const [loading, setLoading] = useState(false); | ||
const { user } = useContext(AuthContext); | ||
|
||
const handleClose = () => { | ||
onClose(); | ||
setSelectedQueue(""); | ||
}; | ||
|
||
const handleUpdateTicketStatus = async (queueId) => { | ||
setLoading(true); | ||
try { | ||
await api.put(`/tickets/${ticketId}`, { | ||
status: "open", | ||
userId: user?.id || null, | ||
queueId: queueId | ||
}); | ||
|
||
setLoading(false); | ||
history.push(`/tickets/${ticketId}`); | ||
handleClose(); | ||
} catch (err) { | ||
setLoading(false); | ||
toastError(err); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<Dialog open={modalOpen} onClose={handleClose}> | ||
<DialogTitle id="form-dialog-title"> | ||
{i18n.t("ticketsList.acceptModal.title")} | ||
</DialogTitle> | ||
<DialogContent dividers> | ||
<FormControl variant="outlined" className={classes.maxWidth}> | ||
<InputLabel>{i18n.t("ticketsList.acceptModal.queue")}</InputLabel> | ||
<Select | ||
value={selectedQueue} | ||
className={classes.autoComplete} | ||
onChange={(e) => setSelectedQueue(e.target.value)} | ||
label={i18n.t("ticketsList.acceptModal.queue")} | ||
> | ||
<MenuItem value={''}> </MenuItem> | ||
{user.queues.map((queue) => ( | ||
<MenuItem key={queue.id} value={queue.id}>{queue.name}</MenuItem> | ||
))} | ||
</Select> | ||
</FormControl> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button | ||
onClick={handleClose} | ||
className={classes.buttonColorError} | ||
disabled={loading} | ||
variant="outlined" | ||
> | ||
{i18n.t("ticketsList.buttons.cancel")} | ||
</Button> | ||
<ButtonWithSpinner | ||
variant="contained" | ||
type="button" | ||
disabled={(selectedQueue === "")} | ||
onClick={() => handleUpdateTicketStatus(selectedQueue)} | ||
color="primary" | ||
loading={loading} | ||
> | ||
{i18n.t("ticketsList.buttons.start")} | ||
</ButtonWithSpinner> | ||
</DialogActions> | ||
</Dialog> | ||
</> | ||
); | ||
}; | ||
|
||
export default AcceptTicketWithouSelectQueue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
f246ea2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Olá, notei que após selecionar o "Setor", abrindo um novo Ticket, se clicar para "Reabrir", trava o "Front" e o Ticket volta com a último setor selecionado!