From 1ecb93801a612df55a227732050ac81e3b60219e Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 3 Jan 2022 14:35:59 +0100 Subject: [PATCH] feat(nui): RightBar data fetching --- ui/src/components/NavBars/LeftBar.tsx | 7 +------ ui/src/components/NavBars/RightBar.tsx | 15 +++++++++++---- ui/src/types/index.ts | 5 +++++ 3 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 ui/src/types/index.ts diff --git a/ui/src/components/NavBars/LeftBar.tsx b/ui/src/components/NavBars/LeftBar.tsx index 73f5c8d..596fed9 100644 --- a/ui/src/components/NavBars/LeftBar.tsx +++ b/ui/src/components/NavBars/LeftBar.tsx @@ -3,12 +3,7 @@ import { useState } from 'react'; import { Link } from 'react-router-dom'; import { useNuiEvent } from '../../hooks/useNuiEvent'; import { debugData } from '../../utils/debugData'; - -interface InitData { - resources: string[]; - totalQueries: number; - totalTime: number; -} +import type { InitData } from '../../types'; const LeftBar: React.FC = () => { debugData([ diff --git a/ui/src/components/NavBars/RightBar.tsx b/ui/src/components/NavBars/RightBar.tsx index d5a43ee..77d1194 100644 --- a/ui/src/components/NavBars/RightBar.tsx +++ b/ui/src/components/NavBars/RightBar.tsx @@ -1,14 +1,21 @@ -import React from 'react'; +import { useState } from 'react'; import { Box, VStack, Center } from '@chakra-ui/react'; +import { useNuiEvent } from '../../hooks/useNuiEvent'; +import type { InitData } from '../../types'; const RightBar: React.FC = () => { + const [initData, setInitData] = useState({ totalQueries: 0, totalTime: 0, resources: [''] }); + + // Debug data defined in LeftBar.tsx + + useNuiEvent('init', (data) => setInitData(data)); + return (
- Number of slow queries: 3 - Most active resource: essentialmode - Total number of queries: 732 + Total number of queries: {initData.totalQueries} + Total amount of time querying: {initData.totalTime}
diff --git a/ui/src/types/index.ts b/ui/src/types/index.ts new file mode 100644 index 0000000..0a37918 --- /dev/null +++ b/ui/src/types/index.ts @@ -0,0 +1,5 @@ +export type InitData = { + resources: string[]; + totalQueries: number; + totalTime: number; +} \ No newline at end of file