@@ -31,15 +31,18 @@ const AddUser = (props) => {
31
31
const [ planInfo , setPlanInfo ] = useState ( {
32
32
priceperUser : 0 ,
33
33
price : 0 ,
34
- totalAllowedUser : 0
34
+ totalAllowedUser : 0 ,
35
+ adminId : ""
35
36
} ) ;
36
37
const [ isFormLoader , setIsFormLoader ] = useState ( false ) ;
37
38
const [ isLoader , setIsLoader ] = useState ( false ) ;
38
39
const [ teamList , setTeamList ] = useState ( [ ] ) ;
39
40
const [ allowedUser , setAllowedUser ] = useState ( 0 ) ;
40
41
const [ err , setErr ] = useState ( "" ) ;
41
42
const role = [ "OrgAdmin" , "Editor" , "User" ] ;
42
-
43
+ const extUser =
44
+ localStorage . getItem ( "Extand_Class" ) &&
45
+ JSON . parse ( localStorage . getItem ( "Extand_Class" ) ) ?. [ 0 ] ;
43
46
useEffect ( ( ) => {
44
47
getTeamList ( ) ;
45
48
// eslint-disable-next-line
@@ -54,15 +57,20 @@ const AddUser = (props) => {
54
57
setPlanInfo ( ( prev ) => ( {
55
58
...prev ,
56
59
priceperUser : resSub . price ,
57
- totalAllowedUser : resSub . totalAllowedUser
60
+ totalAllowedUser : resSub . totalAllowedUser ,
61
+ adminId : resSub . adminId
58
62
} ) ) ;
59
63
setAmount ( ( prev ) => ( { ...prev , price : resSub . price } ) ) ;
60
64
const res = await Parse . Cloud . run ( "allowedusers" ) ;
61
65
if ( props . setFormHeader ) {
62
66
if ( res > 0 ) {
63
67
props . setFormHeader ( t ( "add-user" ) ) ;
64
68
} else {
65
- props . setFormHeader ( t ( "Add-seats" ) ) ;
69
+ props . setFormHeader (
70
+ resSub . adminId !== extUser ?. objectId
71
+ ? "Unauthorized"
72
+ : t ( "Add-seats" )
73
+ ) ;
66
74
}
67
75
}
68
76
setAllowedUser ( res ) ;
@@ -483,40 +491,51 @@ const AddUser = (props) => {
483
491
</ div >
484
492
</ form >
485
493
) : (
486
- < form onSubmit = { handleAddOnSubmit } >
487
- < p className = "flex justify-center text-center mx-2 mb-3 text-base op-text-accent font-medium" >
488
- { t ( "additional-users" ) }
489
- </ p >
490
- < div className = "mb-3 flex justify-between" >
491
- < label
492
- htmlFor = "quantity"
493
- className = "block text-xs text-gray-700 font-semibold"
494
- >
495
- { t ( "Quantity-of-users" ) }
496
- < span className = "text-[red] text-[13px]" > *</ span >
497
- </ label >
498
- < input
499
- type = "number"
500
- name = "quantity"
501
- value = { amount . quantity }
502
- onChange = { ( e ) => handlePricePerUser ( e ) }
503
- className = "w-1/4 op-input op-input-bordered op-input-sm focus:outline-none hover:border-base-content text-xs"
504
- required
505
- />
506
- </ div >
507
- < div className = "mb-3 flex justify-between" >
508
- < label className = "block text-xs text-gray-700 font-semibold" >
509
- { t ( "Price" ) } (1 * { planInfo . priceperUser } )
510
- </ label >
511
- < div className = "w-1/4 flex justify-center items-center text-sm" >
512
- USD { amount . price }
494
+ < >
495
+ { planInfo . adminId !== extUser ?. objectId ? (
496
+ < div className = "mb-3 mt-1 flex justify-center text-center items-center font-medium break-all" >
497
+ { t ( "unauthorized-modal" , {
498
+ adminName : extUser ?. CreatedBy ?. name ,
499
+ adminEmail : extUser ?. CreatedBy ?. email
500
+ } ) }
513
501
</ div >
514
- </ div >
515
- < hr className = "text-base-content mb-3" />
516
- < button className = "op-btn op-btn-primary w-full" >
517
- { t ( "Proceed" ) }
518
- </ button >
519
- </ form >
502
+ ) : (
503
+ < form onSubmit = { handleAddOnSubmit } >
504
+ < p className = "flex justify-center text-center mx-2 mb-3 text-base op-text-accent font-medium" >
505
+ { t ( "additional-users" ) }
506
+ </ p >
507
+ < div className = "mb-3 flex justify-between" >
508
+ < label
509
+ htmlFor = "quantity"
510
+ className = "block text-xs text-gray-700 font-semibold"
511
+ >
512
+ { t ( "Quantity-of-users" ) }
513
+ < span className = "text-[red] text-[13px]" > *</ span >
514
+ </ label >
515
+ < input
516
+ type = "number"
517
+ name = "quantity"
518
+ value = { amount . quantity }
519
+ onChange = { ( e ) => handlePricePerUser ( e ) }
520
+ className = "w-1/4 op-input op-input-bordered op-input-sm focus:outline-none hover:border-base-content text-xs"
521
+ required
522
+ />
523
+ </ div >
524
+ < div className = "mb-3 flex justify-between" >
525
+ < label className = "block text-xs text-gray-700 font-semibold" >
526
+ { t ( "Price" ) } (1 * { planInfo . priceperUser } )
527
+ </ label >
528
+ < div className = "w-1/4 flex justify-center items-center text-sm" >
529
+ USD { amount . price }
530
+ </ div >
531
+ </ div >
532
+ < hr className = "text-base-content mb-3" />
533
+ < button className = "op-btn op-btn-primary w-full" >
534
+ { t ( "Proceed" ) }
535
+ </ button >
536
+ </ form >
537
+ ) }
538
+ </ >
520
539
) }
521
540
</ div >
522
541
) }
0 commit comments