import { t } from '@i18next-toolkit/react'; import { Button, Form, Input, Modal, Table } from 'antd'; import React, { useMemo, useState } from 'react'; import { AppRouterOutput, trpc } from '../../api/trpc'; import { useCurrentWorkspaceId } from '../../store/user'; import { type ColumnsType } from 'antd/es/table/interface'; import { BarChartOutlined, EditOutlined, PlusOutlined, } from '@ant-design/icons'; import { useNavigate } from 'react-router'; import { PageHeader } from '../PageHeader'; import { useEvent } from '../../hooks/useEvent'; import { TelemetryCounter } from './TelemetryCounter'; type TelemetryInfo = AppRouterOutput['telemetry']['all'][number]; export const TelemetryList: React.FC = React.memo(() => { const workspaceId = useCurrentWorkspaceId(); const [isModalOpen, setIsModalOpen] = useState(false); const [form] = Form.useForm<{ id?: string; name: string }>(); const upsertTelemetryMutation = trpc.telemetry.upsert.useMutation(); const utils = trpc.useUtils(); const handleAddTelemetry = useEvent(async () => { await form.validateFields(); const values = form.getFieldsValue(); await upsertTelemetryMutation.mutateAsync({ telemetryId: values.id, workspaceId, name: values.name, }); utils.telemetry.all.refetch(); setIsModalOpen(false); form.resetFields(); }); const handleEditTelemetry = useEvent(async (info: TelemetryInfo) => { setIsModalOpen(true); form.setFieldsValue({ id: info.id, name: info.name, }); }); return (