mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 06:28:51 +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 }) => {
|
||||
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,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 },
|
||||
);
|
||||
|
||||
@@ -32,8 +32,7 @@
|
||||
"allowEdtiableProfileName": true
|
||||
},
|
||||
"email": {
|
||||
"provider": "project-error.dev",
|
||||
"welcomeEmail": "You have got a new phone number registered to you"
|
||||
"provider": "project-error.dev"
|
||||
},
|
||||
"bank": {
|
||||
"showNotifications": true
|
||||
|
||||
@@ -203,7 +203,7 @@
|
||||
"APPS_MARKETPLACE_FORM_IMAGE": "Image or URL",
|
||||
"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_SENT": "Sent",
|
||||
"APPS_EMAIL_SUBJECT": "Subject",
|
||||
|
||||
@@ -64,11 +64,6 @@ export async function fetchMessageActions(
|
||||
const [phoneActions] = await pool.query(queryPhoneActions, [id]);
|
||||
const [externalActions] = await pool.query(queryExternalActions, [id]);
|
||||
|
||||
console.log({
|
||||
phoneActions: phoneActions as UnformattedEmailPhoneAction[],
|
||||
externalActions: externalActions as UnformattedEmailExternalAction[],
|
||||
});
|
||||
|
||||
return {
|
||||
phoneActions: phoneActions as UnformattedEmailPhoneAction[],
|
||||
externalActions: externalActions as UnformattedEmailExternalAction[],
|
||||
|
||||
@@ -38,7 +38,7 @@ export function mapUnformattedEmailMessages(
|
||||
}
|
||||
email.messagesMap.set(message.message_id, {
|
||||
...currentMessage,
|
||||
receivers: [...currentMessage.receivers, message.receiver_identifier],
|
||||
receivers: [...currentMessage.receivers, message.receiver],
|
||||
});
|
||||
} else {
|
||||
email.messagesMap.set(message.message_id, formatMessage(message, myEmail));
|
||||
|
||||
Reference in new issue
Block a user