()
| 19 | import { useSelectedProject } from "~/utils/hooks"; |
| 20 | |
| 21 | const MonitorsTable = () => { |
| 22 | const project = useSelectedProject().data; |
| 23 | const { data: monitors, isLoading } = api.monitors.list.useQuery( |
| 24 | { |
| 25 | projectId: project?.id as string, |
| 26 | }, |
| 27 | { enabled: !!project?.id }, |
| 28 | ); |
| 29 | |
| 30 | return ( |
| 31 | <Card width="100%" overflowX="auto"> |
| 32 | <Skeleton isLoaded={!isLoading}> |
| 33 | {monitors?.length ? ( |
| 34 | <Table> |
| 35 | <Thead> |
| 36 | <Tr> |
| 37 | <Th>Name</Th> |
| 38 | <Th>Created At</Th> |
| 39 | <Th>Entries</Th> |
| 40 | <Th>Datasets</Th> |
| 41 | </Tr> |
| 42 | </Thead> |
| 43 | <Tbody> |
| 44 | {monitors.map((monitor) => { |
| 45 | return ( |
| 46 | <Tr key={monitor.id}> |
| 47 | <Td> |
| 48 | <ProjectLink href={{ pathname: "/monitors/[id]", query: { id: monitor.id } }}> |
| 49 | <Text color="blue.600">{monitor.name}</Text> |
| 50 | </ProjectLink> |
| 51 | </Td> |
| 52 | <Td>{dayjs(monitor.createdAt).format("MMMM D h:mm A")}</Td> |
| 53 | <Td>{monitor.numEntries?.toLocaleString()}</Td> |
| 54 | <Td>{monitor.numDatasets.toLocaleString()}</Td> |
| 55 | </Tr> |
| 56 | ); |
| 57 | })} |
| 58 | </Tbody> |
| 59 | </Table> |
| 60 | ) : ( |
| 61 | <VStack py={8}> |
| 62 | <Icon as={FaTable} boxSize={16} color="gray.300" /> |
| 63 | <Text color="gray.500" textAlign="center" w="full" p={4}> |
| 64 | This project has no monitors. Create a new one to get started. |
| 65 | </Text> |
| 66 | </VStack> |
| 67 | )} |
| 68 | </Skeleton> |
| 69 | </Card> |
| 70 | ); |
| 71 | }; |
| 72 | |
| 73 | export default MonitorsTable; |
nothing calls this directly
no test coverage detected