"use client" import { useAccount } from "@/lib/providers/jazz-provider" import { useState, useCallback, useEffect } from "react" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { toast } from "sonner" const MODIFIER_KEYS = ["Control", "Alt", "Shift", "Meta"] const HotkeyInput = ({ label, value, onChange }: { label: string value: string onChange: (value: string) => void }) => { const [recording, setRecording] = useState(false) const [currentKeys, setCurrentKeys] = useState([]) const handleKeyDown = useCallback( (e: React.KeyboardEvent) => { e.preventDefault() if (!recording) return const key = e.key === " " ? "Space" : e.key if (!currentKeys.includes(key)) { setCurrentKeys(prev => { const newKeys = [...prev, key] return newKeys.slice(-3) }) } }, [recording, currentKeys] ) const handleKeyUp = useCallback( (e: React.KeyboardEvent) => { if (!recording) return const key = e.key === " " ? "Space" : e.key if (MODIFIER_KEYS.includes(key)) return if (currentKeys.length > 0) { onChange(currentKeys.join("+")) setRecording(false) setCurrentKeys([]) } }, [recording, currentKeys, onChange] ) useEffect(() => { if (recording) { const handleKeyDownEvent = (e: KeyboardEvent) => handleKeyDown(e as unknown as React.KeyboardEvent) const handleKeyUpEvent = (e: KeyboardEvent) => handleKeyUp(e as unknown as React.KeyboardEvent) window.addEventListener("keydown", handleKeyDownEvent) window.addEventListener("keyup", handleKeyUpEvent) return () => { window.removeEventListener("keydown", handleKeyDownEvent) window.removeEventListener("keyup", handleKeyUpEvent) } } }, [recording, handleKeyDown, handleKeyUp]) return (
setRecording(true)} />
) } export const SettingsRoute = () => { // const { me } = useAccount() const [inboxHotkey, setInboxHotkey] = useState("") const [topInboxHotkey, setTopInboxHotkey] = useState("") const saveSettings = () => { toast.success("Settings saved", { description: "Your hotkey settings have been updated." }) } return (

Settings

) }