File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -31,14 +31,20 @@ export interface SessionMetadata {
3131 otp_bypass_token_exists : boolean
3232}
3333
34- export function useSessionMetadata ( ) : SessionMetadata | undefined {
34+ export function useSessionMetadata < T = SessionMetadata > (
35+ cookieName = SESSION_METADATA_COOKIE_NAME ,
36+ ) : T | undefined {
3537 return useSelector ( selectIsLoggedIn )
36- ? ( JSON . parse (
37- Cookies . get ( SESSION_METADATA_COOKIE_NAME ) ! ,
38- ) as SessionMetadata )
38+ ? ( JSON . parse ( Cookies . get ( cookieName ) ! ) as T )
3939 : undefined
4040}
4141
42+ useSessionMetadata . predefine = < SessionMetadata , > (
43+ cookieName = SESSION_METADATA_COOKIE_NAME ,
44+ ) => {
45+ return ( ) => useSessionMetadata < SessionMetadata > ( cookieName )
46+ }
47+
4248export type UseSessionChildrenFunction < Required extends boolean > = (
4349 metadata : Required extends true
4450 ? SessionMetadata
You can’t perform that action at this time.
0 commit comments