sarlink-portal/components/auth/account-popver.tsx
i701 9021f01ff4 Add Agreements page, enhance Devices and Users components with sorting and filtering options, and implement user verification dialogs
- Introduced a new Agreements page for managing agreements in the dashboard.
- Enhanced the Devices page by adding sorting and filtering options for better device management.
- Updated the Users page to include sorting functionality and improved layout.
- Implemented user verification and rejection dialogs for better user management.
- Added InputReadOnly component for displaying user information in a read-only format.
- Refactored search component to improve usability and visual consistency.
2024-12-01 23:19:31 +05:00

57 lines
1.6 KiB
TypeScript

'use client'
import { Button } from "@/components/ui/button"
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover"
import { authClient } from "@/lib/auth-client";
import { Loader2, User as UserIcon } from "lucide-react"
import { useRouter } from "next/navigation"
import { useState } from "react"
export function AccountPopover() {
const session = authClient.useSession();
const [loading, setLoading] = useState(false)
const router = useRouter()
if (session.isPending) {
<Button variant={"outline"} disabled>
<Loader2 className="animate-spin" />
</Button>
}
return (
<Popover>
<PopoverTrigger asChild>
<Button variant="outline">
<UserIcon />
</Button>
</PopoverTrigger>
<PopoverContent className="w-fit">
<div className="grid gap-4">
<div className="space-y-2">
<h4 className="font-medium leading-none">{session.data?.user?.name}</h4>
<p className="text-sm text-muted-foreground">
{session.data?.user?.phoneNumber}
</p>
</div>
<Button disabled={loading} onClick={async () => {
setLoading(true)
await authClient.signOut({
fetchOptions: {
onSuccess: () => {
router.push("/login"); // redirect to login page
},
},
})
setLoading(false)
}}>
{loading ? <Loader2 className="animate-spin" /> : "Logout"}
</Button>
</div>
</PopoverContent>
</Popover>
)
}