From 2a73d7e89d672c56c5a2e078fd7711e8ed952aea Mon Sep 17 00:00:00 2001 From: canove Date: Mon, 20 Jul 2020 17:00:52 -0300 Subject: [PATCH] Styles change in chat --- backend/src/models/Message.js | 8 +++ frontend/src/components/Layout/MainDrawer.js | 9 +-- frontend/src/pages/Chat/Chat.js | 10 ++- .../ContactsHeader/ContactsHeader.js | 47 ------------- .../components/MessagesInput/MessagesInput.js | 16 ++--- .../components/MessagesList/MessagesList.js | 67 ++++++++++++------- .../components/TicketsList/TicketsList.js | 49 +++++++------- frontend/src/pages/WhatsAuth/WhatsAuth.js | 61 ++++++----------- .../src/pages/WhatsAuth/components/Qrcode.js | 2 +- 9 files changed, 113 insertions(+), 156 deletions(-) delete mode 100644 frontend/src/pages/Chat/components/ContactsHeader/ContactsHeader.js diff --git a/backend/src/models/Message.js b/backend/src/models/Message.js index af5e3e7..3946be3 100644 --- a/backend/src/models/Message.js +++ b/backend/src/models/Message.js @@ -9,6 +9,14 @@ class Message extends Sequelize.Model { body: { type: Sequelize.TEXT }, mediaUrl: { type: Sequelize.STRING }, mediaType: { type: Sequelize.STRING }, + createdAt: { + type: Sequelize.DATE(6), + allowNull: false, + }, + updatedAt: { + type: Sequelize.DATE(6), + allowNull: false, + }, }, { sequelize, diff --git a/frontend/src/components/Layout/MainDrawer.js b/frontend/src/components/Layout/MainDrawer.js index cf101f2..184ba8b 100644 --- a/frontend/src/components/Layout/MainDrawer.js +++ b/frontend/src/components/Layout/MainDrawer.js @@ -39,7 +39,7 @@ const useStyles = makeStyles(theme => ({ alignItems: "center", justifyContent: "flex-end", padding: "0 8px", - ...theme.mixins.toolbar, + minHeight: "48px", }, appBar: { zIndex: theme.zIndex.drawer + 1, @@ -85,10 +85,11 @@ const useStyles = makeStyles(theme => ({ width: theme.spacing(9), }, }, - appBarSpacer: theme.mixins.toolbar, + appBarSpacer: { + minHeight: "48px", + }, content: { flex: 1, - // height: "100%", overflow: "auto", }, container: { @@ -158,7 +159,7 @@ const MainDrawer = ({ appTitle, children }) => { position="absolute" className={clsx(classes.appBar, open && classes.appBarShift)} > - + ({ flex: 1, // backgroundColor: "#eee", padding: theme.spacing(4), - height: `calc(100% - 64px)`, + height: `calc(100% - 48px)`, overflowY: "hidden", }, chatPapper: { - backgroundColor: "#eee", + // backgroundColor: "#eee", display: "flex", height: "100%", - overflowY: "hidden", }, contactsWrapper: { display: "flex", height: "100%", flexDirection: "column", - overflow: "hidden", + overflowY: "hidden", }, messagessWrapper: { display: "flex", height: "100%", flexDirection: "column", - overflow: "hidden", }, welcomeMsg: { backgroundColor: "#eee", @@ -51,7 +49,7 @@ const Chat = () => { return (
- + diff --git a/frontend/src/pages/Chat/components/ContactsHeader/ContactsHeader.js b/frontend/src/pages/Chat/components/ContactsHeader/ContactsHeader.js deleted file mode 100644 index 2ab1794..0000000 --- a/frontend/src/pages/Chat/components/ContactsHeader/ContactsHeader.js +++ /dev/null @@ -1,47 +0,0 @@ -import React from "react"; - -import { makeStyles } from "@material-ui/core/styles"; -import Card from "@material-ui/core/Card"; -import CardHeader from "@material-ui/core/CardHeader"; -import IconButton from "@material-ui/core/IconButton"; -import MoreVertIcon from "@material-ui/icons/MoreVert"; -import Avatar from "@material-ui/core/Avatar"; - -import profileDefaultPic from "../../../../Images/profile_default.png"; - -const useStyles = makeStyles(theme => ({ - contactsHeader: { - display: "flex", - flex: "none", - // height: 80, - backgroundColor: "#eee", - borderBottomLeftRadius: 0, - borderBottomRightRadius: 0, - borderTopRightRadius: 0, - }, - settingsIcon: { - alignSelf: "center", - marginLeft: "auto", - padding: 8, - }, -})); - -const ContactsHeader = () => { - const classes = useStyles(); - - const username = localStorage.getItem("username"); - - return ( - - } - title={username} - /> - - - - - ); -}; - -export default ContactsHeader; diff --git a/frontend/src/pages/Chat/components/MessagesInput/MessagesInput.js b/frontend/src/pages/Chat/components/MessagesInput/MessagesInput.js index 3bf99f7..aaad664 100644 --- a/frontend/src/pages/Chat/components/MessagesInput/MessagesInput.js +++ b/frontend/src/pages/Chat/components/MessagesInput/MessagesInput.js @@ -27,15 +27,16 @@ const useStyles = makeStyles(theme => ({ newMessageBox: { background: "#eee", display: "flex", - padding: "10px", + padding: "7px", alignItems: "center", + borderTop: "1px solid rgba(0, 0, 0, 0.12)", }, messageInputWrapper: { padding: 6, background: "#fff", display: "flex", - borderRadius: 40, + borderRadius: 20, flex: 1, }, @@ -60,6 +61,7 @@ const useStyles = makeStyles(theme => ({ justifyContent: "space-between", alignItems: "center", backgroundColor: "#eee", + borderTop: "1px solid rgba(0, 0, 0, 0.12)", }, emojiBox: { @@ -240,11 +242,7 @@ const MessagesInput = ({ searchParam }) => { if (media.preview) return ( - + { ); else { return ( - + { inputRef={input => input && !searchParam && input.focus()} className={classes.messageInput} placeholder="Escreva uma mensagem" + multiline + rowsMax={5} value={inputMessage} onChange={handleChangeInput} disabled={recording} diff --git a/frontend/src/pages/Chat/components/MessagesList/MessagesList.js b/frontend/src/pages/Chat/components/MessagesList/MessagesList.js index 07a7c22..fd5fe1c 100644 --- a/frontend/src/pages/Chat/components/MessagesList/MessagesList.js +++ b/frontend/src/pages/Chat/components/MessagesList/MessagesList.js @@ -16,6 +16,7 @@ import CardHeader from "@material-ui/core/CardHeader"; import ReplayIcon from "@material-ui/icons/Replay"; import Avatar from "@material-ui/core/Avatar"; import Button from "@material-ui/core/Button"; +import Paper from "@material-ui/core/Paper"; import { green } from "@material-ui/core/colors"; import whatsBackground from "../../../../Images/wa-background.png"; @@ -30,12 +31,16 @@ const useStyles = makeStyles(theme => ({ display: "flex", flexDirection: "column", overflow: "hidden", + borderTopLeftRadius: 0, + borderBottomLeftRadius: 0, + borderLeft: "0", }, messagesHeader: { display: "flex", backgroundColor: "#eee", flex: "none", + borderBottom: "1px solid rgba(0, 0, 0, 0.12)", }, actionButtons: { @@ -83,7 +88,8 @@ const useStyles = makeStyles(theme => ({ }, messageLeft: { - marginTop: 5, + marginRight: 20, + marginTop: 2, minWidth: 100, maxWidth: 600, height: "auto", @@ -92,20 +98,20 @@ const useStyles = makeStyles(theme => ({ backgroundColor: "#ffffff", alignSelf: "flex-start", - borderTopLeftRadius: 8, + borderTopLeftRadius: 0, borderTopRightRadius: 8, - borderBottomLeftRadius: 0, + borderBottomLeftRadius: 8, borderBottomRightRadius: 8, paddingLeft: 5, paddingRight: 5, paddingTop: 5, paddingBottom: 0, - boxShadow: "0 2px 2px #808888", + boxShadow: "0 1px 1px #b3b3b3", }, messageRight: { marginLeft: 20, - marginTop: 5, + marginTop: 2, minWidth: 100, maxWidth: 600, height: "auto", @@ -122,7 +128,7 @@ const useStyles = makeStyles(theme => ({ paddingRight: 5, paddingTop: 5, paddingBottom: 0, - boxShadow: "0 2px 2px #808888", + boxShadow: "0 1px 1px #b3b3b3", }, textContentItem: { @@ -156,6 +162,7 @@ const useStyles = makeStyles(theme => ({ backgroundColor: "#e1f3fb", margin: "10px", borderRadius: "10px", + boxShadow: "0 1px 1px #b3b3b3", }, dailyTimestampText: { @@ -432,8 +439,8 @@ const MessagesList = () => { }; return ( -
- + + {contact.name ? ( { )}
- - + {ticket.status === "closed" ? ( + + ) : ( + <> + + + + )}
@@ -487,7 +506,7 @@ const MessagesList = () => {
) : null}
-
+ ); }; diff --git a/frontend/src/pages/Chat/components/TicketsList/TicketsList.js b/frontend/src/pages/Chat/components/TicketsList/TicketsList.js index 385bb5e..0d8f45c 100644 --- a/frontend/src/pages/Chat/components/TicketsList/TicketsList.js +++ b/frontend/src/pages/Chat/components/TicketsList/TicketsList.js @@ -37,14 +37,13 @@ const useStyles = makeStyles(theme => ({ height: "100%", flexDirection: "column", overflow: "hidden", + borderTopRightRadius: 0, + borderBottomRightRadius: 0, }, contactsHeader: { display: "flex", backgroundColor: "#eee", - borderBottomLeftRadius: 0, - borderBottomRightRadius: 0, - borderTopRightRadius: 0, }, settingsIcon: { @@ -55,9 +54,6 @@ const useStyles = makeStyles(theme => ({ openTicketsList: { position: "relative", - borderTopLeftRadius: 0, - borderTopRightRadius: 0, - borderBottomRightRadius: 0, height: "50%", overflowY: "scroll", "&::-webkit-scrollbar": { @@ -67,13 +63,11 @@ const useStyles = makeStyles(theme => ({ boxShadow: "inset 0 0 6px rgba(0, 0, 0, 0.3)", backgroundColor: "#e8e8e8", }, + borderTop: "2px solid rgba(0, 0, 0, 0.12)", }, closedTicketsList: { position: "relative", - borderTopLeftRadius: 0, - borderTopRightRadius: 0, - borderBottomRightRadius: 0, flex: 1, overflowY: "scroll", "&::-webkit-scrollbar": { @@ -83,6 +77,7 @@ const useStyles = makeStyles(theme => ({ boxShadow: "inset 0 0 6px rgba(0, 0, 0, 0.3)", backgroundColor: "#e8e8e8", }, + borderTop: "2px solid rgba(0, 0, 0, 0.12)", }, ticketsListHeader: { @@ -90,12 +85,12 @@ const useStyles = makeStyles(theme => ({ // flexShrink: 0, // -webkitBoxAlign: "center", alignItems: "center", - fontWeight: 600, + fontWeight: 500, fontSize: "16px", height: "56px", // backgroundColor: "#eee", color: "rgb(67, 83, 105)", - padding: "0px 24px", + padding: "0px 12px", borderBottom: "1px solid rgba(0, 0, 0, 0.12)", }, @@ -305,11 +300,16 @@ const TicketsList = () => { const resetUnreadMessages = ticketId => { setTickets(prevState => { - let aux = [...prevState]; - let ticketIndex = aux.findIndex(ticket => ticket.id === +ticketId); - aux[ticketIndex].unreadMessages = 0; - - return aux; + const ticketIndex = prevState.findIndex( + ticket => ticket.id === +ticketId + ); + if (ticketIndex !== -1) { + let aux = [...prevState]; + aux[ticketIndex].unreadMessages = 0; + return aux; + } else { + return prevState; + } }); }; @@ -338,8 +338,7 @@ const TicketsList = () => { }; const countTickets = status => { - const ticketsFound = tickets.filter(ticket => ticket.status === status) - .length; + const ticketsFound = tickets.filter(t => t.status === status).length; if (ticketsFound === 0) return ""; return ticketsFound; @@ -434,8 +433,8 @@ const TicketsList = () => { }; return ( -
- + + { /> - +
{ {tab === "open" ? ( <> - +
Meus tickets @@ -485,7 +484,7 @@ const TicketsList = () => { {renderTickets("open")} - +
Aguardando @@ -498,7 +497,7 @@ const TicketsList = () => { ) : ( - + {renderTickets("closed")} )} @@ -508,7 +507,7 @@ const TicketsList = () => { -
+
); }; diff --git a/frontend/src/pages/WhatsAuth/WhatsAuth.js b/frontend/src/pages/WhatsAuth/WhatsAuth.js index 0ce3245..c2c6968 100644 --- a/frontend/src/pages/WhatsAuth/WhatsAuth.js +++ b/frontend/src/pages/WhatsAuth/WhatsAuth.js @@ -14,27 +14,19 @@ import Qrcode from "./components/Qrcode"; const useStyles = makeStyles(theme => ({ root: { display: "flex", + padding: theme.spacing(4), }, - title: { - flexGrow: 1, - }, - - appBarSpacer: theme.mixins.toolbar, content: { flexGrow: 1, overflow: "auto", }, - container: { - // paddingTop: theme.spacing(4), - // paddingBottom: theme.spacing(4), - height: `calc(100% - 64px)`, - }, paper: { padding: theme.spacing(2), display: "flex", overflow: "auto", + alignItems: "center", flexDirection: "column", }, fixedHeight: { @@ -52,7 +44,7 @@ const WhatsAuth = () => { useEffect(() => { const fetchSession = async () => { try { - const res = await api.get("/whatsapp/session"); + const res = await api.get("/whatsapp/session/1"); setQrCode(res.data.qrcode); setSession(res.data); } catch (err) { @@ -73,9 +65,9 @@ const WhatsAuth = () => { socket.on("whats_auth", data => { if (data.action === "authentication") { - history.push("/chat"); setQrCode(""); setSession(data.session); + history.push("/chat"); } }); @@ -87,35 +79,22 @@ const WhatsAuth = () => { console.log(session); return ( -
-
-
-
- - - {session.status === "pending" ? ( - - - - - - ) : ( - - - - - - )} - - {/* - -

paper2

-
-
*/} -
-
-
-
+
+ + {session.status === "pending" ? ( + + + + + + ) : ( + + + + + + )} +
); }; diff --git a/frontend/src/pages/WhatsAuth/components/Qrcode.js b/frontend/src/pages/WhatsAuth/components/Qrcode.js index 7b4f3ff..181e9c7 100644 --- a/frontend/src/pages/WhatsAuth/components/Qrcode.js +++ b/frontend/src/pages/WhatsAuth/components/Qrcode.js @@ -5,7 +5,7 @@ import Typography from "@material-ui/core/Typography"; const Qrcode = ({ qrCode }) => { return (
- + Leia o QrCode para iniciar a sessão