layout responsivo 2ª parte

This commit is contained in:
ertprs
2021-09-07 13:00:51 -03:00
parent 50d6c42345
commit 4bf8ac4521
15 changed files with 2108 additions and 1951 deletions

View File

@@ -2,13 +2,13 @@ import React, { useState, useEffect } from "react";
import Routes from "./routes"; import Routes from "./routes";
import "react-toastify/dist/ReactToastify.css"; import "react-toastify/dist/ReactToastify.css";
import { createMuiTheme, ThemeProvider } from "@material-ui/core/styles"; import { createTheme, ThemeProvider } from "@material-ui/core/styles";
import { ptBR } from "@material-ui/core/locale"; import { ptBR } from "@material-ui/core/locale";
const App = () => { const App = () => {
const [locale, setLocale] = useState(); const [locale, setLocale] = useState();
const theme = createMuiTheme( const theme = createTheme(
{ {
scrollbarStyles: { scrollbarStyles: {
"&::-webkit-scrollbar": { "&::-webkit-scrollbar": {

View File

@@ -6,7 +6,7 @@ import { GithubPicker } from "react-color";
const ColorPicker = ({ onChange, currentColor, handleClose, open }) => { const ColorPicker = ({ onChange, currentColor, handleClose, open }) => {
const [selectedColor, setSelectedColor] = useState(currentColor); const [selectedColor, setSelectedColor] = useState(currentColor);
const handleChange = color => { const handleChange = (color) => {
setSelectedColor(color.hex); setSelectedColor(color.hex);
handleClose(); handleClose();
}; };
@@ -22,7 +22,7 @@ const ColorPicker = ({ onChange, currentColor, handleClose, open }) => {
triangle="hide" triangle="hide"
color={selectedColor} color={selectedColor}
onChange={handleChange} onChange={handleChange}
onChangeComplete={color => onChange(color.hex)} onChangeComplete={(color) => onChange(color.hex)}
/> />
</Dialog> </Dialog>
); );

View File

@@ -3,11 +3,13 @@ import React from "react";
import { makeStyles } from "@material-ui/core/styles"; import { makeStyles } from "@material-ui/core/styles";
import Container from "@material-ui/core/Container"; import Container from "@material-ui/core/Container";
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles((theme) => ({
mainContainer: { mainContainer: {
flex: 1, flex: 1,
padding: theme.spacing(2), // padding: theme.spacing(2),
height: `calc(100% - 48px)`, // height: `calc(100% - 48px)`,
padding: 0,
height: "100%",
}, },
contentWrapper: { contentWrapper: {
@@ -22,7 +24,7 @@ const MainContainer = ({ children }) => {
const classes = useStyles(); const classes = useStyles();
return ( return (
<Container className={classes.mainContainer}> <Container className={classes.mainContainer} maxWidth={false}>
<div className={classes.contentWrapper}>{children}</div> <div className={classes.contentWrapper}>{children}</div>
</Container> </Container>
); );

View File

@@ -12,6 +12,7 @@ import CircularProgress from "@material-ui/core/CircularProgress";
import { green } from "@material-ui/core/colors"; import { green } from "@material-ui/core/colors";
import AttachFileIcon from "@material-ui/icons/AttachFile"; import AttachFileIcon from "@material-ui/icons/AttachFile";
import IconButton from "@material-ui/core/IconButton"; import IconButton from "@material-ui/core/IconButton";
import MoreVert from "@material-ui/icons/MoreVert";
import MoodIcon from "@material-ui/icons/Mood"; import MoodIcon from "@material-ui/icons/Mood";
import SendIcon from "@material-ui/icons/Send"; import SendIcon from "@material-ui/icons/Send";
import CancelIcon from "@material-ui/icons/Cancel"; import CancelIcon from "@material-ui/icons/Cancel";
@@ -19,7 +20,13 @@ import ClearIcon from "@material-ui/icons/Clear";
import MicIcon from "@material-ui/icons/Mic"; import MicIcon from "@material-ui/icons/Mic";
import CheckCircleOutlineIcon from "@material-ui/icons/CheckCircleOutline"; import CheckCircleOutlineIcon from "@material-ui/icons/CheckCircleOutline";
import HighlightOffIcon from "@material-ui/icons/HighlightOff"; import HighlightOffIcon from "@material-ui/icons/HighlightOff";
import { FormControlLabel, Switch } from "@material-ui/core"; import {
FormControlLabel,
Hidden,
Menu,
MenuItem,
Switch,
} from "@material-ui/core";
import ClickAwayListener from "@material-ui/core/ClickAwayListener"; import ClickAwayListener from "@material-ui/core/ClickAwayListener";
import { i18n } from "../../translate/i18n"; import { i18n } from "../../translate/i18n";
@@ -39,6 +46,11 @@ const useStyles = makeStyles((theme) => ({
flexDirection: "column", flexDirection: "column",
alignItems: "center", alignItems: "center",
borderTop: "1px solid rgba(0, 0, 0, 0.12)", borderTop: "1px solid rgba(0, 0, 0, 0.12)",
[theme.breakpoints.down("sm")]: {
position: "fixed",
bottom: 0,
width: "100%",
},
}, },
newMessageBox: { newMessageBox: {
@@ -56,6 +68,7 @@ const useStyles = makeStyles((theme) => ({
display: "flex", display: "flex",
borderRadius: 20, borderRadius: 20,
flex: 1, flex: 1,
position: "relative",
}, },
messageInput: { messageInput: {
@@ -200,6 +213,7 @@ const MessageInput = ({ ticketStatus }) => {
const [quickAnswers, setQuickAnswer] = useState([]); const [quickAnswers, setQuickAnswer] = useState([]);
const [typeBar, setTypeBar] = useState(false); const [typeBar, setTypeBar] = useState(false);
const inputRef = useRef(); const inputRef = useRef();
const [anchorEl, setAnchorEl] = useState(null);
const { setReplyingMessage, replyingMessage } = const { setReplyingMessage, replyingMessage } =
useContext(ReplyMessageContext); useContext(ReplyMessageContext);
const { user } = useContext(AuthContext); const { user } = useContext(AuthContext);
@@ -363,6 +377,14 @@ const MessageInput = ({ ticketStatus }) => {
} }
}; };
const handleOpenMenuClick = (event) => {
setAnchorEl(event.currentTarget);
};
const handleMenuItemClick = (event) => {
setAnchorEl(null);
};
const renderReplyingMessage = (message) => { const renderReplyingMessage = (message) => {
return ( return (
<div className={classes.replyginMsgWrapper}> <div className={classes.replyginMsgWrapper}>
@@ -429,6 +451,7 @@ const MessageInput = ({ ticketStatus }) => {
<Paper square elevation={0} className={classes.mainWrapper}> <Paper square elevation={0} className={classes.mainWrapper}>
{replyingMessage && renderReplyingMessage(replyingMessage)} {replyingMessage && renderReplyingMessage(replyingMessage)}
<div className={classes.newMessageBox}> <div className={classes.newMessageBox}>
<Hidden only={["sm", "xs"]}>
<IconButton <IconButton
aria-label="emojiPicker" aria-label="emojiPicker"
component="span" component="span"
@@ -483,6 +506,71 @@ const MessageInput = ({ ticketStatus }) => {
/> />
} }
/> />
</Hidden>
<Hidden only={["md", "lg", "xl"]}>
<IconButton
aria-controls="simple-menu"
aria-haspopup="true"
onClick={handleOpenMenuClick}
>
<MoreVert></MoreVert>
</IconButton>
<Menu
id="simple-menu"
keepMounted
anchorEl={anchorEl}
open={Boolean(anchorEl)}
onClose={handleMenuItemClick}
>
<MenuItem onClick={handleMenuItemClick}>
<IconButton
aria-label="emojiPicker"
component="span"
disabled={loading || recording || ticketStatus !== "open"}
onClick={(e) => setShowEmoji((prevState) => !prevState)}
>
<MoodIcon className={classes.sendMessageIcons} />
</IconButton>
</MenuItem>
<MenuItem onClick={handleMenuItemClick}>
<input
multiple
type="file"
id="upload-button"
disabled={loading || recording || ticketStatus !== "open"}
className={classes.uploadInput}
onChange={handleChangeMedias}
/>
<label htmlFor="upload-button">
<IconButton
aria-label="upload"
component="span"
disabled={loading || recording || ticketStatus !== "open"}
>
<AttachFileIcon className={classes.sendMessageIcons} />
</IconButton>
</label>
</MenuItem>
<MenuItem onClick={handleMenuItemClick}>
<FormControlLabel
style={{ marginRight: 7, color: "gray" }}
label={i18n.t("messagesInput.signMessage")}
labelPlacement="start"
control={
<Switch
size="small"
checked={signMessage}
onChange={(e) => {
setSignMessage(e.target.checked);
}}
name="showAllTickets"
color="primary"
/>
}
/>
</MenuItem>
</Menu>
</Hidden>
<div className={classes.messageInputWrapper}> <div className={classes.messageInputWrapper}>
<InputBase <InputBase
inputRef={(input) => { inputRef={(input) => {

View File

@@ -26,7 +26,7 @@ const MessageOptionsMenu = ({ message, menuOpen, handleClose, anchorEl }) => {
handleClose(); handleClose();
}; };
const handleOpenConfirmationModal = e => { const handleOpenConfirmationModal = (e) => {
setConfirmationOpen(true); setConfirmationOpen(true);
handleClose(); handleClose();
}; };

View File

@@ -29,7 +29,7 @@ import whatsBackground from "../../assets/wa-background.png";
import api from "../../services/api"; import api from "../../services/api";
import toastError from "../../errors/toastError"; import toastError from "../../errors/toastError";
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles((theme) => ({
messagesListWrapper: { messagesListWrapper: {
overflow: "hidden", overflow: "hidden",
position: "relative", position: "relative",
@@ -45,6 +45,9 @@ const useStyles = makeStyles(theme => ({
flexGrow: 1, flexGrow: 1,
padding: "20px 20px 20px 20px", padding: "20px 20px 20px 20px",
overflowY: "scroll", overflowY: "scroll",
[theme.breakpoints.down("sm")]: {
paddingBottom: "90px",
},
...theme.scrollbarStyles, ...theme.scrollbarStyles,
}, },
@@ -260,8 +263,8 @@ const reducer = (state, action) => {
const messages = action.payload; const messages = action.payload;
const newMessages = []; const newMessages = [];
messages.forEach(message => { messages.forEach((message) => {
const messageIndex = state.findIndex(m => m.id === message.id); const messageIndex = state.findIndex((m) => m.id === message.id);
if (messageIndex !== -1) { if (messageIndex !== -1) {
state[messageIndex] = message; state[messageIndex] = message;
} else { } else {
@@ -274,7 +277,7 @@ const reducer = (state, action) => {
if (action.type === "ADD_MESSAGE") { if (action.type === "ADD_MESSAGE") {
const newMessage = action.payload; const newMessage = action.payload;
const messageIndex = state.findIndex(m => m.id === newMessage.id); const messageIndex = state.findIndex((m) => m.id === newMessage.id);
if (messageIndex !== -1) { if (messageIndex !== -1) {
state[messageIndex] = newMessage; state[messageIndex] = newMessage;
@@ -287,7 +290,7 @@ const reducer = (state, action) => {
if (action.type === "UPDATE_MESSAGE") { if (action.type === "UPDATE_MESSAGE") {
const messageToUpdate = action.payload; const messageToUpdate = action.payload;
const messageIndex = state.findIndex(m => m.id === messageToUpdate.id); const messageIndex = state.findIndex((m) => m.id === messageToUpdate.id);
if (messageIndex !== -1) { if (messageIndex !== -1) {
state[messageIndex] = messageToUpdate; state[messageIndex] = messageToUpdate;
@@ -357,7 +360,7 @@ const MessagesList = ({ ticketId, isGroup }) => {
socket.on("connect", () => socket.emit("joinChatBox", ticketId)); socket.on("connect", () => socket.emit("joinChatBox", ticketId));
socket.on("appMessage", data => { socket.on("appMessage", (data) => {
if (data.action === "create") { if (data.action === "create") {
dispatch({ type: "ADD_MESSAGE", payload: data.message }); dispatch({ type: "ADD_MESSAGE", payload: data.message });
scrollToBottom(); scrollToBottom();
@@ -374,7 +377,7 @@ const MessagesList = ({ ticketId, isGroup }) => {
}, [ticketId]); }, [ticketId]);
const loadMore = () => { const loadMore = () => {
setPageNumber(prevPageNumber => prevPageNumber + 1); setPageNumber((prevPageNumber) => prevPageNumber + 1);
}; };
const scrollToBottom = () => { const scrollToBottom = () => {
@@ -383,7 +386,7 @@ const MessagesList = ({ ticketId, isGroup }) => {
} }
}; };
const handleScroll = e => { const handleScroll = (e) => {
if (!hasMore) return; if (!hasMore) return;
const { scrollTop } = e.currentTarget; const { scrollTop } = e.currentTarget;
@@ -405,11 +408,11 @@ const MessagesList = ({ ticketId, isGroup }) => {
setSelectedMessage(message); setSelectedMessage(message);
}; };
const handleCloseMessageOptionsMenu = e => { const handleCloseMessageOptionsMenu = (e) => {
setAnchorEl(null); setAnchorEl(null);
}; };
const checkMessageMedia = message => { const checkMessageMedia = (message) => {
if (message.mediaType === "image") { if (message.mediaType === "image") {
return <ModalImageCors imageUrl={message.mediaUrl} />; return <ModalImageCors imageUrl={message.mediaUrl} />;
} }
@@ -449,7 +452,7 @@ const MessagesList = ({ ticketId, isGroup }) => {
} }
}; };
const renderMessageAck = message => { const renderMessageAck = (message) => {
if (message.ack === 0) { if (message.ack === 0) {
return <AccessTime fontSize="small" className={classes.ackIcons} />; return <AccessTime fontSize="small" className={classes.ackIcons} />;
} }
@@ -518,7 +521,7 @@ const MessagesList = ({ ticketId, isGroup }) => {
} }
}; };
const renderQuotedMessage = message => { const renderQuotedMessage = (message) => {
return ( return (
<div <div
className={clsx(classes.quotedContainerLeft, { className={clsx(classes.quotedContainerLeft, {
@@ -557,7 +560,7 @@ const MessagesList = ({ ticketId, isGroup }) => {
id="messageActionsButton" id="messageActionsButton"
disabled={message.isDeleted} disabled={message.isDeleted}
className={classes.messageActionsButton} className={classes.messageActionsButton}
onClick={e => handleOpenMessageOptionsMenu(e, message)} onClick={(e) => handleOpenMessageOptionsMenu(e, message)}
> >
<ExpandMore /> <ExpandMore />
</IconButton> </IconButton>
@@ -589,7 +592,7 @@ const MessagesList = ({ ticketId, isGroup }) => {
id="messageActionsButton" id="messageActionsButton"
disabled={message.isDeleted} disabled={message.isDeleted}
className={classes.messageActionsButton} className={classes.messageActionsButton}
onClick={e => handleOpenMessageOptionsMenu(e, message)} onClick={(e) => handleOpenMessageOptionsMenu(e, message)}
> >
<ExpandMore /> <ExpandMore />
</IconButton> </IconButton>

View File

@@ -19,7 +19,7 @@ import toastError from "../../errors/toastError";
const drawerWidth = 320; const drawerWidth = 320;
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles((theme) => ({
root: { root: {
display: "flex", display: "flex",
height: "100%", height: "100%",
@@ -27,6 +27,25 @@ const useStyles = makeStyles(theme => ({
overflow: "hidden", overflow: "hidden",
}, },
ticketInfo: {
maxWidth: "50%",
flexBasis: "50%",
[theme.breakpoints.down("sm")]: {
maxWidth: "80%",
flexBasis: "80%",
},
},
ticketActionButtons: {
maxWidth: "50%",
flexBasis: "50%",
display: "flex",
[theme.breakpoints.down("sm")]: {
maxWidth: "100%",
flexBasis: "100%",
marginBottom: "5px",
},
},
mainWrapper: { mainWrapper: {
flex: 1, flex: 1,
height: "100%", height: "100%",
@@ -89,7 +108,7 @@ const Ticket = () => {
socket.on("connect", () => socket.emit("joinChatBox", ticketId)); socket.on("connect", () => socket.emit("joinChatBox", ticketId));
socket.on("ticket", data => { socket.on("ticket", (data) => {
if (data.action === "update") { if (data.action === "update") {
setTicket(data.ticket); setTicket(data.ticket);
} }
@@ -100,9 +119,9 @@ const Ticket = () => {
} }
}); });
socket.on("contact", data => { socket.on("contact", (data) => {
if (data.action === "update") { if (data.action === "update") {
setContact(prevState => { setContact((prevState) => {
if (prevState.id === data.contact?.id) { if (prevState.id === data.contact?.id) {
return { ...prevState, ...data.contact }; return { ...prevState, ...data.contact };
} }
@@ -134,12 +153,16 @@ const Ticket = () => {
})} })}
> >
<TicketHeader loading={loading}> <TicketHeader loading={loading}>
<div className={classes.ticketInfo}>
<TicketInfo <TicketInfo
contact={contact} contact={contact}
ticket={ticket} ticket={ticket}
onClick={handleDrawerOpen} onClick={handleDrawerOpen}
/> />
</div>
<div className={classes.ticketActionButtons}>
<TicketActionButtons ticket={ticket} /> <TicketActionButtons ticket={ticket} />
</div>
</TicketHeader> </TicketHeader>
<ReplyMessageProvider> <ReplyMessageProvider>
<MessagesList <MessagesList

View File

@@ -1,20 +1,29 @@
import React from "react"; import React from "react";
import { Card } from "@material-ui/core"; import { Card, Button } from "@material-ui/core";
import { makeStyles } from "@material-ui/core/styles"; import { makeStyles } from "@material-ui/core/styles";
import TicketHeaderSkeleton from "../TicketHeaderSkeleton"; import TicketHeaderSkeleton from "../TicketHeaderSkeleton";
import ArrowBackIos from "@material-ui/icons/ArrowBackIos";
import { useHistory } from "react-router-dom";
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles((theme) => ({
ticketHeader: { ticketHeader: {
display: "flex", display: "flex",
backgroundColor: "#eee", backgroundColor: "#eee",
flex: "none", flex: "none",
borderBottom: "1px solid rgba(0, 0, 0, 0.12)", borderBottom: "1px solid rgba(0, 0, 0, 0.12)",
[theme.breakpoints.down("sm")]: {
flexWrap: "wrap",
},
}, },
})); }));
const TicketHeader = ({ loading, children }) => { const TicketHeader = ({ loading, children }) => {
const classes = useStyles(); const classes = useStyles();
const history = useHistory();
const handleBack = () => {
history.push("/tickets");
};
return ( return (
<> <>
@@ -22,6 +31,9 @@ const TicketHeader = ({ loading, children }) => {
<TicketHeaderSkeleton /> <TicketHeaderSkeleton />
) : ( ) : (
<Card square className={classes.ticketHeader}> <Card square className={classes.ticketHeader}>
<Button color="primary" onClick={handleBack}>
<ArrowBackIos />
</Button>
{children} {children}
</Card> </Card>
)} )}

View File

@@ -22,7 +22,7 @@ import { Can } from "../Can";
import TicketsQueueSelect from "../TicketsQueueSelect"; import TicketsQueueSelect from "../TicketsQueueSelect";
import { Button } from "@material-ui/core"; import { Button } from "@material-ui/core";
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles((theme) => ({
ticketsWrapper: { ticketsWrapper: {
position: "relative", position: "relative",
display: "flex", display: "flex",
@@ -90,7 +90,7 @@ const TicketsManager = () => {
const searchInputRef = useRef(); const searchInputRef = useRef();
const { user } = useContext(AuthContext); const { user } = useContext(AuthContext);
const userQueueIds = user.queues.map(q => q.id); const userQueueIds = user.queues.map((q) => q.id);
const [selectedQueueIds, setSelectedQueueIds] = useState(userQueueIds || []); const [selectedQueueIds, setSelectedQueueIds] = useState(userQueueIds || []);
useEffect(() => { useEffect(() => {
@@ -101,7 +101,7 @@ const TicketsManager = () => {
let searchTimeout; let searchTimeout;
const handleSearch = e => { const handleSearch = (e) => {
const searchedTerm = e.target.value.toLowerCase(); const searchedTerm = e.target.value.toLowerCase();
clearTimeout(searchTimeout); clearTimeout(searchTimeout);
@@ -125,7 +125,7 @@ const TicketsManager = () => {
<Paper elevation={0} variant="outlined" className={classes.ticketsWrapper}> <Paper elevation={0} variant="outlined" className={classes.ticketsWrapper}>
<NewTicketModal <NewTicketModal
modalOpen={newTicketModalOpen} modalOpen={newTicketModalOpen}
onClose={e => setNewTicketModalOpen(false)} onClose={(e) => setNewTicketModalOpen(false)}
/> />
<Paper elevation={0} square className={classes.tabsHeader}> <Paper elevation={0} square className={classes.tabsHeader}>
<Tabs <Tabs
@@ -189,7 +189,7 @@ const TicketsManager = () => {
size="small" size="small"
checked={showAllTickets} checked={showAllTickets}
onChange={() => onChange={() =>
setShowAllTickets(prevState => !prevState) setShowAllTickets((prevState) => !prevState)
} }
name="showAllTickets" name="showAllTickets"
color="primary" color="primary"
@@ -204,7 +204,7 @@ const TicketsManager = () => {
style={{ marginLeft: 6 }} style={{ marginLeft: 6 }}
selectedQueueIds={selectedQueueIds} selectedQueueIds={selectedQueueIds}
userQueues={user?.queues} userQueues={user?.queues}
onChange={values => setSelectedQueueIds(values)} onChange={(values) => setSelectedQueueIds(values)}
/> />
</Paper> </Paper>
<TabPanel value={tab} name="open" className={classes.ticketsWrapper}> <TabPanel value={tab} name="open" className={classes.ticketsWrapper}>

View File

@@ -40,8 +40,8 @@ const reducer = (state, action) => {
const contacts = action.payload; const contacts = action.payload;
const newContacts = []; const newContacts = [];
contacts.forEach(contact => { contacts.forEach((contact) => {
const contactIndex = state.findIndex(c => c.id === contact.id); const contactIndex = state.findIndex((c) => c.id === contact.id);
if (contactIndex !== -1) { if (contactIndex !== -1) {
state[contactIndex] = contact; state[contactIndex] = contact;
} else { } else {
@@ -54,7 +54,7 @@ const reducer = (state, action) => {
if (action.type === "UPDATE_CONTACTS") { if (action.type === "UPDATE_CONTACTS") {
const contact = action.payload; const contact = action.payload;
const contactIndex = state.findIndex(c => c.id === contact.id); const contactIndex = state.findIndex((c) => c.id === contact.id);
if (contactIndex !== -1) { if (contactIndex !== -1) {
state[contactIndex] = contact; state[contactIndex] = contact;
@@ -67,7 +67,7 @@ const reducer = (state, action) => {
if (action.type === "DELETE_CONTACT") { if (action.type === "DELETE_CONTACT") {
const contactId = action.payload; const contactId = action.payload;
const contactIndex = state.findIndex(c => c.id === contactId); const contactIndex = state.findIndex((c) => c.id === contactId);
if (contactIndex !== -1) { if (contactIndex !== -1) {
state.splice(contactIndex, 1); state.splice(contactIndex, 1);
} }
@@ -79,7 +79,7 @@ const reducer = (state, action) => {
} }
}; };
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles((theme) => ({
mainPaper: { mainPaper: {
flex: 1, flex: 1,
padding: theme.spacing(1), padding: theme.spacing(1),
@@ -132,7 +132,7 @@ const Contacts = () => {
useEffect(() => { useEffect(() => {
const socket = openSocket(process.env.REACT_APP_BACKEND_URL); const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
socket.on("contact", data => { socket.on("contact", (data) => {
if (data.action === "update" || data.action === "create") { if (data.action === "update" || data.action === "create") {
dispatch({ type: "UPDATE_CONTACTS", payload: data.contact }); dispatch({ type: "UPDATE_CONTACTS", payload: data.contact });
} }
@@ -147,7 +147,7 @@ const Contacts = () => {
}; };
}, []); }, []);
const handleSearch = event => { const handleSearch = (event) => {
setSearchParam(event.target.value.toLowerCase()); setSearchParam(event.target.value.toLowerCase());
}; };
@@ -161,7 +161,7 @@ const Contacts = () => {
setContactModalOpen(false); setContactModalOpen(false);
}; };
const handleSaveTicket = async contactId => { const handleSaveTicket = async (contactId) => {
if (!contactId) return; if (!contactId) return;
setLoading(true); setLoading(true);
try { try {
@@ -177,12 +177,12 @@ const Contacts = () => {
setLoading(false); setLoading(false);
}; };
const hadleEditContact = contactId => { const hadleEditContact = (contactId) => {
setSelectedContactId(contactId); setSelectedContactId(contactId);
setContactModalOpen(true); setContactModalOpen(true);
}; };
const handleDeleteContact = async contactId => { const handleDeleteContact = async (contactId) => {
try { try {
await api.delete(`/contacts/${contactId}`); await api.delete(`/contacts/${contactId}`);
toast.success(i18n.t("contacts.toasts.deleted")); toast.success(i18n.t("contacts.toasts.deleted"));
@@ -204,10 +204,10 @@ const Contacts = () => {
}; };
const loadMore = () => { const loadMore = () => {
setPageNumber(prevState => prevState + 1); setPageNumber((prevState) => prevState + 1);
}; };
const handleScroll = e => { const handleScroll = (e) => {
if (!hasMore || loading) return; if (!hasMore || loading) return;
const { scrollTop, scrollHeight, clientHeight } = e.currentTarget; const { scrollTop, scrollHeight, clientHeight } = e.currentTarget;
if (scrollHeight - (scrollTop + 100) < clientHeight) { if (scrollHeight - (scrollTop + 100) < clientHeight) {
@@ -233,7 +233,7 @@ const Contacts = () => {
} }
open={confirmOpen} open={confirmOpen}
onClose={setConfirmOpen} onClose={setConfirmOpen}
onConfirm={e => onConfirm={(e) =>
deletingContact deletingContact
? handleDeleteContact(deletingContact.id) ? handleDeleteContact(deletingContact.id)
: handleimportContact() : handleimportContact()
@@ -262,7 +262,7 @@ const Contacts = () => {
<Button <Button
variant="contained" variant="contained"
color="primary" color="primary"
onClick={e => setConfirmOpen(true)} onClick={(e) => setConfirmOpen(true)}
> >
{i18n.t("contacts.buttons.import")} {i18n.t("contacts.buttons.import")}
</Button> </Button>
@@ -298,7 +298,7 @@ const Contacts = () => {
</TableHead> </TableHead>
<TableBody> <TableBody>
<> <>
{contacts.map(contact => ( {contacts.map((contact) => (
<TableRow key={contact.id}> <TableRow key={contact.id}>
<TableCell style={{ paddingRight: 0 }}> <TableCell style={{ paddingRight: 0 }}>
{<Avatar src={contact.profilePicUrl} />} {<Avatar src={contact.profilePicUrl} />}
@@ -325,7 +325,7 @@ const Contacts = () => {
yes={() => ( yes={() => (
<IconButton <IconButton
size="small" size="small"
onClick={e => { onClick={(e) => {
setConfirmOpen(true); setConfirmOpen(true);
setDeletingContact(contact); setDeletingContact(contact);
}} }}

View File

@@ -30,7 +30,7 @@ import { AuthContext } from "../../context/Auth/AuthContext";
// ); // );
// }; // };
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles((theme) => ({
paper: { paper: {
marginTop: theme.spacing(8), marginTop: theme.spacing(8),
display: "flex", display: "flex",
@@ -57,11 +57,11 @@ const Login = () => {
const { handleLogin } = useContext(AuthContext); const { handleLogin } = useContext(AuthContext);
const handleChangeInput = e => { const handleChangeInput = (e) => {
setUser({ ...user, [e.target.name]: e.target.value }); setUser({ ...user, [e.target.name]: e.target.value });
}; };
const handlSubmit = e => { const handlSubmit = (e) => {
e.preventDefault(); e.preventDefault();
handleLogin(user); handleLogin(user);
}; };

View File

@@ -28,7 +28,7 @@ import QueueModal from "../../components/QueueModal";
import { toast } from "react-toastify"; import { toast } from "react-toastify";
import ConfirmationModal from "../../components/ConfirmationModal"; import ConfirmationModal from "../../components/ConfirmationModal";
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles((theme) => ({
mainPaper: { mainPaper: {
flex: 1, flex: 1,
padding: theme.spacing(1), padding: theme.spacing(1),
@@ -47,8 +47,8 @@ const reducer = (state, action) => {
const queues = action.payload; const queues = action.payload;
const newQueues = []; const newQueues = [];
queues.forEach(queue => { queues.forEach((queue) => {
const queueIndex = state.findIndex(q => q.id === queue.id); const queueIndex = state.findIndex((q) => q.id === queue.id);
if (queueIndex !== -1) { if (queueIndex !== -1) {
state[queueIndex] = queue; state[queueIndex] = queue;
} else { } else {
@@ -61,7 +61,7 @@ const reducer = (state, action) => {
if (action.type === "UPDATE_QUEUES") { if (action.type === "UPDATE_QUEUES") {
const queue = action.payload; const queue = action.payload;
const queueIndex = state.findIndex(u => u.id === queue.id); const queueIndex = state.findIndex((u) => u.id === queue.id);
if (queueIndex !== -1) { if (queueIndex !== -1) {
state[queueIndex] = queue; state[queueIndex] = queue;
@@ -73,7 +73,7 @@ const reducer = (state, action) => {
if (action.type === "DELETE_QUEUE") { if (action.type === "DELETE_QUEUE") {
const queueId = action.payload; const queueId = action.payload;
const queueIndex = state.findIndex(q => q.id === queueId); const queueIndex = state.findIndex((q) => q.id === queueId);
if (queueIndex !== -1) { if (queueIndex !== -1) {
state.splice(queueIndex, 1); state.splice(queueIndex, 1);
} }
@@ -113,7 +113,7 @@ const Queues = () => {
useEffect(() => { useEffect(() => {
const socket = openSocket(process.env.REACT_APP_BACKEND_URL); const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
socket.on("queue", data => { socket.on("queue", (data) => {
if (data.action === "update" || data.action === "create") { if (data.action === "update" || data.action === "create") {
dispatch({ type: "UPDATE_QUEUES", payload: data.queue }); dispatch({ type: "UPDATE_QUEUES", payload: data.queue });
} }
@@ -138,7 +138,7 @@ const Queues = () => {
setSelectedQueue(null); setSelectedQueue(null);
}; };
const handleEditQueue = queue => { const handleEditQueue = (queue) => {
setSelectedQueue(queue); setSelectedQueue(queue);
setQueueModalOpen(true); setQueueModalOpen(true);
}; };
@@ -148,7 +148,7 @@ const Queues = () => {
setSelectedQueue(null); setSelectedQueue(null);
}; };
const handleDeleteQueue = async queueId => { const handleDeleteQueue = async (queueId) => {
try { try {
await api.delete(`/queue/${queueId}`); await api.delete(`/queue/${queueId}`);
toast.success(i18n.t("Queue deleted successfully!")); toast.success(i18n.t("Queue deleted successfully!"));
@@ -210,7 +210,7 @@ const Queues = () => {
</TableHead> </TableHead>
<TableBody> <TableBody>
<> <>
{queues.map(queue => ( {queues.map((queue) => (
<TableRow key={queue.id}> <TableRow key={queue.id}>
<TableCell align="center">{queue.name}</TableCell> <TableCell align="center">{queue.name}</TableCell>
<TableCell align="center"> <TableCell align="center">

View File

@@ -8,12 +8,13 @@ import TicketsManager from "../../components/TicketsManager/";
import Ticket from "../../components/Ticket/"; import Ticket from "../../components/Ticket/";
import { i18n } from "../../translate/i18n"; import { i18n } from "../../translate/i18n";
import Hidden from "@material-ui/core/Hidden";
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles((theme) => ({
chatContainer: { chatContainer: {
flex: 1, flex: 1,
// backgroundColor: "#eee", // // backgroundColor: "#eee",
padding: theme.spacing(4), // padding: theme.spacing(4),
height: `calc(100% - 48px)`, height: `calc(100% - 48px)`,
overflowY: "hidden", overflowY: "hidden",
}, },
@@ -30,6 +31,15 @@ const useStyles = makeStyles(theme => ({
flexDirection: "column", flexDirection: "column",
overflowY: "hidden", overflowY: "hidden",
}, },
contactsWrapperSmall: {
display: "flex",
height: "100%",
flexDirection: "column",
overflowY: "hidden",
[theme.breakpoints.down("sm")]: {
display: "none",
},
},
messagessWrapper: { messagessWrapper: {
display: "flex", display: "flex",
height: "100%", height: "100%",
@@ -42,6 +52,13 @@ const useStyles = makeStyles(theme => ({
alignItems: "center", alignItems: "center",
height: "100%", height: "100%",
textAlign: "center", textAlign: "center",
borderRadius: 0,
},
ticketsManager: {},
ticketsManagerClosed: {
[theme.breakpoints.down("sm")]: {
display: "none",
},
}, },
})); }));
@@ -53,18 +70,30 @@ const Chat = () => {
<div className={classes.chatContainer}> <div className={classes.chatContainer}>
<div className={classes.chatPapper}> <div className={classes.chatPapper}>
<Grid container spacing={0}> <Grid container spacing={0}>
<Grid item xs={4} className={classes.contactsWrapper}> {/* <Grid item xs={4} className={classes.contactsWrapper}> */}
<Grid
item
xs={12}
md={4}
className={
ticketId ? classes.contactsWrapperSmall : classes.contactsWrapper
}
>
<TicketsManager /> <TicketsManager />
</Grid> </Grid>
<Grid item xs={8} className={classes.messagessWrapper}> <Grid item xs={12} md={8} className={classes.messagessWrapper}>
{/* <Grid item xs={8} className={classes.messagessWrapper}> */}
{ticketId ? ( {ticketId ? (
<> <>
<Ticket /> <Ticket />
</> </>
) : ( ) : (
<Paper square variant="outlined" className={classes.welcomeMsg}> <Hidden only={["sm", "xs"]}>
<Paper className={classes.welcomeMsg}>
{/* <Paper square variant="outlined" className={classes.welcomeMsg}> */}
<span>{i18n.t("chat.noTicketMessage")}</span> <span>{i18n.t("chat.noTicketMessage")}</span>
</Paper> </Paper>
</Hidden>
)} )}
</Grid> </Grid>
</Grid> </Grid>

View File

@@ -35,8 +35,8 @@ const reducer = (state, action) => {
const users = action.payload; const users = action.payload;
const newUsers = []; const newUsers = [];
users.forEach(user => { users.forEach((user) => {
const userIndex = state.findIndex(u => u.id === user.id); const userIndex = state.findIndex((u) => u.id === user.id);
if (userIndex !== -1) { if (userIndex !== -1) {
state[userIndex] = user; state[userIndex] = user;
} else { } else {
@@ -49,7 +49,7 @@ const reducer = (state, action) => {
if (action.type === "UPDATE_USERS") { if (action.type === "UPDATE_USERS") {
const user = action.payload; const user = action.payload;
const userIndex = state.findIndex(u => u.id === user.id); const userIndex = state.findIndex((u) => u.id === user.id);
if (userIndex !== -1) { if (userIndex !== -1) {
state[userIndex] = user; state[userIndex] = user;
@@ -62,7 +62,7 @@ const reducer = (state, action) => {
if (action.type === "DELETE_USER") { if (action.type === "DELETE_USER") {
const userId = action.payload; const userId = action.payload;
const userIndex = state.findIndex(u => u.id === userId); const userIndex = state.findIndex((u) => u.id === userId);
if (userIndex !== -1) { if (userIndex !== -1) {
state.splice(userIndex, 1); state.splice(userIndex, 1);
} }
@@ -74,7 +74,7 @@ const reducer = (state, action) => {
} }
}; };
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles((theme) => ({
mainPaper: { mainPaper: {
flex: 1, flex: 1,
padding: theme.spacing(1), padding: theme.spacing(1),
@@ -124,7 +124,7 @@ const Users = () => {
useEffect(() => { useEffect(() => {
const socket = openSocket(process.env.REACT_APP_BACKEND_URL); const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
socket.on("user", data => { socket.on("user", (data) => {
if (data.action === "update" || data.action === "create") { if (data.action === "update" || data.action === "create") {
dispatch({ type: "UPDATE_USERS", payload: data.user }); dispatch({ type: "UPDATE_USERS", payload: data.user });
} }
@@ -149,16 +149,16 @@ const Users = () => {
setUserModalOpen(false); setUserModalOpen(false);
}; };
const handleSearch = event => { const handleSearch = (event) => {
setSearchParam(event.target.value.toLowerCase()); setSearchParam(event.target.value.toLowerCase());
}; };
const handleEditUser = user => { const handleEditUser = (user) => {
setSelectedUser(user); setSelectedUser(user);
setUserModalOpen(true); setUserModalOpen(true);
}; };
const handleDeleteUser = async userId => { const handleDeleteUser = async (userId) => {
try { try {
await api.delete(`/users/${userId}`); await api.delete(`/users/${userId}`);
toast.success(i18n.t("users.toasts.deleted")); toast.success(i18n.t("users.toasts.deleted"));
@@ -171,10 +171,10 @@ const Users = () => {
}; };
const loadMore = () => { const loadMore = () => {
setPageNumber(prevState => prevState + 1); setPageNumber((prevState) => prevState + 1);
}; };
const handleScroll = e => { const handleScroll = (e) => {
if (!hasMore || loading) return; if (!hasMore || loading) return;
const { scrollTop, scrollHeight, clientHeight } = e.currentTarget; const { scrollTop, scrollHeight, clientHeight } = e.currentTarget;
if (scrollHeight - (scrollTop + 100) < clientHeight) { if (scrollHeight - (scrollTop + 100) < clientHeight) {
@@ -250,7 +250,7 @@ const Users = () => {
</TableHead> </TableHead>
<TableBody> <TableBody>
<> <>
{users.map(user => ( {users.map((user) => (
<TableRow key={user.id}> <TableRow key={user.id}>
<TableCell align="center">{user.name}</TableCell> <TableCell align="center">{user.name}</TableCell>
<TableCell align="center">{user.email}</TableCell> <TableCell align="center">{user.email}</TableCell>
@@ -265,7 +265,7 @@ const Users = () => {
<IconButton <IconButton
size="small" size="small"
onClick={e => { onClick={(e) => {
setConfirmModalOpen(true); setConfirmModalOpen(true);
setDeletingUser(user); setDeletingUser(user);
}} }}