Melhorado o visual e feedback dos cards de localização

This commit is contained in:
Danilo Alves
2022-01-17 10:27:25 -03:00
parent 54c9a4206d
commit f8d3a75f09
2 changed files with 14 additions and 17 deletions

View File

@@ -3,7 +3,7 @@ import { promisify } from "util";
import { writeFile } from "fs"; import { writeFile } from "fs";
import * as Sentry from "@sentry/node"; import * as Sentry from "@sentry/node";
import { import WAWebJS, {
Contact as WbotContact, Contact as WbotContact,
Message as WbotMessage, Message as WbotMessage,
MessageAck, MessageAck,
@@ -130,21 +130,17 @@ const verifyMessage = async (
quotedMsgId: quotedMsg?.id quotedMsgId: quotedMsg?.id
}; };
await ticket.update({ lastMessage: msg.type === "location" ? msg.description ? "Localization - " + msg.description.split('\\n')[0] : "Localization" : msg.body }); await ticket.update({ lastMessage: msg.type === "location" ? msg.location.description ? "Localization - " + msg.location.description.split('\\n')[0] : "Localization" : msg.body });
await CreateMessageService({ messageData }); await CreateMessageService({ messageData });
}; };
const prepareLocation = (msg: WbotMessage): WbotMessage => { const prepareLocation = (msg: WbotMessage): WbotMessage => {
console.log(msg)
let gmapsUrl = "https://maps.google.com/maps?q=" + msg.location.latitude + "%2C" + msg.location.longitude + "&z=17&hl=pt-BR"; let gmapsUrl = "https://maps.google.com/maps?q=" + msg.location.latitude + "%2C" + msg.location.longitude + "&z=17&hl=pt-BR";
msg.body = "data:image/png;base64," + msg.body + "|" + gmapsUrl; msg.body = "data:image/png;base64," + msg.body + "|" + gmapsUrl;
msg.body += "|" + (msg.description != undefined ? msg.description : (msg.location.latitude + ", " + msg.location.longitude)) msg.body += "|" + (msg.location.description ? msg.location.description : (msg.location.latitude + ", " + msg.location.longitude))
console.log(msg.body)
console.log(msg.description)
return msg; return msg;
}; };

View File

@@ -22,18 +22,19 @@ const LocationPreview = ({ image, link, description }) => {
<div style={{ <div style={{
minWidth: "250px", minWidth: "250px",
}}> }}>
<Grid container spacing={1}> <div>
<Grid item xs={2}> <div style={{ float: "left" }}>
<img src={image} onClick={handleLocation} /> <img src={image} onClick={handleLocation} style={{ width: "100px" }} />
</Grid> </div>
{ description && ( { description && (
<Grid item xs={9}> <div style={{ display: "flex", flexWrap: "wrap" }}>
<Typography style={{ marginTop: "12px", marginLeft: "15px" }} variant="subtitle1" color="primary" gutterBottom> <Typography style={{ marginTop: "12px", marginLeft: "15px", marginRight: "15px", float: "left" }} variant="subtitle1" color="primary" gutterBottom>
<div dangerouslySetInnerHTML={{ __html: description.replace('\\n', '<br />') }}></div> <div dangerouslySetInnerHTML={{ __html: description.replace('\\n', '<br />') }}></div>
</Typography> </Typography>
</Grid> </div>
)} )}
<Grid item xs={12}> <div style={{ display: "block", content: "", clear: "both" }}></div>
<div>
<Divider /> <Divider />
<Button <Button
fullWidth fullWidth
@@ -41,8 +42,8 @@ const LocationPreview = ({ image, link, description }) => {
onClick={handleLocation} onClick={handleLocation}
disabled={!link} disabled={!link}
>Visualizar</Button> >Visualizar</Button>
</Grid> </div>
</Grid> </div>
</div> </div>
</> </>
); );