Styles change in chat

This commit is contained in:
canove
2020-07-20 17:00:52 -03:00
parent 940285f63e
commit 2a73d7e89d
9 changed files with 113 additions and 156 deletions

View File

@@ -9,6 +9,14 @@ class Message extends Sequelize.Model {
body: { type: Sequelize.TEXT }, body: { type: Sequelize.TEXT },
mediaUrl: { type: Sequelize.STRING }, mediaUrl: { type: Sequelize.STRING },
mediaType: { type: Sequelize.STRING }, mediaType: { type: Sequelize.STRING },
createdAt: {
type: Sequelize.DATE(6),
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE(6),
allowNull: false,
},
}, },
{ {
sequelize, sequelize,

View File

@@ -39,7 +39,7 @@ const useStyles = makeStyles(theme => ({
alignItems: "center", alignItems: "center",
justifyContent: "flex-end", justifyContent: "flex-end",
padding: "0 8px", padding: "0 8px",
...theme.mixins.toolbar, minHeight: "48px",
}, },
appBar: { appBar: {
zIndex: theme.zIndex.drawer + 1, zIndex: theme.zIndex.drawer + 1,
@@ -85,10 +85,11 @@ const useStyles = makeStyles(theme => ({
width: theme.spacing(9), width: theme.spacing(9),
}, },
}, },
appBarSpacer: theme.mixins.toolbar, appBarSpacer: {
minHeight: "48px",
},
content: { content: {
flex: 1, flex: 1,
// height: "100%",
overflow: "auto", overflow: "auto",
}, },
container: { container: {
@@ -158,7 +159,7 @@ const MainDrawer = ({ appTitle, children }) => {
position="absolute" position="absolute"
className={clsx(classes.appBar, open && classes.appBarShift)} className={clsx(classes.appBar, open && classes.appBarShift)}
> >
<Toolbar className={classes.toolbar}> <Toolbar variant="dense" className={classes.toolbar}>
<IconButton <IconButton
edge="start" edge="start"
color="inherit" color="inherit"

View File

@@ -12,28 +12,26 @@ const useStyles = makeStyles(theme => ({
flex: 1, flex: 1,
// backgroundColor: "#eee", // backgroundColor: "#eee",
padding: theme.spacing(4), padding: theme.spacing(4),
height: `calc(100% - 64px)`, height: `calc(100% - 48px)`,
overflowY: "hidden", overflowY: "hidden",
}, },
chatPapper: { chatPapper: {
backgroundColor: "#eee", // backgroundColor: "#eee",
display: "flex", display: "flex",
height: "100%", height: "100%",
overflowY: "hidden",
}, },
contactsWrapper: { contactsWrapper: {
display: "flex", display: "flex",
height: "100%", height: "100%",
flexDirection: "column", flexDirection: "column",
overflow: "hidden", overflowY: "hidden",
}, },
messagessWrapper: { messagessWrapper: {
display: "flex", display: "flex",
height: "100%", height: "100%",
flexDirection: "column", flexDirection: "column",
overflow: "hidden",
}, },
welcomeMsg: { welcomeMsg: {
backgroundColor: "#eee", backgroundColor: "#eee",
@@ -51,7 +49,7 @@ const Chat = () => {
return ( return (
<div className={classes.chatContainer}> <div className={classes.chatContainer}>
<Paper square className={classes.chatPapper}> <Paper square elevation={0} 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}>
<TicketsList /> <TicketsList />

View File

@@ -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 (
<Card variant="outlined" square className={classes.contactsHeader}>
<CardHeader
avatar={<Avatar alt="logged_user" src={profileDefaultPic} />}
title={username}
/>
<IconButton className={classes.settingsIcon} aria-label="settings">
<MoreVertIcon />
</IconButton>
</Card>
);
};
export default ContactsHeader;

View File

@@ -27,15 +27,16 @@ const useStyles = makeStyles(theme => ({
newMessageBox: { newMessageBox: {
background: "#eee", background: "#eee",
display: "flex", display: "flex",
padding: "10px", padding: "7px",
alignItems: "center", alignItems: "center",
borderTop: "1px solid rgba(0, 0, 0, 0.12)",
}, },
messageInputWrapper: { messageInputWrapper: {
padding: 6, padding: 6,
background: "#fff", background: "#fff",
display: "flex", display: "flex",
borderRadius: 40, borderRadius: 20,
flex: 1, flex: 1,
}, },
@@ -60,6 +61,7 @@ const useStyles = makeStyles(theme => ({
justifyContent: "space-between", justifyContent: "space-between",
alignItems: "center", alignItems: "center",
backgroundColor: "#eee", backgroundColor: "#eee",
borderTop: "1px solid rgba(0, 0, 0, 0.12)",
}, },
emojiBox: { emojiBox: {
@@ -240,11 +242,7 @@ const MessagesInput = ({ searchParam }) => {
if (media.preview) if (media.preview)
return ( return (
<Paper <Paper elevation={0} square className={classes.viewMediaInputWrapper}>
variant="outlined"
square
className={classes.viewMediaInputWrapper}
>
<IconButton <IconButton
aria-label="cancel-upload" aria-label="cancel-upload"
component="span" component="span"
@@ -274,7 +272,7 @@ const MessagesInput = ({ searchParam }) => {
); );
else { else {
return ( return (
<Paper variant="outlined" square className={classes.newMessageBox}> <Paper square elevation={0} className={classes.newMessageBox}>
<IconButton <IconButton
aria-label="emojiPicker" aria-label="emojiPicker"
component="span" component="span"
@@ -310,6 +308,8 @@ const MessagesInput = ({ searchParam }) => {
inputRef={input => input && !searchParam && input.focus()} inputRef={input => input && !searchParam && input.focus()}
className={classes.messageInput} className={classes.messageInput}
placeholder="Escreva uma mensagem" placeholder="Escreva uma mensagem"
multiline
rowsMax={5}
value={inputMessage} value={inputMessage}
onChange={handleChangeInput} onChange={handleChangeInput}
disabled={recording} disabled={recording}

View File

@@ -16,6 +16,7 @@ import CardHeader from "@material-ui/core/CardHeader";
import ReplayIcon from "@material-ui/icons/Replay"; import ReplayIcon from "@material-ui/icons/Replay";
import Avatar from "@material-ui/core/Avatar"; import Avatar from "@material-ui/core/Avatar";
import Button from "@material-ui/core/Button"; import Button from "@material-ui/core/Button";
import Paper from "@material-ui/core/Paper";
import { green } from "@material-ui/core/colors"; import { green } from "@material-ui/core/colors";
import whatsBackground from "../../../../Images/wa-background.png"; import whatsBackground from "../../../../Images/wa-background.png";
@@ -30,12 +31,16 @@ const useStyles = makeStyles(theme => ({
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
overflow: "hidden", overflow: "hidden",
borderTopLeftRadius: 0,
borderBottomLeftRadius: 0,
borderLeft: "0",
}, },
messagesHeader: { messagesHeader: {
display: "flex", display: "flex",
backgroundColor: "#eee", backgroundColor: "#eee",
flex: "none", flex: "none",
borderBottom: "1px solid rgba(0, 0, 0, 0.12)",
}, },
actionButtons: { actionButtons: {
@@ -83,7 +88,8 @@ const useStyles = makeStyles(theme => ({
}, },
messageLeft: { messageLeft: {
marginTop: 5, marginRight: 20,
marginTop: 2,
minWidth: 100, minWidth: 100,
maxWidth: 600, maxWidth: 600,
height: "auto", height: "auto",
@@ -92,20 +98,20 @@ const useStyles = makeStyles(theme => ({
backgroundColor: "#ffffff", backgroundColor: "#ffffff",
alignSelf: "flex-start", alignSelf: "flex-start",
borderTopLeftRadius: 8, borderTopLeftRadius: 0,
borderTopRightRadius: 8, borderTopRightRadius: 8,
borderBottomLeftRadius: 0, borderBottomLeftRadius: 8,
borderBottomRightRadius: 8, borderBottomRightRadius: 8,
paddingLeft: 5, paddingLeft: 5,
paddingRight: 5, paddingRight: 5,
paddingTop: 5, paddingTop: 5,
paddingBottom: 0, paddingBottom: 0,
boxShadow: "0 2px 2px #808888", boxShadow: "0 1px 1px #b3b3b3",
}, },
messageRight: { messageRight: {
marginLeft: 20, marginLeft: 20,
marginTop: 5, marginTop: 2,
minWidth: 100, minWidth: 100,
maxWidth: 600, maxWidth: 600,
height: "auto", height: "auto",
@@ -122,7 +128,7 @@ const useStyles = makeStyles(theme => ({
paddingRight: 5, paddingRight: 5,
paddingTop: 5, paddingTop: 5,
paddingBottom: 0, paddingBottom: 0,
boxShadow: "0 2px 2px #808888", boxShadow: "0 1px 1px #b3b3b3",
}, },
textContentItem: { textContentItem: {
@@ -156,6 +162,7 @@ const useStyles = makeStyles(theme => ({
backgroundColor: "#e1f3fb", backgroundColor: "#e1f3fb",
margin: "10px", margin: "10px",
borderRadius: "10px", borderRadius: "10px",
boxShadow: "0 1px 1px #b3b3b3",
}, },
dailyTimestampText: { dailyTimestampText: {
@@ -432,8 +439,8 @@ const MessagesList = () => {
}; };
return ( return (
<div className={classes.mainWrapper}> <Paper variant="outlined" elevation={0} className={classes.mainWrapper}>
<Card variant="outlined" square className={classes.messagesHeader}> <Card square className={classes.messagesHeader}>
{contact.name ? ( {contact.name ? (
<CardHeader <CardHeader
titleTypographyProps={{ noWrap: true }} titleTypographyProps={{ noWrap: true }}
@@ -453,21 +460,33 @@ const MessagesList = () => {
)} )}
<div className={classes.actionButtons}> <div className={classes.actionButtons}>
<Button {ticket.status === "closed" ? (
startIcon={<ReplayIcon />} <Button
size="small" startIcon={<ReplayIcon />}
onClick={e => handleUpdateTicketStatus("pending")} size="small"
> onClick={e => handleUpdateTicketStatus("open", userId)}
Retornar >
</Button> Reabrir
<Button </Button>
size="small" ) : (
variant="contained" <>
color="primary" <Button
onClick={e => handleUpdateTicketStatus("closed", userId)} startIcon={<ReplayIcon />}
> size="small"
Resolver onClick={e => handleUpdateTicketStatus("pending", null)}
</Button> >
Retornar
</Button>
<Button
size="small"
variant="contained"
color="primary"
onClick={e => handleUpdateTicketStatus("closed", userId)}
>
Resolver
</Button>
</>
)}
</div> </div>
</Card> </Card>
<div className={classes.messagesListWrapper}> <div className={classes.messagesListWrapper}>
@@ -487,7 +506,7 @@ const MessagesList = () => {
</div> </div>
) : null} ) : null}
</div> </div>
</div> </Paper>
); );
}; };

View File

@@ -37,14 +37,13 @@ const useStyles = makeStyles(theme => ({
height: "100%", height: "100%",
flexDirection: "column", flexDirection: "column",
overflow: "hidden", overflow: "hidden",
borderTopRightRadius: 0,
borderBottomRightRadius: 0,
}, },
contactsHeader: { contactsHeader: {
display: "flex", display: "flex",
backgroundColor: "#eee", backgroundColor: "#eee",
borderBottomLeftRadius: 0,
borderBottomRightRadius: 0,
borderTopRightRadius: 0,
}, },
settingsIcon: { settingsIcon: {
@@ -55,9 +54,6 @@ const useStyles = makeStyles(theme => ({
openTicketsList: { openTicketsList: {
position: "relative", position: "relative",
borderTopLeftRadius: 0,
borderTopRightRadius: 0,
borderBottomRightRadius: 0,
height: "50%", height: "50%",
overflowY: "scroll", overflowY: "scroll",
"&::-webkit-scrollbar": { "&::-webkit-scrollbar": {
@@ -67,13 +63,11 @@ const useStyles = makeStyles(theme => ({
boxShadow: "inset 0 0 6px rgba(0, 0, 0, 0.3)", boxShadow: "inset 0 0 6px rgba(0, 0, 0, 0.3)",
backgroundColor: "#e8e8e8", backgroundColor: "#e8e8e8",
}, },
borderTop: "2px solid rgba(0, 0, 0, 0.12)",
}, },
closedTicketsList: { closedTicketsList: {
position: "relative", position: "relative",
borderTopLeftRadius: 0,
borderTopRightRadius: 0,
borderBottomRightRadius: 0,
flex: 1, flex: 1,
overflowY: "scroll", overflowY: "scroll",
"&::-webkit-scrollbar": { "&::-webkit-scrollbar": {
@@ -83,6 +77,7 @@ const useStyles = makeStyles(theme => ({
boxShadow: "inset 0 0 6px rgba(0, 0, 0, 0.3)", boxShadow: "inset 0 0 6px rgba(0, 0, 0, 0.3)",
backgroundColor: "#e8e8e8", backgroundColor: "#e8e8e8",
}, },
borderTop: "2px solid rgba(0, 0, 0, 0.12)",
}, },
ticketsListHeader: { ticketsListHeader: {
@@ -90,12 +85,12 @@ const useStyles = makeStyles(theme => ({
// flexShrink: 0, // flexShrink: 0,
// -webkitBoxAlign: "center", // -webkitBoxAlign: "center",
alignItems: "center", alignItems: "center",
fontWeight: 600, fontWeight: 500,
fontSize: "16px", fontSize: "16px",
height: "56px", height: "56px",
// backgroundColor: "#eee", // backgroundColor: "#eee",
color: "rgb(67, 83, 105)", color: "rgb(67, 83, 105)",
padding: "0px 24px", padding: "0px 12px",
borderBottom: "1px solid rgba(0, 0, 0, 0.12)", borderBottom: "1px solid rgba(0, 0, 0, 0.12)",
}, },
@@ -305,11 +300,16 @@ const TicketsList = () => {
const resetUnreadMessages = ticketId => { const resetUnreadMessages = ticketId => {
setTickets(prevState => { setTickets(prevState => {
let aux = [...prevState]; const ticketIndex = prevState.findIndex(
let ticketIndex = aux.findIndex(ticket => ticket.id === +ticketId); ticket => ticket.id === +ticketId
aux[ticketIndex].unreadMessages = 0; );
if (ticketIndex !== -1) {
return aux; let aux = [...prevState];
aux[ticketIndex].unreadMessages = 0;
return aux;
} else {
return prevState;
}
}); });
}; };
@@ -338,8 +338,7 @@ const TicketsList = () => {
}; };
const countTickets = status => { const countTickets = status => {
const ticketsFound = tickets.filter(ticket => ticket.status === status) const ticketsFound = tickets.filter(t => t.status === status).length;
.length;
if (ticketsFound === 0) return ""; if (ticketsFound === 0) return "";
return ticketsFound; return ticketsFound;
@@ -434,8 +433,8 @@ const TicketsList = () => {
}; };
return ( return (
<div className={classes.contactsWrapper}> <Paper elevation={0} variant="outlined" className={classes.contactsWrapper}>
<Paper square variant="outlined" className={classes.root}> <Paper elevation={0}>
<Tabs <Tabs
value={tab} value={tab}
onChange={handleChangeTab} onChange={handleChangeTab}
@@ -456,7 +455,7 @@ const TicketsList = () => {
/> />
</Tabs> </Tabs>
</Paper> </Paper>
<Paper variant="outlined" square className={classes.contactsSearchBox}> <Paper square elevation={0} className={classes.contactsSearchBox}>
<div className={classes.serachInputWrapper}> <div className={classes.serachInputWrapper}>
<SearchIcon className={classes.searchIcon} /> <SearchIcon className={classes.searchIcon} />
<InputBase <InputBase
@@ -474,7 +473,7 @@ const TicketsList = () => {
</Paper> </Paper>
{tab === "open" ? ( {tab === "open" ? (
<> <>
<Paper variant="outlined" className={classes.openTicketsList}> <Paper square elevation={0} className={classes.openTicketsList}>
<List style={{ paddingTop: 0 }}> <List style={{ paddingTop: 0 }}>
<div className={classes.ticketsListHeader}> <div className={classes.ticketsListHeader}>
Meus tickets Meus tickets
@@ -485,7 +484,7 @@ const TicketsList = () => {
{renderTickets("open")} {renderTickets("open")}
</List> </List>
</Paper> </Paper>
<Paper variant="outlined" className={classes.openTicketsList}> <Paper square elevation={0} className={classes.openTicketsList}>
<List style={{ paddingTop: 0 }}> <List style={{ paddingTop: 0 }}>
<div className={classes.ticketsListHeader}> <div className={classes.ticketsListHeader}>
Aguardando Aguardando
@@ -498,7 +497,7 @@ const TicketsList = () => {
</Paper> </Paper>
</> </>
) : ( ) : (
<Paper variant="outlined" className={classes.closedTicketsList}> <Paper square elevation={0} className={classes.closedTicketsList}>
<List>{renderTickets("closed")}</List> <List>{renderTickets("closed")}</List>
</Paper> </Paper>
)} )}
@@ -508,7 +507,7 @@ const TicketsList = () => {
<source src={require("../../../../util/sound.ogg")} type="audio/ogg" /> <source src={require("../../../../util/sound.ogg")} type="audio/ogg" />
<embed hidden={true} autostart="false" loop={false} src="./sound.mp3" /> <embed hidden={true} autostart="false" loop={false} src="./sound.mp3" />
</audio> </audio>
</div> </Paper>
); );
}; };

View File

@@ -14,27 +14,19 @@ import Qrcode from "./components/Qrcode";
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles(theme => ({
root: { root: {
display: "flex", display: "flex",
padding: theme.spacing(4),
}, },
title: {
flexGrow: 1,
},
appBarSpacer: theme.mixins.toolbar,
content: { content: {
flexGrow: 1, flexGrow: 1,
overflow: "auto", overflow: "auto",
}, },
container: {
// paddingTop: theme.spacing(4),
// paddingBottom: theme.spacing(4),
height: `calc(100% - 64px)`,
},
paper: { paper: {
padding: theme.spacing(2), padding: theme.spacing(2),
display: "flex", display: "flex",
overflow: "auto", overflow: "auto",
alignItems: "center",
flexDirection: "column", flexDirection: "column",
}, },
fixedHeight: { fixedHeight: {
@@ -52,7 +44,7 @@ const WhatsAuth = () => {
useEffect(() => { useEffect(() => {
const fetchSession = async () => { const fetchSession = async () => {
try { try {
const res = await api.get("/whatsapp/session"); const res = await api.get("/whatsapp/session/1");
setQrCode(res.data.qrcode); setQrCode(res.data.qrcode);
setSession(res.data); setSession(res.data);
} catch (err) { } catch (err) {
@@ -73,9 +65,9 @@ const WhatsAuth = () => {
socket.on("whats_auth", data => { socket.on("whats_auth", data => {
if (data.action === "authentication") { if (data.action === "authentication") {
history.push("/chat");
setQrCode(""); setQrCode("");
setSession(data.session); setSession(data.session);
history.push("/chat");
} }
}); });
@@ -87,35 +79,22 @@ const WhatsAuth = () => {
console.log(session); console.log(session);
return ( return (
<div> <div className={classes.root}>
<div className={classes.root}> <Grid container spacing={3}>
<main className={classes.content}> {session.status === "pending" ? (
<div className={classes.appBarSpacer} /> <Grid item xs={12}>
<Container maxWidth="lg" className={classes.container}> <Paper className={classes.paper}>
<Grid container spacing={3}> <Qrcode qrCode={qrCode} />
{session.status === "pending" ? ( </Paper>
<Grid item xs={6}> </Grid>
<Paper className={classes.paper}> ) : (
<Qrcode qrCode={qrCode} /> <Grid item xs={6}>
</Paper> <Paper className={classes.paper}>
</Grid> <Bateryinfo sessio={session} />
) : ( </Paper>
<Grid item xs={6}> </Grid>
<Paper className={classes.paper}> )}
<Bateryinfo sessio={session} /> </Grid>
</Paper>
</Grid>
)}
{/* <Grid item xs={12} md={4} lg={3}>
<Paper className={fixedHeightPaper}>
<h1>paper2</h1>
</Paper>
</Grid> */}
</Grid>
</Container>
</main>
</div>
</div> </div>
); );
}; };

View File

@@ -5,7 +5,7 @@ import Typography from "@material-ui/core/Typography";
const Qrcode = ({ qrCode }) => { const Qrcode = ({ qrCode }) => {
return ( return (
<div> <div>
<Typography component="h2" variant="h6" color="primary" gutterBottom> <Typography color="primary" gutterBottom>
Leia o QrCode para iniciar a sessão Leia o QrCode para iniciar a sessão
</Typography> </Typography>
<QRCode value={qrCode} size={256} /> <QRCode value={qrCode} size={256} />