index.tsx raw
1 import { Button } from '@/components/ui/button'
2 import SecondaryPageLayout from '@/layouts/SecondaryPageLayout'
3 import { useSecondaryPage } from '@/PageManager'
4 import { useNostr } from '@/providers/NostrProvider'
5 import { forwardRef } from 'react'
6 import { useTranslation } from 'react-i18next'
7
8 const LogoutPage = forwardRef(({ index }: { index?: number }, ref) => {
9 const { t } = useTranslation()
10 const { pop } = useSecondaryPage()
11 const { account, removeAccount } = useNostr()
12
13 const handleLogout = () => {
14 if (account) {
15 removeAccount(account)
16 pop()
17 }
18 }
19
20 return (
21 <SecondaryPageLayout ref={ref} index={index} title={t('Logout')}>
22 <div className="p-4 space-y-6">
23 <p className="text-muted-foreground">{t('Are you sure you want to logout?')}</p>
24 <div className="flex flex-col gap-3">
25 <Button variant="outline" onClick={() => pop()} className="w-full">
26 {t('Cancel')}
27 </Button>
28 <Button variant="destructive" onClick={handleLogout} className="w-full">
29 {t('Logout')}
30 </Button>
31 </div>
32 </div>
33 </SecondaryPageLayout>
34 )
35 })
36 LogoutPage.displayName = 'LogoutPage'
37 export default LogoutPage
38