@@ -4,20 +4,32 @@ import FullScreenButton from "./FullScreenButton";
4
4
import { useNavigate } from "react-router-dom" ;
5
5
import Parse from "parse" ;
6
6
import { useWindowSize } from "../hook/useWindowSize" ;
7
- import { openInNewTab } from "../constant/Utils" ;
7
+ import { checkIsSubscribed , openInNewTab } from "../constant/Utils" ;
8
+ import { isEnableSubscription } from "../constant/const" ;
9
+
8
10
const Header = ( { showSidebar } ) => {
9
- const navigation = useNavigate ( ) ;
11
+ const navigate = useNavigate ( ) ;
10
12
const { width } = useWindowSize ( ) ;
11
13
let applogo = localStorage . getItem ( "appLogo" ) || "" ;
12
14
let username = localStorage . getItem ( "username" ) ;
13
15
const image = localStorage . getItem ( "profileImg" ) || dp ;
14
16
15
17
const [ isOpen , setIsOpen ] = useState ( false ) ;
18
+ const [ isSubscribe , setIsSubscribe ] = useState ( true ) ;
16
19
17
20
const toggleDropdown = ( ) => {
18
21
setIsOpen ( ! isOpen ) ;
19
22
} ;
20
-
23
+ useEffect ( ( ) => {
24
+ checkSubscription ( ) ;
25
+ // eslint-disable-next-line react-hooks/exhaustive-deps
26
+ } , [ ] ) ;
27
+ async function checkSubscription ( ) {
28
+ if ( isEnableSubscription ) {
29
+ const getIsSubscribe = await checkIsSubscribed ( ) ;
30
+ setIsSubscribe ( getIsSubscribe ) ;
31
+ }
32
+ }
21
33
const closeDropdown = ( ) => {
22
34
setIsOpen ( false ) ;
23
35
Parse . User . logOut ( ) ;
@@ -43,7 +55,7 @@ const Header = ({ showSidebar }) => {
43
55
localStorage . setItem ( "baseUrl" , baseUrl ) ;
44
56
localStorage . setItem ( "parseAppId" , appid ) ;
45
57
46
- navigation ( "/" ) ;
58
+ navigate ( "/" ) ;
47
59
} ;
48
60
49
61
//handle to close profile drop down menu onclick screen
@@ -83,6 +95,16 @@ const Header = ({ showSidebar }) => {
83
95
id = "profile-menu"
84
96
className = "flex justify-between items-center gap-x-3"
85
97
>
98
+ { ! isSubscribe && (
99
+ < div >
100
+ < button
101
+ className = "text-xs bg-[#002864] p-2 text-white rounded shadow"
102
+ onClick = { ( ) => navigate ( "/subscription" ) }
103
+ >
104
+ Upgrade Now
105
+ </ button >
106
+ </ div >
107
+ ) }
86
108
< div >
87
109
< FullScreenButton />
88
110
</ div >
@@ -123,7 +145,7 @@ const Header = ({ showSidebar }) => {
123
145
className = "hover:bg-gray-100 py-1 px-2 cursor-pointer font-normal"
124
146
onClick = { ( ) => {
125
147
setIsOpen ( false ) ;
126
- navigation ( "/profile" ) ;
148
+ navigate ( "/profile" ) ;
127
149
} }
128
150
>
129
151
< i className = "fa-regular fa-user" > </ i > Profile
@@ -132,7 +154,7 @@ const Header = ({ showSidebar }) => {
132
154
className = "hover:bg-gray-100 py-1 px-2 cursor-pointer font-normal"
133
155
onClick = { ( ) => {
134
156
setIsOpen ( false ) ;
135
- navigation ( "/changepassword" ) ;
157
+ navigate ( "/changepassword" ) ;
136
158
} }
137
159
>
138
160
< i className = "fa-solid fa-lock" > </ i > Change Password
0 commit comments