- app/(mobile)/m/settings/page.tsx — read-only account-info, product-selector (hergebruikt ActivateProductButton + setActiveProductAction met redirectTo /m/products/[id]/solo), QR-pairing-instructie, logout - components/mobile/logout-button.tsx — AlertDialog "Uitloggen?" met bevestig + annuleer; demo-user mag uitloggen (geen demo-block) - Tests: LogoutButton render + open + bevestig (logoutAction) + annuleer Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
'use client'
|
|
|
|
import { useState, useTransition } from 'react'
|
|
import { LogOut } from 'lucide-react'
|
|
import {
|
|
AlertDialog,
|
|
AlertDialogAction,
|
|
AlertDialogCancel,
|
|
AlertDialogContent,
|
|
AlertDialogDescription,
|
|
AlertDialogFooter,
|
|
AlertDialogHeader,
|
|
AlertDialogTitle,
|
|
} from '@/components/ui/alert-dialog'
|
|
import { Button } from '@/components/ui/button'
|
|
import { logoutAction } from '@/actions/auth'
|
|
|
|
export function LogoutButton() {
|
|
const [open, setOpen] = useState(false)
|
|
const [pending, startTransition] = useTransition()
|
|
|
|
function confirm() {
|
|
startTransition(async () => {
|
|
await logoutAction()
|
|
})
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<Button
|
|
variant="outline"
|
|
onClick={() => setOpen(true)}
|
|
className="w-full justify-center gap-2"
|
|
>
|
|
<LogOut className="size-4" aria-hidden="true" />
|
|
Uitloggen
|
|
</Button>
|
|
<AlertDialog open={open} onOpenChange={setOpen}>
|
|
<AlertDialogContent size="sm">
|
|
<AlertDialogHeader>
|
|
<AlertDialogTitle>Uitloggen?</AlertDialogTitle>
|
|
<AlertDialogDescription>
|
|
Weet je zeker dat je wilt uitloggen?
|
|
</AlertDialogDescription>
|
|
</AlertDialogHeader>
|
|
<AlertDialogFooter>
|
|
<AlertDialogCancel onClick={() => setOpen(false)}>Annuleren</AlertDialogCancel>
|
|
<AlertDialogAction disabled={pending} onClick={confirm}>
|
|
{pending ? 'Bezig…' : 'Uitloggen'}
|
|
</AlertDialogAction>
|
|
</AlertDialogFooter>
|
|
</AlertDialogContent>
|
|
</AlertDialog>
|
|
</>
|
|
)
|
|
}
|