Skip to content

Commit 72c7f1f

Browse files
Merge pull request #1325 from digma-ai/feature/email-confirmation-screen
Add email confirmation step
1 parent c732be9 commit 72c7f1f

File tree

22 files changed

+419
-86
lines changed

22 files changed

+419
-86
lines changed
Lines changed: 17 additions & 0 deletions
Loading
Lines changed: 17 additions & 0 deletions
Loading

src/components/EmailConfirmation/index.tsx

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,20 @@ export const EmailConfirmation = () => {
1616
const themeKind = getThemeKind(theme);
1717
const [emailConfirmationResult, setEmailConfirmationResult] =
1818
useState<EmailConfirmationResult>();
19+
const params = getUrlQueryParams(window.location.search);
20+
const userId = params.userId;
21+
const token = params.token;
1922

2023
useEffect(() => {
21-
const params = getUrlQueryParams(window.location.search);
24+
if (!userId || !token) {
25+
return;
26+
}
2227

2328
axios
2429
.get("/api/Authentication/confirm-email", {
2530
params: {
26-
userId: params.userId,
27-
token: params.token
31+
userId,
32+
token
2833
}
2934
})
3035
.then(() => {
@@ -39,7 +44,7 @@ export const EmailConfirmation = () => {
3944
result: "failure"
4045
});
4146
});
42-
}, []);
47+
}, [token, userId]);
4348

4449
useEffect(() => {
4550
if (emailConfirmationResult) {
@@ -49,9 +54,18 @@ export const EmailConfirmation = () => {
4954
}
5055
}, [emailConfirmationResult]);
5156

52-
return (
53-
<GenericPageLayout title={"Digma email confirmation"}>
54-
{emailConfirmationResult?.result === "success" && (
57+
const renderContent = () => {
58+
if (!userId || !token) {
59+
return (
60+
<s.TextContainer>
61+
<Title>Invalid link</Title>
62+
<Subtitle>Link is partial or invalid</Subtitle>
63+
</s.TextContainer>
64+
);
65+
}
66+
67+
if (emailConfirmationResult?.result === "success") {
68+
return (
5569
<s.Container>
5670
<s.Illustration
5771
src={`/assets/images/greenCheckmarkWithFlares_${themeKind}.svg`}
@@ -61,10 +75,17 @@ export const EmailConfirmation = () => {
6175
<Subtitle>You may now log in with your user and password</Subtitle>
6276
</s.TextContainer>
6377
</s.Container>
64-
)}
65-
{emailConfirmationResult?.result === "failure" && (
66-
<Title>Failed to confirm email</Title>
67-
)}
78+
);
79+
}
80+
81+
if (emailConfirmationResult?.result === "failure") {
82+
return <Title>Failed to confirm email</Title>;
83+
}
84+
};
85+
86+
return (
87+
<GenericPageLayout title={"Digma email confirmation"}>
88+
{renderContent()}
6889
</GenericPageLayout>
6990
);
7091
};

src/components/EmailConfirmation/styles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ export const Illustration = styled.img`
1111
top: -60px;
1212
position: absolute;
1313
width: 1100px;
14-
height: 220px;
14+
height: 265px;
1515
`;
1616

1717
export const TextContainer = styled.div`
18-
padding-top: 116px;
18+
padding-top: 160px;
1919
display: flex;
2020
flex-direction: column;
2121
align-items: center;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import { AccountActivation } from ".";
3+
4+
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
5+
const meta: Meta<typeof AccountActivation> = {
6+
title: "Main/Authentication/AccountActivation",
7+
component: AccountActivation,
8+
parameters: {
9+
// More on how to position stories at: https://storybook.js.org/docs/react/configure/story-layout
10+
layout: "fullscreen"
11+
}
12+
};
13+
14+
export default meta;
15+
16+
type Story = StoryObj<typeof meta>;
17+
18+
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
19+
export const Default: Story = {};
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { useTheme } from "styled-components";
2+
import { sendUserActionTrackingEvent } from "../../../../utils/actions/sendUserActionTrackingEvent";
3+
import { getThemeKind } from "../../../common/App/styles";
4+
import * as s from "./styles";
5+
import type { AccountActivationProps } from "./types";
6+
7+
export const AccountActivation = ({
8+
onClose,
9+
emailToConfirm,
10+
onConfirmationEmailResend
11+
}: AccountActivationProps) => {
12+
const theme = useTheme();
13+
const themeKind = getThemeKind(theme);
14+
15+
const handleResendButtonClick = () => {
16+
if (!emailToConfirm) {
17+
return;
18+
}
19+
20+
sendUserActionTrackingEvent("resend button clicked");
21+
onConfirmationEmailResend(emailToConfirm);
22+
};
23+
24+
const handleLinkClick = () => {
25+
sendUserActionTrackingEvent("I activated my account link clicked");
26+
onClose();
27+
};
28+
29+
return (
30+
<s.Container>
31+
<s.Illustration
32+
src={`/assets/images/mailWithCheckmark_${themeKind}.svg`}
33+
/>
34+
<s.TextContainer>
35+
<s.Title>Check your mail</s.Title>
36+
<span>
37+
Click the link in the email to confirm your address. If you
38+
haven&apos;t received the email, click &quot;Resend.&quot;
39+
</span>
40+
</s.TextContainer>
41+
{emailToConfirm && (
42+
<s.ResendButton
43+
buttonType={"secondary"}
44+
label={"Resend"}
45+
onClick={handleResendButtonClick}
46+
/>
47+
)}
48+
<s.IActivatedMyAccountLink onClick={handleLinkClick}>
49+
I activated my account
50+
</s.IActivatedMyAccountLink>
51+
</s.Container>
52+
);
53+
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import styled from "styled-components";
2+
import {
3+
subheading1BoldTypography,
4+
subscriptRegularTypography
5+
} from "../../../common/App/typographies";
6+
import { Link } from "../../../common/v3/Link";
7+
import { NewButton } from "../../../common/v3/NewButton";
8+
9+
export const Container = styled.div`
10+
display: flex;
11+
flex-direction: column;
12+
align-items: center;
13+
padding-top: 64px;
14+
gap: 24px;
15+
`;
16+
17+
export const Illustration = styled.img`
18+
height: 220px;
19+
`;
20+
21+
export const TextContainer = styled.div`
22+
${subscriptRegularTypography}
23+
display: flex;
24+
flex-direction: column;
25+
align-items: center;
26+
gap: 8px;
27+
text-align: center;
28+
color: ${({ theme }) => theme.colors.v3.text.secondary};
29+
max-width: 324px;
30+
`;
31+
32+
export const Title = styled.span`
33+
${subheading1BoldTypography}
34+
color: ${({ theme }) => theme.colors.v3.text.primary};
35+
`;
36+
37+
export const ResendButton = styled(NewButton)`
38+
max-width: 250px;
39+
`;
40+
41+
export const IActivatedMyAccountLink = styled(Link)`
42+
margin-top: 14px;
43+
`;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export interface AccountActivationProps {
2+
emailToConfirm?: string;
3+
onConfirmationEmailResend: (email: string) => void;
4+
onClose: () => void;
5+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import {
2+
DIGMA_PRIVACY_POLICY_URL,
3+
DIGMA_TERMS_OF_USE_URL
4+
} from "../../../../constants";
5+
import { openURLInDefaultBrowser } from "../../../../utils/actions/openURLInDefaultBrowser";
6+
import { sendUserActionTrackingEvent } from "../../../../utils/actions/sendUserActionTrackingEvent";
7+
import * as s from "./styles";
8+
9+
export const Agreement = () => {
10+
const handleTermsOfUseLinkClick = () => {
11+
sendUserActionTrackingEvent("terms of use link clicked");
12+
openURLInDefaultBrowser(DIGMA_TERMS_OF_USE_URL);
13+
};
14+
15+
const handlePrivacyPolicyLinkClick = () => {
16+
sendUserActionTrackingEvent("privacy policy link clicked");
17+
openURLInDefaultBrowser(DIGMA_PRIVACY_POLICY_URL);
18+
};
19+
return (
20+
<s.Container>
21+
<span>By signing up, you agree with</span>
22+
<span>
23+
<s.Link onClick={handleTermsOfUseLinkClick}>Terms of Use</s.Link> and{" "}
24+
<s.Link onClick={handlePrivacyPolicyLinkClick}>Privacy Policy</s.Link>
25+
</span>
26+
</s.Container>
27+
);
28+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import styled from "styled-components";
2+
import { subscriptRegularTypography } from "../../../common/App/typographies";
3+
import { Link as CommonLink } from "../../../common/v3/Link";
4+
5+
export const Container = styled.div`
6+
display: flex;
7+
flex-direction: column;
8+
gap: 4px;
9+
align-items: center;
10+
text-align: center;
11+
color: ${({ theme }) => theme.colors.v3.text.tertiary};
12+
${subscriptRegularTypography}
13+
`;
14+
15+
export const Link = styled(CommonLink)`
16+
${subscriptRegularTypography}
17+
text-decoration: underline;
18+
display: inline;
19+
`;

0 commit comments

Comments
 (0)