mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-19 04:09:26 +00:00
fix: sonarcloud warning and code cleanup
This commit is contained in:
@@ -102,12 +102,8 @@ const ContactModal = ({ open, onClose, contactId, initialValues, onSave }) => {
|
||||
fetchContact();
|
||||
}, [contactId, open, initialValues]);
|
||||
|
||||
const handleClose = contactId => {
|
||||
if (contactId) {
|
||||
onClose(contactId);
|
||||
} else {
|
||||
onClose();
|
||||
}
|
||||
const handleClose = () => {
|
||||
onClose();
|
||||
setContact(initialState);
|
||||
};
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ const MarkdownWrapper = ({ children }) => {
|
||||
}
|
||||
|
||||
const options = React.useMemo(() => {
|
||||
const options = {
|
||||
const markdownOptions = {
|
||||
disableParsingRawHTML: true,
|
||||
forceInline: true,
|
||||
overrides: {
|
||||
@@ -171,11 +171,11 @@ const MarkdownWrapper = ({ children }) => {
|
||||
|
||||
elements.forEach(element => {
|
||||
if (!allowedElements.includes(element)) {
|
||||
options.overrides[element] = ({ children }) => children;
|
||||
markdownOptions.overrides[element] = el => el.children;
|
||||
}
|
||||
});
|
||||
|
||||
return options;
|
||||
return markdownOptions;
|
||||
}, []);
|
||||
|
||||
return <Markdown options={options}>{children}</Markdown>;
|
||||
|
||||
@@ -100,8 +100,8 @@ const NewTicketModal = ({ modalOpen, onClose }) => {
|
||||
handleSaveTicket(contact.id);
|
||||
};
|
||||
|
||||
const createAddContactOption = (options, params) => {
|
||||
const filtered = filter(options, params);
|
||||
const createAddContactOption = (filterOptions, params) => {
|
||||
const filtered = filter(filterOptions, params);
|
||||
|
||||
if (params.inputValue !== "" && !loading && searchParam.length >= 3) {
|
||||
filtered.push({
|
||||
|
||||
@@ -21,6 +21,7 @@ import ButtonWithSpinner from "../ButtonWithSpinner";
|
||||
import MarkdownWrapper from "../MarkdownWrapper";
|
||||
import { Tooltip } from "@material-ui/core";
|
||||
import { AuthContext } from "../../context/Auth/AuthContext";
|
||||
import toastError from "../../errors/toastError";
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
ticket: {
|
||||
@@ -114,25 +115,25 @@ const TicketListItem = ({ ticket }) => {
|
||||
};
|
||||
}, []);
|
||||
|
||||
const handleAcepptTicket = async ticketId => {
|
||||
const handleAcepptTicket = async id => {
|
||||
setLoading(true);
|
||||
try {
|
||||
await api.put(`/tickets/${ticketId}`, {
|
||||
await api.put(`/tickets/${id}`, {
|
||||
status: "open",
|
||||
userId: user?.id,
|
||||
});
|
||||
} catch (err) {
|
||||
setLoading(false);
|
||||
alert(err);
|
||||
toastError(err);
|
||||
}
|
||||
if (isMounted.current) {
|
||||
setLoading(false);
|
||||
}
|
||||
history.push(`/tickets/${ticketId}`);
|
||||
history.push(`/tickets/${id}`);
|
||||
};
|
||||
|
||||
const handleSelectTicket = (e, ticket) => {
|
||||
history.push(`/tickets/${ticket.id}`);
|
||||
const handleSelectTicket = id => {
|
||||
history.push(`/tickets/${id}`);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -142,7 +143,7 @@ const TicketListItem = ({ ticket }) => {
|
||||
button
|
||||
onClick={e => {
|
||||
if (ticket.status === "pending") return;
|
||||
handleSelectTicket(e, ticket);
|
||||
handleSelectTicket(ticket.id);
|
||||
}}
|
||||
selected={ticketId && +ticketId === ticket.id}
|
||||
className={clsx(classes.ticket, {
|
||||
@@ -160,9 +161,7 @@ const TicketListItem = ({ ticket }) => {
|
||||
></span>
|
||||
</Tooltip>
|
||||
<ListItemAvatar>
|
||||
<Avatar
|
||||
src={ticket.contact.profilePicUrl && ticket.contact.profilePicUrl}
|
||||
></Avatar>
|
||||
<Avatar src={ticket?.contact?.profilePicUrl} />
|
||||
</ListItemAvatar>
|
||||
<ListItemText
|
||||
disableTypography
|
||||
|
||||
Reference in New Issue
Block a user