@@ -4,6 +4,7 @@ import { Card, Descriptions, Badge, Button, Spin, Typography, message, Space, Mo
44import { ArrowLeftOutlined , CheckCircleOutlined , CloseCircleOutlined } from '@ant-design/icons' ;
55import dayjs from 'dayjs' ;
66import { getAgent , approveAgent , rejectAgent } from '../../api/agents' ;
7+ import { useLocale } from '../../hooks/useLocale' ;
78
89const { Title } = Typography ;
910
@@ -17,6 +18,7 @@ export default function AgentDetailPage() {
1718 const { id } = useParams < { id : string } > ( ) ;
1819 const navigate = useNavigate ( ) ;
1920 const queryClient = useQueryClient ( ) ;
21+ const { t } = useLocale ( ) ;
2022
2123 const { data : agent , isLoading, error } = useQuery ( {
2224 queryKey : [ 'agent' , id ] ,
@@ -27,32 +29,32 @@ export default function AgentDetailPage() {
2729 const approveMutation = useMutation ( {
2830 mutationFn : ( ) => approveAgent ( id ! ) ,
2931 onSuccess : ( ) => {
30- message . success ( 'Agent approved' ) ;
32+ message . success ( t ( 'agents.approveSuccess' ) ) ;
3133 queryClient . invalidateQueries ( { queryKey : [ 'agent' , id ] } ) ;
3234 } ,
3335 onError : ( ) => {
34- message . error ( 'Failed to approve agent' ) ;
36+ message . error ( t ( 'agents.approveFailed' ) ) ;
3537 } ,
3638 } ) ;
3739
3840 const rejectMutation = useMutation ( {
3941 mutationFn : ( ) => rejectAgent ( id ! ) ,
4042 onSuccess : ( ) => {
41- message . success ( 'Agent rejected') ;
43+ message . success ( t ( 'agents. rejected') ) ;
4244 navigate ( '/agents' ) ;
4345 } ,
4446 onError : ( ) => {
45- message . error ( 'Failed to reject agent' ) ;
47+ message . error ( t ( 'agents.rejectFailed' ) ) ;
4648 } ,
4749 } ) ;
4850
4951 const showRejectConfirm = ( ) => {
5052 Modal . confirm ( {
51- title : 'Reject Agent' ,
52- content : 'Are you sure you want to reject this agent?' ,
53- okText : 'Confirm' ,
53+ title : t ( 'agents.rejectTitle' ) ,
54+ content : t ( 'agents.rejectConfirmDetail' ) ,
55+ okText : t ( 'common.confirm' ) ,
5456 okType : 'danger' ,
55- cancelText : 'Cancel' ,
57+ cancelText : t ( 'common.cancel' ) ,
5658 onOk : ( ) => rejectMutation . mutate ( ) ,
5759 } ) ;
5860 } ;
@@ -65,9 +67,9 @@ export default function AgentDetailPage() {
6567 return (
6668 < Card >
6769 < div style = { { textAlign : 'center' , padding : 48 } } >
68- < Typography . Text type = "danger" > Failed to load agent details. </ Typography . Text >
70+ < Typography . Text type = "danger" > { t ( 'agents.loadDetailFailed' ) } </ Typography . Text >
6971 < br /> < br />
70- < Button onClick = { ( ) => navigate ( '/agents' ) } > Back to Agents </ Button >
72+ < Button onClick = { ( ) => navigate ( '/agents' ) } > { t ( 'agents.backToList' ) } </ Button >
7173 </ div >
7274 </ Card >
7375 ) ;
@@ -77,7 +79,7 @@ export default function AgentDetailPage() {
7779 < div >
7880 < Space style = { { marginBottom : 16 } } >
7981 < Button icon = { < ArrowLeftOutlined /> } onClick = { ( ) => navigate ( '/agents' ) } >
80- Back
82+ { t ( 'agents.back' ) }
8183 </ Button >
8284 </ Space >
8385
@@ -94,7 +96,7 @@ export default function AgentDetailPage() {
9496 onClick = { ( ) => approveMutation . mutate ( ) }
9597 loading = { approveMutation . isPending }
9698 >
97- Approve Agent
99+ { t ( 'agents.approve' ) }
98100 </ Button >
99101 { ! agent . approved && (
100102 < Button
@@ -103,25 +105,25 @@ export default function AgentDetailPage() {
103105 onClick = { showRejectConfirm }
104106 loading = { rejectMutation . isPending }
105107 >
106- Reject Agent
108+ { t ( 'agents.rejectTitle' ) }
107109 </ Button >
108110 ) }
109111 </ Space >
110112 </ div >
111113
112114 < Descriptions bordered column = { 1 } >
113- < Descriptions . Item label = "ID" > { agent . id } </ Descriptions . Item >
114- < Descriptions . Item label = "Hostname" > { agent . hostname } </ Descriptions . Item >
115- < Descriptions . Item label = "MySQL Version" >
115+ < Descriptions . Item label = { t ( 'agents.id' ) } > { agent . id } </ Descriptions . Item >
116+ < Descriptions . Item label = { t ( 'agents.hostname' ) } > { agent . hostname } </ Descriptions . Item >
117+ < Descriptions . Item label = { t ( 'agents.mysqlVersion' ) } >
116118 { agent . mySQLVersion || '-' }
117119 </ Descriptions . Item >
118- < Descriptions . Item label = "Status" >
120+ < Descriptions . Item label = { t ( 'agents.status' ) } >
119121 < Badge status = { statusBadge [ agent . status ] } text = { agent . status } />
120122 </ Descriptions . Item >
121- < Descriptions . Item label = "Last Seen" >
123+ < Descriptions . Item label = { t ( 'agents.lastSeen' ) } >
122124 { agent . lastSeen ? dayjs ( agent . lastSeen ) . format ( 'YYYY-MM-DD HH:mm:ss' ) : '-' }
123125 </ Descriptions . Item >
124- < Descriptions . Item label = "Created At" >
126+ < Descriptions . Item label = { t ( 'agents.created' ) } >
125127 { dayjs ( agent . createdAt ) . format ( 'YYYY-MM-DD HH:mm:ss' ) }
126128 </ Descriptions . Item >
127129 </ Descriptions >
0 commit comments