Skip to content

Commit aebef62

Browse files
authored
feat: verification modal (#988)
1 parent 1b35b30 commit aebef62

File tree

2 files changed

+30
-32
lines changed

2 files changed

+30
-32
lines changed

netlify/functions-src/mongo-scripts/create-user.mongodb.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ db.getCollection('users').insertOne({
2626
country: 'US',
2727
spokenLanguages: ['en', 'es'],
2828
tags: ['JavaScript', 'Node.js', 'MongoDB'],
29-
roles: ['mentor'],
29+
roles: ['Mentor'],
3030
channels: [
3131
{
3232
type: 'email',

src/components/layouts/App/App.js

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useState } from 'react';
1+
import { useEffect, useState, useCallback } from 'react';
22
import styled from 'styled-components/macro';
33
import { toast, ToastContainer } from 'react-toastify';
44

@@ -11,6 +11,8 @@ import { ActionsHandler } from './ActionsHandler';
1111
import { desktop, mobile } from '../../../Me/styles/shared/devices';
1212
import { Sidebar } from '../../Sidebar/Sidebar';
1313
import { useMentors } from '../../../context/mentorsContext/MentorsContext';
14+
import { useUser } from '../../../context/userContext/UserContext';
15+
import { VerificationModal } from './VerificationModal';
1416

1517
const App = (props) => {
1618
const { children } = props;
@@ -22,6 +24,16 @@ const App = (props) => {
2224
onClose: null,
2325
});
2426
const { mentors } = useMentors();
27+
const { isNotYetVerified, emailVerifiedInfo } = useUser();
28+
29+
const handleModal = useCallback((title, content, onClose) => {
30+
setModal({
31+
title,
32+
content,
33+
onClose,
34+
});
35+
report('Modal', 'open', title);
36+
}, []);
2537

2638
useEffect(() => {
2739
if (process.env.REACT_APP_MAINTENANCE_MESSAGE) {
@@ -43,14 +55,22 @@ const App = (props) => {
4355
[tag, country, name, language]
4456
);
4557

46-
const handleModal = (title, content, onClose) => {
47-
setModal({
48-
title,
49-
content,
50-
onClose,
51-
});
52-
report('Modal', 'open', title);
53-
};
58+
useEffect(() => {
59+
if (isNotYetVerified && emailVerifiedInfo?.email) {
60+
handleModal(
61+
'Email Verification Required',
62+
<VerificationModal
63+
onSuccess={() => {
64+
setModal({ title: null, content: null, onClose: null });
65+
toast.success('Verification email sent! Please check your inbox.');
66+
}}
67+
/>,
68+
() => {
69+
// Optional: handle modal close
70+
}
71+
);
72+
}
73+
}, [isNotYetVerified, emailVerifiedInfo, handleModal]);
5474

5575
return (
5676
<div className="app">
@@ -110,26 +130,4 @@ const Main = styled.section`
110130
}
111131
`;
112132

113-
const StayTunedLink = styled.a`
114-
border-radius: 3px;
115-
box-sizing: border-box;
116-
font-family: Lato,sans-serif;
117-
transition: box-shadow 0.1s ease-in-out;
118-
background-color: #69d5b1;
119-
color: #fff;
120-
margin: 10px auto;
121-
display: block;
122-
width: fit-content;
123-
padding: 5px 10px;
124-
text-decoration: none;
125-
126-
&:hover {
127-
box-shadow: inset 0 0 100px 0 #00000010;
128-
}
129-
130-
&:disabled {
131-
opacity: 0.5;
132-
}
133-
`;
134-
135133
export default AppWithActionHandlers;

0 commit comments

Comments
 (0)