1
- import { useEffect , useState } from 'react' ;
1
+ import { useEffect , useState , useCallback } from 'react' ;
2
2
import styled from 'styled-components/macro' ;
3
3
import { toast , ToastContainer } from 'react-toastify' ;
4
4
@@ -11,6 +11,8 @@ import { ActionsHandler } from './ActionsHandler';
11
11
import { desktop , mobile } from '../../../Me/styles/shared/devices' ;
12
12
import { Sidebar } from '../../Sidebar/Sidebar' ;
13
13
import { useMentors } from '../../../context/mentorsContext/MentorsContext' ;
14
+ import { useUser } from '../../../context/userContext/UserContext' ;
15
+ import { VerificationModal } from './VerificationModal' ;
14
16
15
17
const App = ( props ) => {
16
18
const { children } = props ;
@@ -22,6 +24,16 @@ const App = (props) => {
22
24
onClose : null ,
23
25
} ) ;
24
26
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
+ } , [ ] ) ;
25
37
26
38
useEffect ( ( ) => {
27
39
if ( process . env . REACT_APP_MAINTENANCE_MESSAGE ) {
@@ -43,14 +55,22 @@ const App = (props) => {
43
55
[ tag , country , name , language ]
44
56
) ;
45
57
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 ] ) ;
54
74
55
75
return (
56
76
< div className = "app" >
@@ -110,26 +130,4 @@ const Main = styled.section`
110
130
}
111
131
` ;
112
132
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
-
135
133
export default AppWithActionHandlers ;
0 commit comments