Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add licensed user data to the licensed users box #8868

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions frontend/src/component/admin/users/UsersHeader/LicensedUsersBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Box, styled } from '@mui/material';
import { HelpIcon } from 'component/common/HelpIcon/HelpIcon';
import { useState } from 'react';
import { LicensedUsersSidebar } from './LicensedUsersSidebar';
import { useLicensedUsers } from 'hooks/useLicensedUsers';
import useLoading from 'hooks/useLoading';

const StyledButton = styled('button')(({ theme }) => ({
background: 'none',
Expand Down Expand Up @@ -40,12 +42,35 @@ const MainMetric = styled('span')(({ theme }) => ({
fontWeight: 'bold',
}));

export const LicensedUsersBox = () => {
const OpenSidebarButton = () => {
const [licensedUsersChartOpen, setLicensedUsersChartOpen] = useState(false);

return (
<Figure>
<>
<StyledButton
onClick={() => {
setLicensedUsersChartOpen(true);
}}
>
View graph over time
</StyledButton>
<LicensedUsersSidebar
open={licensedUsersChartOpen}
close={() => setLicensedUsersChartOpen(false)}
/>
</>
);
};

export const LicensedUsersBox = () => {
const { data, loading } = useLicensedUsers();
const ref = useLoading(loading, '[data-loading-licensed-users=true]');
return (
<Figure ref={ref}>
<TopRow>
<MainMetric>11/25</MainMetric>
<MainMetric data-loading-licensed-users>
{data.licensedUsers.current}/{data.seatCount}
</MainMetric>
<HelpIcon
htmlTooltip
tooltip={
Expand All @@ -60,18 +85,8 @@ export const LicensedUsersBox = () => {

<StyledCaption>
<span>Seats used in the last 30 days</span>
<StyledButton
onClick={() => {
setLicensedUsersChartOpen(true);
}}
>
View graph over time
</StyledButton>
<OpenSidebarButton />
</StyledCaption>
<LicensedUsersSidebar
open={licensedUsersChartOpen}
close={() => setLicensedUsersChartOpen(false)}
/>
</Figure>
);
};
Loading