'use client'
import {Button} from '@/components/ui/button'
import {Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger} from '@/components/ui/dialog'
import {useState} from 'react'
import Link from 'next/link'
interface RealnameAuthDialogProps {
  triggerClassName?: string
  open?: boolean
  defaultOpen?: boolean
  onOpenChange?: (open: boolean) => void
  onSuccess?: () => void
}

export function RealnameAuthDialog({
  triggerClassName,
  open,
  defaultOpen,
  onOpenChange,
}: RealnameAuthDialogProps) {
  const [internalOpen, setInternalOpen] = useState(defaultOpen || false)

  const actualOpen = open !== undefined ? open : internalOpen
  const actualOnOpenChange = onOpenChange || setInternalOpen

  return (
    <Dialog open={actualOpen} onOpenChange={actualOnOpenChange}>
      <DialogTrigger asChild>
        <Button theme="outline" className={triggerClassName || 'w-24'}>
          去认证
        </Button>
      </DialogTrigger>
      <DialogContent>
        <DialogHeader>
          <DialogTitle>实名认证</DialogTitle>
        </DialogHeader>
        <div className="py-4 space-y-4">
          <p>为了保障您的账户安全和正常使用服务，请您尽快完成实名认证</p>
          <div className="flex justify-end gap-2">
            <Button
              theme="outline"
              onClick={() => actualOnOpenChange(false)}
            >
              稍后再说
            </Button>
            <Link href="/admin/identify"><Button onClick={() => actualOnOpenChange(false)}>立即认证</Button></Link>
          </div>
        </div>
      </DialogContent>
    </Dialog>
  )
}
