Files
web/src/components/composites/dialogs/realname-auth-dialog.tsx

66 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use client'
import {Button} from '@/components/ui/button'
import {Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger} from '@/components/ui/dialog'
import {useRouter} from 'next/navigation'
import {useState} from 'react'
interface RealnameAuthDialogProps {
hasAuthenticated: boolean
triggerClassName?: string
open?: boolean
onOpenChange?: (open: boolean) => void
onSuccess?: () => void
}
export function RealnameAuthDialog({
hasAuthenticated,
triggerClassName,
open,
onOpenChange,
onSuccess,
}: RealnameAuthDialogProps) {
const [internalOpen, setInternalOpen] = useState(false)
const router = useRouter()
const actualOpen = open !== undefined ? open : internalOpen
const actualOnOpenChange = onOpenChange || setInternalOpen
if (hasAuthenticated) {
return null
}
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>
<Button
onClick={() => {
router.push('/admin/identify')
onSuccess?.()
}}
>
</Button>
</div>
</div>
</DialogContent>
</Dialog>
)
}