forked from Remitwise-Org/Remitwise-Frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSessionExpiryProvider.tsx
More file actions
44 lines (41 loc) · 1.16 KB
/
Copy pathSessionExpiryProvider.tsx
File metadata and controls
44 lines (41 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'use client';
import { useSessionExpiry } from '@/lib/client/useSessionExpiry';
import SessionExpiryNotification from './SessionExpiryNotification';
/**
* Session expiry provider component
* Wraps the application to provide global session expiry notifications
* Handles both warning (countdown + stay signed in) and expired (reconnect) phases.
*
* @example Usage in layout
* ```typescript
* import SessionExpiryProvider from '@/components/SessionExpiryProvider';
*
* export default function RootLayout({ children }) {
* return (
* <html>
* <body>
* <SessionExpiryProvider>
* {children}
* </SessionExpiryProvider>
* </body>
* </html>
* );
* }
* ```
*/
export default function SessionExpiryProvider({ children }: { children: React.ReactNode }) {
const { phase, message, countdown, staySignedIn, reconnect, clearExpiry } = useSessionExpiry();
return (
<>
<SessionExpiryNotification
phase={phase}
message={message}
countdown={countdown}
onStaySignedIn={staySignedIn}
onReconnect={reconnect}
onDismiss={clearExpiry}
/>
{children}
</>
);
}