Skip to content

Commit

Permalink
convert showdata to a react component
Browse files Browse the repository at this point in the history
  • Loading branch information
Aliiiu committed Jan 14, 2025
1 parent b5b9a39 commit 6d66d6b
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/components/client/StatsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ type Stat = {
icon?: (props: IconProps) => JSX.Element
}

const showData = (
value: Stat['value'],
prefix?: string,
isFetched?: boolean,
) => {
const ShowData = ({
value,
prefix,
isFetched,
}: {
value: number | undefined
prefix?: string
isFetched?: boolean
}) => {
if (value === undefined && !isFetched) {
return (
<Spinner variant="primary" role="status" size="sm">
Expand Down Expand Up @@ -166,14 +170,20 @@ const StatsPage = () => {
fontSize={{ base: 'sm', md: 'md' }}
fontWeight="semibold"
>
{isFailedToFetchData
? '-'
: showData(item.value, valuePrefix, isFetched)}
{isFailedToFetchData ? (
'-'
) : (
<ShowData
value={item.value || 0}
prefix={valuePrefix}
isFetched={isFetched}
/>
)}
</Text>
</Flex>
)
})}
</Stack>
</Stack>{' '}
</Flex>
)
})}
Expand Down

0 comments on commit 6d66d6b

Please sign in to comment.