22
33import { useEffect , useState } from "react" ;
44import { useRouter } from "next/navigation" ;
5+ import FocusTrap from "focus-trap-react" ;
56
67// #826: apiFetch dispatches "auth:expired" instead of forcing a full page
78// reload on 401, so in-progress form state elsewhere on the page survives.
@@ -20,57 +21,59 @@ export function AuthExpiredListener() {
2021 if ( ! expired ) return null ;
2122
2223 return (
23- < div
24- role = "alertdialog"
25- aria-modal = "true"
26- aria-labelledby = "auth-expired-title"
27- style = { {
28- position : "fixed" ,
29- inset : 0 ,
30- zIndex : 100 ,
31- display : "flex" ,
32- alignItems : "center" ,
33- justifyContent : "center" ,
34- background : "rgba(0, 0, 0, 0.6)" ,
35- } }
36- >
24+ < FocusTrap focusTrapOptions = { { escapeDeactivates : false } } >
3725 < div
26+ role = "alertdialog"
27+ aria-modal = "true"
28+ aria-labelledby = "auth-expired-title"
3829 style = { {
39- maxWidth : 360 ,
40- borderRadius : 16 ,
41- padding : 24 ,
42- background : "#0a0a0f" ,
43- border : "1px solid rgba(255,255,255,0.1)" ,
44- color : "#fff" ,
30+ position : "fixed" ,
31+ inset : 0 ,
32+ zIndex : 100 ,
33+ display : "flex" ,
34+ alignItems : "center" ,
35+ justifyContent : "center" ,
36+ background : "rgba(0, 0, 0, 0.6)" ,
4537 } }
4638 >
47- < h2 id = "auth-expired-title" style = { { margin : 0 , fontSize : 16 , fontWeight : 600 } } >
48- Session expired
49- </ h2 >
50- < p style = { { marginTop : 8 , marginBottom : 16 , fontSize : 14 , color : "rgba(255,255,255,0.6)" } } >
51- Your session has expired. Any unsaved changes on this page were not submitted.
52- Please log in again to continue.
53- </ p >
54- < button
55- type = "button"
56- onClick = { ( ) => {
57- setExpired ( false ) ;
58- router . replace ( "/" ) ;
59- } }
39+ < div
6040 style = { {
61- width : "100%" ,
62- padding : "10px 16px" ,
63- borderRadius : 9999 ,
64- border : "none" ,
65- background : "#00e5b0" ,
66- color : "#0a0a0f" ,
67- fontWeight : 600 ,
68- cursor : "pointer" ,
41+ maxWidth : 360 ,
42+ borderRadius : 16 ,
43+ padding : 24 ,
44+ background : "#0a0a0f" ,
45+ border : "1px solid rgba(255,255,255,0.1)" ,
46+ color : "#fff" ,
6947 } }
7048 >
71- Log in again
72- </ button >
49+ < h2 id = "auth-expired-title" style = { { margin : 0 , fontSize : 16 , fontWeight : 600 } } >
50+ Session expired
51+ </ h2 >
52+ < p style = { { marginTop : 8 , marginBottom : 16 , fontSize : 14 , color : "rgba(255,255,255,0.6)" } } >
53+ Your session has expired. Any unsaved changes on this page were not submitted.
54+ Please log in again to continue.
55+ </ p >
56+ < button
57+ type = "button"
58+ onClick = { ( ) => {
59+ setExpired ( false ) ;
60+ router . replace ( "/" ) ;
61+ } }
62+ style = { {
63+ width : "100%" ,
64+ padding : "10px 16px" ,
65+ borderRadius : 9999 ,
66+ border : "none" ,
67+ background : "#00e5b0" ,
68+ color : "#0a0a0f" ,
69+ fontWeight : 600 ,
70+ cursor : "pointer" ,
71+ } }
72+ >
73+ Log in again
74+ </ button >
75+ </ div >
7376 </ div >
74- </ div >
77+ </ FocusTrap >
7578 ) ;
7679}
0 commit comments