"use client" import { useState } from "react" import { Sheet, SheetContent, SheetHeader, SheetTitle } from "@/components/ui/sheet" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import { UserForm } from "./user-form" import { Button } from "@/components/ui/button" import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog" import { Mail, ShieldAlert, Trash2, Ban } from "lucide-react" import { User } from "./column" import { toast } from "@/hooks/use-toast" interface UserDetailSheetProps { user: User open: boolean onOpenChange: (open: boolean) => void } export function UserDetailSheet({ user, open, onOpenChange }: UserDetailSheetProps) { const [isDeleting, setIsDeleting] = useState(false) const [isResetting, setIsResetting] = useState(false) const [isSendingMagic, setIsSendingMagic] = useState(false) const [isRemovingMfa, setIsRemovingMfa] = useState(false) const [isBanning, setIsBanning] = useState(false) const handleResetPassword = async () => { try { setIsResetting(true) toast({ title: "Success", description: "Password reset email sent", }) } catch (error) { toast({ title: "Error", description: "Failed to send reset password email", variant: "destructive", }) console.error(error) } finally { setIsResetting(false) } } const handleSendMagicLink = async () => { try { setIsSendingMagic(true) toast({ title: "Success", description: "Magic link sent", }) } catch (error) { toast({ title: "Error", description: "Failed to send magic link", variant: "destructive", }) console.error(error) } finally { setIsSendingMagic(false) } } const handleRemoveMfa = async () => { try { setIsRemovingMfa(true) await removeMfaFactors(user.id) toast({ title: "Success", description: "MFA factors removed", }) } catch (error) { toast({ title: "Error", description: "Failed to remove MFA factors", variant: "destructive", }) console.error(error) } finally { setIsRemovingMfa(false) } } const handleBanUser = async () => { try { setIsBanning(true) await banUser(user.id) toast({ title: "Success", description: "User banned successfully", }) } catch (error) { toast({ title: "Error", description: "Failed to ban user", variant: "destructive", }) console.error(error) } finally { setIsBanning(false) } } const handleDeleteUser = async () => { try { setIsDeleting(true) await deleteUser(user.id) toast({ title: "Success", description: "User deleted successfully", }) onOpenChange(false) } catch (error) { toast({ title: "Error", description: "Failed to delete user", variant: "destructive", }) console.error(error) } finally { setIsDeleting(false) } } return ( User Details

{user.email}

ID: {user.id}

Details Profile Security

Profile Information

Profile data will be loaded here.

Reset password

Send a password recovery email to the user

Send magic link

Passwordless login via email for the user

Danger zone

Be wary of the following features as they cannot be undone.

Remove MFA factors

This will log the user out of all active sessions

Ban user

Revoke access to the project for a set duration

Delete user

User will no longer have access to the project

Are you absolutely sure? This action cannot be undone. This will permanently delete the user account and remove their data from our servers. Cancel Delete
) }