@@ -5,6 +5,7 @@ import { Button } from '@/components/ui/button';
55import { Settings as SettingsIcon , ArrowLeft } from 'lucide-react' ;
66import { RelayListManager } from '@/components/RelayListManager' ;
77import { useCurrentUser } from '@/hooks/useCurrentUser' ;
8+ import { useInventoryKey } from '@/hooks/useInventoryKey' ;
89import { LoginArea } from '@/components/auth/LoginArea' ;
910
1011export function Settings ( ) {
@@ -96,7 +97,54 @@ export function Settings() {
9697 </ div >
9798 </ CardContent >
9899 </ Card >
100+
101+ { /* Troubleshooting */ }
102+ < Card className = "border-0 shadow-xl bg-white/70 dark:bg-slate-800/70 backdrop-blur-sm mt-8" >
103+ < CardContent className = "pt-6" >
104+ < div className = "space-y-4" >
105+ < div >
106+ < h3 className = "text-lg font-semibold text-red-600 dark:text-red-400" > Troubleshooting</ h3 >
107+ < p className = "text-muted-foreground text-sm" >
108+ If you are experiencing issues with sharing or data persistence (e.g. "Not ready or no personal key"), try resetting your encryption key.
109+ < br /> < strong > Warning:</ strong > This will invalidate existing shares. You will need to re-share your inventory.
110+ </ p >
111+ </ div >
112+ < ResetKeyButton />
113+ </ div >
114+ </ CardContent >
115+ </ Card >
99116 </ div >
100117 </ div >
101118 ) ;
119+ }
120+
121+ function ResetKeyButton ( ) {
122+ const { initializeKey, isLoading, myKey } = useInventoryKey ( ) ;
123+ const [ status , setStatus ] = React . useState < string > ( '' ) ;
124+
125+ const handleReset = async ( ) => {
126+ try {
127+ setStatus ( 'Resetting...' ) ;
128+ await initializeKey . mutateAsync ( ) ;
129+ setStatus ( 'Success! Key reset.' ) ;
130+ setTimeout ( ( ) => setStatus ( '' ) , 3000 ) ;
131+ } catch ( e ) {
132+ console . error ( e ) ;
133+ setStatus ( 'Error: ' + ( e as Error ) . message ) ;
134+ }
135+ } ;
136+
137+ return (
138+ < div className = "flex items-center gap-4" >
139+ < Button
140+ variant = "destructive"
141+ onClick = { handleReset }
142+ disabled = { isLoading || initializeKey . isPending }
143+ >
144+ { initializeKey . isPending ? 'Resetting...' : 'Reset Inventory Key' }
145+ </ Button >
146+ { status && < span className = "text-sm font-medium" > { status } </ span > }
147+ { myKey && < span className = "text-xs text-green-600" > Active Key Present</ span > }
148+ </ div >
149+ ) ;
102150}
0 commit comments