Welcome email + Phone Actions tested working

This commit is contained in:
J Francisco Rader committed 2021-03-30 02:48:22 -03:00
1 parent 392dfda8b4
commit e08bdf4c12
6 files changed
+34 -36

No files matched your search

@@ -23,7 +23,7 @@ const mapParagraphs = (paragraph: string, t: TFunction) => {
export const EmailMessage = ({ message, subject }: { message: IEmailMessage; subject: string }) => {
const history = useHistory();
const { t } = useTranslation();
const { replyEmail } = useEmail();
const { replyEmail, head } = useEmail();
const [{ phoneActions, externalActions }, setActions] = useState<
Pick<IEmailMessage, 'phoneActions' | 'externalActions'>
@@ -40,6 +40,8 @@ export const EmailMessage = ({ message, subject }: { message: IEmailMessage; sub
}
}, [fetchEmailActions, message.hasActions, message.id]);
const receivers = message.receivers.join(', ');
return (
<Box px={2}>
<Card>
@@ -47,7 +49,7 @@ export const EmailMessage = ({ message, subject }: { message: IEmailMessage; sub
{t('GENERIC_FROM')}: <i>{message.sender}</i>
</CardContent>
<CardContent>
{t('GENERIC_TO')}: <i>{message.receivers.join(', ')}</i>
{t('GENERIC_TO')}: <i>{receivers}</i>
</CardContent>
<CardContent>
@@ -57,34 +59,38 @@ export const EmailMessage = ({ message, subject }: { message: IEmailMessage; sub
<Box mt={2}>
<Card>
<CardContent>{message.body.split('\n').map((p) => mapParagraphs(p, t))}</CardContent>
{message.hasActions && phoneActions && (
<CardActions>
<Box textAlign="right" width="100%">
{phoneActions.map((action) => (
<Button color="primary" onClick={() => history.push(action.href)}>
{action.label}
</Button>
))}
</Box>
</CardActions>
)}
</Card>
{message.hasActions && phoneActions && (
{!message.sender.includes('no-reply') && (
<CardActions>
<Box textAlign="right" width="100%">
{phoneActions.map((action) => (
<Button onClick={() => history.push(action.href)}>{action.label}</Button>
))}
<Button
onClick={() => replyEmail({ ...message, subject })}
color="primary"
startIcon={<ReplyAllIcon />}
>
{t('GENERIC_REPLY_ALL')}
</Button>
<Button
onClick={() => replyEmail({ ...message, subject, receivers: [message.sender] })}
color="primary"
startIcon={<ReplyIcon />}
>
{t('GENERIC_REPLY')}
</Button>
</Box>
</CardActions>
)}
<CardActions>
<Box textAlign="right" width="100%">
<Button
onClick={() => replyEmail({ ...message, subject })}
color="primary"
startIcon={<ReplyAllIcon />}
>
{t('GENERIC_REPLY_ALL')}
</Button>
<Button
onClick={() => replyEmail({ ...message, subject, receivers: [message.sender] })}
color="primary"
startIcon={<ReplyIcon />}
>
{t('GENERIC_REPLY')}
</Button>
</Box>
</CardActions>
</Box>
</Box>
);
+1 -3
View File
@@ -1,4 +1,3 @@
import dayjs from 'dayjs';
import qs from 'qs';
import { useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -49,13 +48,12 @@ export const useEmail = () => {
]);
const replyEmail = (message: IEmailMessage & { subject: string }) => {
const sendDate = dayjs.unix(message.sendDate).format(t('DATE_FORMAT'));
const receivers = message.receivers.join(',');
const query = qs.stringify(
{
...message,
receivers,
body: ` \n\n ----- On ${sendDate} ${message.sender} wrote: ----- \n\n ${message.body}`,
body: '',
},
{ addQueryPrefix: true },
);