mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Welcome email + Phone Actions tested working
This commit is contained in:
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 }) => {
|
export const EmailMessage = ({ message, subject }: { message: IEmailMessage; subject: string }) => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { replyEmail } = useEmail();
|
const { replyEmail, head } = useEmail();
|
||||||
|
|
||||||
const [{ phoneActions, externalActions }, setActions] = useState<
|
const [{ phoneActions, externalActions }, setActions] = useState<
|
||||||
Pick<IEmailMessage, 'phoneActions' | 'externalActions'>
|
Pick<IEmailMessage, 'phoneActions' | 'externalActions'>
|
||||||
@@ -40,6 +40,8 @@ export const EmailMessage = ({ message, subject }: { message: IEmailMessage; sub
|
|||||||
}
|
}
|
||||||
}, [fetchEmailActions, message.hasActions, message.id]);
|
}, [fetchEmailActions, message.hasActions, message.id]);
|
||||||
|
|
||||||
|
const receivers = message.receivers.join(', ');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box px={2}>
|
<Box px={2}>
|
||||||
<Card>
|
<Card>
|
||||||
@@ -47,7 +49,7 @@ export const EmailMessage = ({ message, subject }: { message: IEmailMessage; sub
|
|||||||
{t('GENERIC_FROM')}: <i>{message.sender}</i>
|
{t('GENERIC_FROM')}: <i>{message.sender}</i>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
{t('GENERIC_TO')}: <i>{message.receivers.join(', ')}</i>
|
{t('GENERIC_TO')}: <i>{receivers}</i>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|
||||||
<CardContent>
|
<CardContent>
|
||||||
@@ -57,34 +59,38 @@ export const EmailMessage = ({ message, subject }: { message: IEmailMessage; sub
|
|||||||
<Box mt={2}>
|
<Box mt={2}>
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent>{message.body.split('\n').map((p) => mapParagraphs(p, t))}</CardContent>
|
<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>
|
</Card>
|
||||||
{message.hasActions && phoneActions && (
|
{!message.sender.includes('no-reply') && (
|
||||||
<CardActions>
|
<CardActions>
|
||||||
<Box textAlign="right" width="100%">
|
<Box textAlign="right" width="100%">
|
||||||
{phoneActions.map((action) => (
|
<Button
|
||||||
<Button onClick={() => history.push(action.href)}>{action.label}</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>
|
</Box>
|
||||||
</CardActions>
|
</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>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import dayjs from 'dayjs';
|
|
||||||
import qs from 'qs';
|
import qs from 'qs';
|
||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@@ -49,13 +48,12 @@ export const useEmail = () => {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const replyEmail = (message: IEmailMessage & { subject: string }) => {
|
const replyEmail = (message: IEmailMessage & { subject: string }) => {
|
||||||
const sendDate = dayjs.unix(message.sendDate).format(t('DATE_FORMAT'));
|
|
||||||
const receivers = message.receivers.join(',');
|
const receivers = message.receivers.join(',');
|
||||||
const query = qs.stringify(
|
const query = qs.stringify(
|
||||||
{
|
{
|
||||||
...message,
|
...message,
|
||||||
receivers,
|
receivers,
|
||||||
body: ` \n\n ----- On ${sendDate} ${message.sender} wrote: ----- \n\n ${message.body}`,
|
body: '',
|
||||||
},
|
},
|
||||||
{ addQueryPrefix: true },
|
{ addQueryPrefix: true },
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -32,8 +32,7 @@
|
|||||||
"allowEdtiableProfileName": true
|
"allowEdtiableProfileName": true
|
||||||
},
|
},
|
||||||
"email": {
|
"email": {
|
||||||
"provider": "project-error.dev",
|
"provider": "project-error.dev"
|
||||||
"welcomeEmail": "You have got a new phone number registered to you"
|
|
||||||
},
|
},
|
||||||
"bank": {
|
"bank": {
|
||||||
"showNotifications": true
|
"showNotifications": true
|
||||||
|
|||||||
@@ -203,7 +203,7 @@
|
|||||||
"APPS_MARKETPLACE_FORM_IMAGE": "Image or URL",
|
"APPS_MARKETPLACE_FORM_IMAGE": "Image or URL",
|
||||||
"APPS_MARKETPLACE_FORM_DESCRIPTION": "Description",
|
"APPS_MARKETPLACE_FORM_DESCRIPTION": "Description",
|
||||||
|
|
||||||
"APPS_EMAIL_WELCOME": "Thanks for using New Phone Who Dis, your email is listed above and your registered phone number is: ",
|
"APPS_EMAIL_WELCOME": "Thanks for using New Phone Who Dis, your email is listed above and your phone number is in the Settings app",
|
||||||
"APPS_EMAIL_INBOX": "Inbox",
|
"APPS_EMAIL_INBOX": "Inbox",
|
||||||
"APPS_EMAIL_SENT": "Sent",
|
"APPS_EMAIL_SENT": "Sent",
|
||||||
"APPS_EMAIL_SUBJECT": "Subject",
|
"APPS_EMAIL_SUBJECT": "Subject",
|
||||||
|
|||||||
@@ -64,11 +64,6 @@ export async function fetchMessageActions(
|
|||||||
const [phoneActions] = await pool.query(queryPhoneActions, [id]);
|
const [phoneActions] = await pool.query(queryPhoneActions, [id]);
|
||||||
const [externalActions] = await pool.query(queryExternalActions, [id]);
|
const [externalActions] = await pool.query(queryExternalActions, [id]);
|
||||||
|
|
||||||
console.log({
|
|
||||||
phoneActions: phoneActions as UnformattedEmailPhoneAction[],
|
|
||||||
externalActions: externalActions as UnformattedEmailExternalAction[],
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
phoneActions: phoneActions as UnformattedEmailPhoneAction[],
|
phoneActions: phoneActions as UnformattedEmailPhoneAction[],
|
||||||
externalActions: externalActions as UnformattedEmailExternalAction[],
|
externalActions: externalActions as UnformattedEmailExternalAction[],
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export function mapUnformattedEmailMessages(
|
|||||||
}
|
}
|
||||||
email.messagesMap.set(message.message_id, {
|
email.messagesMap.set(message.message_id, {
|
||||||
...currentMessage,
|
...currentMessage,
|
||||||
receivers: [...currentMessage.receivers, message.receiver_identifier],
|
receivers: [...currentMessage.receivers, message.receiver],
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
email.messagesMap.set(message.message_id, formatMessage(message, myEmail));
|
email.messagesMap.set(message.message_id, formatMessage(message, myEmail));
|
||||||
|
|||||||
Reference in new issue
Block a user