-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add tenant invitation notification (#497)
- Loading branch information
Showing
8 changed files
with
88 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from rest_framework import serializers | ||
|
||
|
||
class TenantInvitationEmailSerializer(serializers.Serializer): | ||
token = serializers.CharField() | ||
tenant_membership_id = serializers.CharField() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import logging | ||
|
||
from common import emails | ||
from . import email_serializers | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class TenantInvitationEmail(emails.Email): | ||
name = 'TENANT_INVITATION' | ||
serializer_class = email_serializers.TenantInvitationEmailSerializer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/webapp-libs/webapp-emails/src/templates/tenantInvitation/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './tenantInvitation.component'; |
36 changes: 36 additions & 0 deletions
36
...s/webapp-libs/webapp-emails/src/templates/tenantInvitation/tenantInvitation.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { useGenerateAbsoluteLocalePath } from '@sb/webapp-core/hooks'; | ||
import { RoutesConfig } from '@sb/webapp-core/config/routes'; | ||
import { FormattedMessage } from 'react-intl'; | ||
|
||
import { EmailComponentProps } from '../../types'; | ||
import { Button, Layout } from '../../base'; | ||
|
||
|
||
export type TenantInvitationProps = EmailComponentProps & { | ||
token: string | ||
tenantMembershipId: string | ||
}; | ||
|
||
export const Template = ({token, tenantMembershipId}: TenantInvitationProps) => { | ||
const generateLocalePath = useGenerateAbsoluteLocalePath(); | ||
const url = generateLocalePath(RoutesConfig.home); | ||
|
||
return ( | ||
<Layout | ||
title={<FormattedMessage defaultMessage="You have a new tenant invitation" id="Email / TenantInvitation / Title" />} | ||
text={ | ||
<FormattedMessage | ||
defaultMessage="Click button below to accept or decline new invitation.<br />Token: {token}<br />MembershipId: {tenantMembershipId}" | ||
id="Email / TenantInvitation / Text" | ||
values={{ token: token, tenantMembershipId: tenantMembershipId }} | ||
/> | ||
} | ||
> | ||
<Button linkTo={url}> | ||
<FormattedMessage defaultMessage="Button" id="Email / TenantInvitation / Link label" /> | ||
</Button> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export const Subject = () => <FormattedMessage defaultMessage="You have a new tenant invitation" id="Email / TenantInvitation / Subject" /> |
23 changes: 23 additions & 0 deletions
23
...ges/webapp-libs/webapp-emails/src/templates/tenantInvitation/tenantInvitation.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { StoryFn } from '@storybook/react'; | ||
|
||
import { EmailTemplateType } from '../../types'; | ||
import { EmailStory } from '../../emailStory/emailStory.component'; | ||
import { | ||
Template as TenantInvitationEmail, | ||
Subject as TenantInvitationSubject, | ||
TenantInvitationProps, | ||
} from './tenantInvitation.component'; | ||
|
||
const Template: StoryFn<TenantInvitationProps> = (args) => ( | ||
<EmailStory type={EmailTemplateType.TENANT_INVITATION} subject={<TenantInvitationSubject />} emailData={args}> | ||
<TenantInvitationEmail {...args} /> | ||
</EmailStory> | ||
); | ||
|
||
export default { | ||
title: 'Emails/TenantInvitation', | ||
component: TenantInvitationEmail, | ||
}; | ||
|
||
export const Primary = Template.bind({}); | ||
Primary.args = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters