diff --git a/src/components/BluetoothDevicePicker.tsx b/src/components/BluetoothDevicePicker.tsx index b828d03..c89c5e8 100644 --- a/src/components/BluetoothDevicePicker.tsx +++ b/src/components/BluetoothDevicePicker.tsx @@ -1,5 +1,14 @@ import { useEffect, useState, useCallback } from "react"; import type { BluetoothDevice } from "../types/electron"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog"; +import { Button } from "@/components/ui/button"; export function BluetoothDevicePicker() { const [devices, setDevices] = useState([]); @@ -40,111 +49,71 @@ export function BluetoothDevicePicker() { setIsScanning(false); }, []); - // Handle escape key - const handleEscape = useCallback( - (e: KeyboardEvent) => { - if (e.key === "Escape") { - handleCancel(); - } - }, - [handleCancel], - ); - - useEffect(() => { - if (isOpen) { - document.addEventListener("keydown", handleEscape); - return () => document.removeEventListener("keydown", handleEscape); - } - }, [isOpen, handleEscape]); - - if (!isOpen) return null; - return ( -
-
e.stopPropagation()} - role="dialog" - aria-labelledby="bluetooth-picker-title" - aria-describedby="bluetooth-picker-message" + !open && handleCancel()}> + -
-

- Select Bluetooth Device -

-
-
- {isScanning && devices.length === 0 ? ( -
- - - - - - Scanning for Bluetooth devices... - -
- ) : ( - <> -

- {devices.length} device{devices.length !== 1 ? "s" : ""} found. - Select a device to connect: -

-
- {devices.map((device) => ( - - ))} + + Select Bluetooth Device + + {isScanning && devices.length === 0 ? ( +
+ + + + + Scanning for Bluetooth devices...
- - )} -
-
- + ))} +
+ )} + + + -
-
-
+ + + + ); } diff --git a/src/components/ConfirmDialog.tsx b/src/components/ConfirmDialog.tsx index d984cdc..02498a2 100644 --- a/src/components/ConfirmDialog.tsx +++ b/src/components/ConfirmDialog.tsx @@ -1,4 +1,14 @@ -import { useEffect, useCallback } from "react"; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, +} from "@/components/ui/alert-dialog"; +import { cn } from "@/lib/utils"; interface ConfirmDialogProps { isOpen: boolean; @@ -21,75 +31,32 @@ export function ConfirmDialog({ onCancel, variant = "warning", }: ConfirmDialogProps) { - // Handle escape key - const handleEscape = useCallback( - (e: KeyboardEvent) => { - if (e.key === "Escape") { - onCancel(); - } - }, - [onCancel], - ); - - useEffect(() => { - if (isOpen) { - document.addEventListener("keydown", handleEscape); - return () => document.removeEventListener("keydown", handleEscape); - } - }, [isOpen, handleEscape]); - - if (!isOpen) return null; - return ( -
-
e.stopPropagation()} - role="dialog" - aria-labelledby="dialog-title" - aria-describedby="dialog-message" + !open && onCancel()}> + -
-

- {title} -

-
-
-

- {message} -

-
-
- - -
-
-
+ + + + ); }