Copilot commented on code in PR #3012:
URL: https://github.com/apache/apisix-dashboard/pull/3012#discussion_r2074799701
##########
src/routes/services/index.tsx:
##########
@@ -1,9 +1,135 @@
+import { queryClient } from '@/config/global';
+import { useSuspenseQuery } from '@tanstack/react-query';
import { createFileRoute } from '@tanstack/react-router';
+import { useTranslation } from 'react-i18next';
+import type { APISIXType } from '@/types/schema/apisix';
+import { ProTable } from '@ant-design/pro-components';
+import type { ProColumns } from '@ant-design/pro-components';
+import { useEffect, useMemo } from 'react';
+import { ToDetailPageBtn, ToAddPageBtn } from '@/components/page/ToAddPageBtn';
+import { pageSearchSchema } from '@/types/schema/pageSearch';
+import { getServiceListQueryOptions } from '@/apis/services';
+import { usePagination } from '@/utils/usePagination';
+import { AntdConfigProvider } from '@/config/antdConfigProvider';
+import PageHeader from '@/components/page/PageHeader';
-export const Route = createFileRoute('/services/')({
- component: RouteComponent,
-});
+const ServiceList = () => {
+ const { pagination, handlePageChange, updateTotal } = usePagination({
+ queryKey: 'services',
+ });
+
+ const query = useSuspenseQuery(getServiceListQueryOptions(pagination));
+ const { data, isLoading } = query;
+ const { t } = useTranslation();
+
+ useEffect(() => {
+ if (data?.total) {
+ updateTotal(data.total);
+ }
+ }, [data?.total, updateTotal]);
+
+ const columns = useMemo<ProColumns<APISIXType['RespServiceItem']>[]>(() => {
+ return [
+ {
+ dataIndex: ['value', 'id'],
+ title: 'ID',
+ key: 'id',
+ valueType: 'text',
+ },
+ {
+ dataIndex: ['value', 'name'],
+ title: t('form.basic.name'),
+ key: 'name',
+ valueType: 'text',
+ },
+ {
+ dataIndex: ['value', 'desc'],
+ title: t('form.basic.desc'),
+ key: 'desc',
+ valueType: 'text',
+ },
+ {
+ dataIndex: ['value', 'update_time'],
+ title: t('form.info.update_time'),
+ key: 'update_time',
+ valueType: 'dateTime',
+ sorter: true,
+ renderText: (text) => {
+ if (!text) return '-';
+ return new Date(Number(text) * 1000).toISOString();
Review Comment:
Consider adding a check to ensure that Number(text) is not NaN before
converting to a date, for example by using isNaN(Number(text)) and providing an
appropriate fallback.
```suggestion
const numericValue = Number(text);
if (!text || isNaN(numericValue)) return '-';
return new Date(numericValue * 1000).toISOString();
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]