Skip to content

Commit

Permalink
mail template
Browse files Browse the repository at this point in the history
  • Loading branch information
sinamics committed Dec 3, 2023
1 parent 3a3d00c commit ebd0e4f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/adminPage/mail/mailOrganizationInviteTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ const OrganizationInviteTemplate = () => {
}, [defaultTemplates]);

useEffect(() => {
const notificationTemplate = mailTemplates as IMailTemplate;
setEmailTemplate(notificationTemplate);
const inviteOrganizationTemplate = mailTemplates as IMailTemplate;
setEmailTemplate(inviteOrganizationTemplate);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [mailTemplates]);

Expand Down Expand Up @@ -97,7 +97,7 @@ const OrganizationInviteTemplate = () => {
setMailTemplates(
{
template: JSON.stringify(stateTemplate),
type: "notificationTemplate",
type: "inviteOrganizationTemplate",
},
{
onSuccess: () => {
Expand Down Expand Up @@ -167,7 +167,7 @@ const OrganizationInviteTemplate = () => {
className="btn btn-sm"
onClick={() =>
getDefaultMailTemplate({
template: "notificationTemplate",
template: "inviteOrganizationTemplate",
})
}
>
Expand All @@ -178,7 +178,7 @@ const OrganizationInviteTemplate = () => {
<button
className="btn btn-sm"
disabled={changes.subject || changes.body || sendingMailLoading}
onClick={() => sendTestMail({ type: "notificationTemplate" })}
onClick={() => sendTestMail({ type: "inviteOrganizationTemplate" })}
>
{sendingMailLoading
? t("mail.templates.sendTestMailButtonLoading")
Expand Down
10 changes: 10 additions & 0 deletions src/server/api/routers/adminRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,10 @@ export const adminRouter = createTRPCRouter({
toEmail: ctx.session.user.email,
toName: ctx.session.user.name,
fromName: ctx.session.user.name,
fromAdmin: ctx.session.user.name,
forgotLink: "https://example.com",
notificationMessage: "Test notification message",
fromOrganization: "Test Organization",
nwid: "123456789",
},
{ async: true },
Expand Down Expand Up @@ -517,6 +519,14 @@ export const adminRouter = createTRPCRouter({
await sendTemplateEmail(notifiyTemplate);
break;
}
case "inviteOrganizationTemplate": {
const defaultInviteOrganizationTemplate = inviteOrganizationTemplate();
const notifiyTemplate =
globalOptions?.inviteOrganizationTemplate ??
defaultInviteOrganizationTemplate;
await sendTemplateEmail(notifiyTemplate);
break;
}
default:
break;
}
Expand Down

0 comments on commit ebd0e4f

Please sign in to comment.