Skip to content

Commit b0c2d34

Browse files
committed
feat: add refresh functionality to user usage modal with loading state indicator
1 parent cb0430b commit b0c2d34

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/widgets/dashboard/users/user-usage-modal/user-usage-modal.widget.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ import {
2020
Text,
2121
Tooltip
2222
} from '@mantine/core'
23-
import { TbChartBar as IconChartBar, TbChevronLeft, TbChevronRight } from 'react-icons/tb'
23+
import {
24+
TbChartBar as IconChartBar,
25+
TbChevronLeft,
26+
TbChevronRight,
27+
TbRefresh
28+
} from 'react-icons/tb'
2429
import { GetUserUsageByRangeCommand } from '@remnawave/backend-contract'
2530
import { PiEmpty, PiListBullets } from 'react-icons/pi'
2631
import { BarChart, Sparkline } from '@mantine/charts'
@@ -75,7 +80,12 @@ export const UserUsageModalWidget = (props: IProps) => {
7580
setDateRange([start, end])
7681
}, [period])
7782

78-
const { data: userUsage, isLoading } = useGetUserUsageByRange({
83+
const {
84+
data: userUsage,
85+
isLoading,
86+
refetch,
87+
isRefetching
88+
} = useGetUserUsageByRange({
7989
route: {
8090
uuid: userUuid
8191
},
@@ -522,6 +532,14 @@ export const UserUsageModalWidget = (props: IProps) => {
522532
value={period}
523533
w={{ base: 130 }}
524534
/>
535+
<ActionIcon
536+
loading={isRefetching}
537+
onClick={() => refetch()}
538+
size="input-sm"
539+
variant="subtle"
540+
>
541+
<TbRefresh size={20} />
542+
</ActionIcon>
525543
</Group>
526544

527545
<SimpleGrid cols={{ base: 1, sm: 2 }} spacing="md">

0 commit comments

Comments
 (0)