File tree Expand file tree Collapse file tree 3 files changed +28
-21
lines changed Expand file tree Collapse file tree 3 files changed +28
-21
lines changed Original file line number Diff line number Diff line change @@ -49,20 +49,19 @@ const AddSigner = (props) => {
49
49
e . preventDefault ( ) ;
50
50
e . stopPropagation ( ) ;
51
51
setIsLoader ( true ) ;
52
+ if ( localStorage . getItem ( "TenantId" ) ) {
52
53
try {
53
54
const contactQuery = new Parse . Object ( "contracts_Contactbook" ) ;
54
55
contactQuery . set ( "Name" , name ) ;
55
56
contactQuery . set ( "Phone" , phone ) ;
56
57
contactQuery . set ( "Email" , email ) ;
57
58
contactQuery . set ( "UserRole" , "contracts_Guest" ) ;
58
59
59
- if ( localStorage . getItem ( "TenantId" ) ) {
60
60
contactQuery . set ( "TenantId" , {
61
61
__type : "Pointer" ,
62
62
className : "partners_Tenant" ,
63
63
objectId : localStorage . getItem ( "TenantId" )
64
64
} ) ;
65
- }
66
65
67
66
try {
68
67
const _users = Parse . Object . extend ( "User" ) ;
@@ -188,6 +187,9 @@ const AddSigner = (props) => {
188
187
setIsLoader ( false ) ;
189
188
alert ( "something went wrong!" ) ;
190
189
}
190
+ } else {
191
+ alert ( 'something went wrong, please try again later' )
192
+ }
191
193
} ;
192
194
193
195
// Define a function to handle the "add yourself" checkbox
Original file line number Diff line number Diff line change @@ -28,29 +28,34 @@ const HomeLayout = () => {
28
28
const [ tourConfigs , setTourConfigs ] = useState ( [ ] ) ;
29
29
const [ , setCookie ] = useCookies ( [ "accesstoken" , "main_Domain" ] ) ;
30
30
31
+ const tenantId = localStorage . getItem ( "TenantId" ) ;
31
32
useEffect ( ( ) => {
32
- ( async ( ) => {
33
- try {
34
- // Use the session token to validate the user
35
- const userQuery = new Parse . Query ( Parse . User ) ;
36
- const user = await userQuery . get ( Parse . User . current ( ) . id , {
37
- sessionToken : localStorage . getItem ( "accesstoken" )
38
- } ) ;
39
- if ( user ) {
40
- localStorage . setItem ( "profileImg" , user . get ( "ProfilePic" ) || "" ) ;
41
- checkIsSubscribed ( ) ;
42
- } else {
33
+ if ( ! tenantId ) {
34
+ setIsUserValid ( false ) ;
35
+ } else {
36
+ ( async ( ) => {
37
+ try {
38
+ // Use the session token to validate the user
39
+ const userQuery = new Parse . Query ( Parse . User ) ;
40
+ const user = await userQuery . get ( Parse . User . current ( ) . id , {
41
+ sessionToken : localStorage . getItem ( "accesstoken" )
42
+ } ) ;
43
+ if ( user ) {
44
+ localStorage . setItem ( "profileImg" , user . get ( "ProfilePic" ) || "" ) ;
45
+ checkIsSubscribed ( ) ;
46
+ } else {
47
+ setIsUserValid ( false ) ;
48
+ }
49
+ } catch ( error ) {
50
+ // Session token is invalid or there was an error
43
51
setIsUserValid ( false ) ;
44
52
}
45
- } catch ( error ) {
46
- // Session token is invalid or there was an error
47
- setIsUserValid ( false ) ;
48
- }
49
- } ) ( ) ;
50
- saveCookies ( ) ;
53
+ } ) ( ) ;
54
+ saveCookies ( ) ;
55
+ }
51
56
52
57
// eslint-disable-next-line react-hooks/exhaustive-deps
53
- } , [ ] ) ;
58
+ } , [ tenantId ] ) ;
54
59
//function to use save data in cookies storage
55
60
const saveCookies = ( ) => {
56
61
const main_Domain = window . location . origin ;
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ const Dashboard = () => {
24
24
getDashboard ( localStorage . getItem ( "PageLanding" ) ) ;
25
25
}
26
26
} else {
27
- navigate ( "/" , { replace : true , state : { from : location } } ) ;
27
+ navigate ( "/" , { replace : true , state : { from : "" } } ) ;
28
28
}
29
29
// eslint-disable-next-line
30
30
} , [ id ] ) ;
You can’t perform that action at this time.
0 commit comments