Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion netlify/functions-src/mongo-scripts/create-user.mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ db.getCollection('users').insertOne({
country: 'US',
spokenLanguages: ['en', 'es'],
tags: ['JavaScript', 'Node.js', 'MongoDB'],
roles: ['mentor'],
roles: ['Mentor'],
channels: [
{
type: 'email',
Expand Down
60 changes: 29 additions & 31 deletions src/components/layouts/App/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react';
import { useEffect, useState, useCallback } from 'react';
import styled from 'styled-components/macro';
import { toast, ToastContainer } from 'react-toastify';

Expand All @@ -11,6 +11,8 @@ import { ActionsHandler } from './ActionsHandler';
import { desktop, mobile } from '../../../Me/styles/shared/devices';
import { Sidebar } from '../../Sidebar/Sidebar';
import { useMentors } from '../../../context/mentorsContext/MentorsContext';
import { useUser } from '../../../context/userContext/UserContext';
import { VerificationModal } from './VerificationModal';

const App = (props) => {
const { children } = props;
Expand All @@ -22,6 +24,16 @@ const App = (props) => {
onClose: null,
});
const { mentors } = useMentors();
const { isNotYetVerified, emailVerifiedInfo } = useUser();

const handleModal = useCallback((title, content, onClose) => {
setModal({
title,
content,
onClose,
});
report('Modal', 'open', title);
}, []);

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

const handleModal = (title, content, onClose) => {
setModal({
title,
content,
onClose,
});
report('Modal', 'open', title);
};
useEffect(() => {
if (isNotYetVerified && emailVerifiedInfo?.email) {
handleModal(
'Email Verification Required',
<VerificationModal
onSuccess={() => {
setModal({ title: null, content: null, onClose: null });
toast.success('Verification email sent! Please check your inbox.');
}}
/>,
() => {
// Optional: handle modal close
}
);
}
}, [isNotYetVerified, emailVerifiedInfo, handleModal]);

return (
<div className="app">
Expand Down Expand Up @@ -110,26 +130,4 @@ const Main = styled.section`
}
`;

const StayTunedLink = styled.a`
border-radius: 3px;
box-sizing: border-box;
font-family: Lato,sans-serif;
transition: box-shadow 0.1s ease-in-out;
background-color: #69d5b1;
color: #fff;
margin: 10px auto;
display: block;
width: fit-content;
padding: 5px 10px;
text-decoration: none;

&:hover {
box-shadow: inset 0 0 100px 0 #00000010;
}

&:disabled {
opacity: 0.5;
}
`;

export default AppWithActionHandlers;