返回 AiToEarn
AgentTestingNoticeDialog.tsx
根目录 / project / aitoearn-web / src / components / Chat / ChatInput / AgentTestingNoticeDialog.tsx
1 /**
2 * AgentTestingNoticeDialog - Agent 测试阶段提示弹窗
3 * 功能:在 Chat 提交前提示测试阶段风险,并支持不再提示
4 */
5
6 'use client'
7
8 import { useEffect, useId, useState } from 'react'
9 import { useTransClient } from '@/app/i18n/client'
10 import {
11 AlertDialog,
12 AlertDialogAction,
13 AlertDialogCancel,
14 AlertDialogContent,
15 AlertDialogDescription,
16 AlertDialogFooter,
17 AlertDialogHeader,
18 AlertDialogTitle,
19 } from '@/components/ui/alert-dialog'
20 import { Checkbox } from '@/components/ui/checkbox'
21
22 interface AgentTestingNoticeDialogProps {
23 open: boolean
24 onOpenChange: (open: boolean) => void
25 onConfirm: (doNotShowAgain: boolean) => void
26 }
27
28 export function AgentTestingNoticeDialog({
29 open,
30 onOpenChange,
31 onConfirm,
32 }: AgentTestingNoticeDialogProps) {
33 const { t } = useTransClient('chat')
34 const checkboxId = useId()
35 const [doNotShowAgain, setDoNotShowAgain] = useState(false)
36
37 useEffect(() => {
38 if (open) {
39 setDoNotShowAgain(false)
40 }
41 }, [open])
42
43 return (
44 <AlertDialog open={open} onOpenChange={onOpenChange}>
45 <AlertDialogContent className="min-h-0 max-w-[520px]">
46 <AlertDialogHeader>
47 <AlertDialogTitle className="text-foreground">
48 {t('agentNotice.title')}
49 </AlertDialogTitle>
50 <AlertDialogDescription className="text-sm leading-6 text-muted-foreground">
51 {t('agentNotice.description')}
52 </AlertDialogDescription>
53 </AlertDialogHeader>
54
55 <label
56 htmlFor={checkboxId}
57 className="flex cursor-pointer items-center gap-2 rounded-md border border-border bg-muted/40 px-3 py-2 text-sm text-foreground"
58 >
59 <Checkbox
60 id={checkboxId}
61 checked={doNotShowAgain}
62 onCheckedChange={checked => setDoNotShowAgain(checked === true)}
63 />
64 <span>{t('agentNotice.doNotShowAgain')}</span>
65 </label>
66
67 <AlertDialogFooter>
68 <AlertDialogCancel>{t('agentNotice.cancel')}</AlertDialogCancel>
69 <AlertDialogAction onClick={() => onConfirm(doNotShowAgain)}>
70 {t('agentNotice.confirm')}
71 </AlertDialogAction>
72 </AlertDialogFooter>
73 </AlertDialogContent>
74 </AlertDialog>
75 )
76 }
77
77 lines Plain Text