11"use client" ;
22
3- import React , { useEffect } from "react" ;
3+ import React from "react" ;
44import { Button } from "@/components/ui/Button" ;
5+ import { useModalDialog } from "@/hooks/useModalDialog" ;
56import type { Stream } from "@/lib/dashboard" ;
67
78interface StreamDetailsModalProps {
@@ -17,30 +18,29 @@ export const StreamDetailsModal: React.FC<StreamDetailsModalProps> = ({
1718 onCancelClick,
1819 onTopUpClick,
1920} ) => {
20- // Escape key support
21- useEffect ( ( ) => {
22- const handleEscape = ( e : KeyboardEvent ) => {
23- if ( e . key === "Escape" ) onClose ( ) ;
24- } ;
25- window . addEventListener ( "keydown" , handleEscape ) ;
26- return ( ) => window . removeEventListener ( "keydown" , handleEscape ) ;
27- } , [ onClose ] ) ;
21+ const dialogRef = useModalDialog ( { onClose } ) ;
2822
2923 const progress = stream . deposited > 0 ? Math . min ( 100 , Math . max ( 0 , ( stream . withdrawn / stream . deposited ) * 100 ) ) : 0 ;
3024 const remaining = stream . deposited - stream . withdrawn ;
3125
3226 return (
3327 < div
3428 className = "fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-md"
29+ role = "dialog"
30+ aria-modal = "true"
31+ aria-labelledby = "stream-details-modal-title"
3532 onClick = { ( e ) => {
3633 if ( e . target === e . currentTarget ) onClose ( ) ;
3734 } }
3835 >
39- < div className = "glass-card relative w-full max-w-2xl mx-4 rounded-3xl border border-glass-border p-8 shadow-2xl animate-in fade-in zoom-in-95" >
36+ < div
37+ ref = { dialogRef }
38+ className = "glass-card relative w-full max-w-2xl mx-4 rounded-3xl border border-glass-border p-8 shadow-2xl animate-in fade-in zoom-in-95"
39+ >
4040 { /* Header */ }
4141 < div className = "flex items-center justify-between mb-8" >
4242 < div >
43- < h2 className = "text-2xl font-black tracking-tight" > Stream Details</ h2 >
43+ < h2 id = "stream-details-modal-title" className = "text-2xl font-black tracking-tight" > Stream Details</ h2 >
4444 < p className = "text-sm text-slate-400 font-mono" > ID: { stream . id } </ p >
4545 </ div >
4646 < button
0 commit comments