feat(nui): RightBar data fetching

This commit is contained in:
Luke committed 2022-01-03 14:35:59 +01:00
1 parent ae121fd01c
commit 1ecb93801a
3 files changed
+17 -10

No files matched your search

+1 -6
View File
@@ -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([
+11 -4
View File
@@ -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<InitData>({ totalQueries: 0, totalTime: 0, resources: [''] });
// Debug data defined in LeftBar.tsx
useNuiEvent<InitData>('init', (data) => setInitData(data));
return (
<Box float="right" w="20%" h="max" p="1.2vh">
<Center>
<VStack align="left">
<Box>Number of slow queries: 3</Box>
<Box>Most active resource: essentialmode</Box>
<Box>Total number of queries: 732</Box>
<Box>Total number of queries: {initData.totalQueries}</Box>
<Box>Total amount of time querying: {initData.totalTime}</Box>
</VStack>
</Center>
</Box>
+5
View File
@@ -0,0 +1,5 @@
export type InitData = {
resources: string[];
totalQueries: number;
totalTime: number;
}