Skip to content

Commit 2319486

Browse files
chore(site): replace deployment stats service by react-query (#9698)
1 parent 5a22f08 commit 2319486

File tree

3 files changed

+13
-66
lines changed

3 files changed

+13
-66
lines changed

site/src/api/queries/deployment.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@ export const deploymentDAUs = () => {
1313
queryFn: () => API.getDeploymentDAUs(),
1414
};
1515
};
16+
17+
export const deploymentStats = () => {
18+
return {
19+
queryKey: ["deployment", "stats"],
20+
queryFn: () => API.getDeploymentStats(),
21+
};
22+
};
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { useMachine } from "@xstate/react";
21
import { usePermissions } from "hooks/usePermissions";
32
import { DeploymentBannerView } from "./DeploymentBannerView";
4-
import { deploymentStatsMachine } from "xServices/deploymentStats/deploymentStatsMachine";
3+
import { useQuery } from "@tanstack/react-query";
4+
import { deploymentStats } from "api/queries/deployment";
55

66
export const DeploymentBanner: React.FC = () => {
77
const permissions = usePermissions();
8-
const [state, sendEvent] = useMachine(deploymentStatsMachine);
8+
const deploymentStatsQuery = useQuery(deploymentStats());
99

10-
if (!permissions.viewDeploymentValues || !state.context.deploymentStats) {
10+
if (!permissions.viewDeploymentValues || !deploymentStatsQuery.data) {
1111
return null;
1212
}
1313

1414
return (
1515
<DeploymentBannerView
16-
stats={state.context.deploymentStats}
17-
fetchStats={() => sendEvent("RELOAD")}
16+
stats={deploymentStatsQuery.data}
17+
fetchStats={() => deploymentStatsQuery.refetch()}
1818
/>
1919
);
2020
};

site/src/xServices/deploymentStats/deploymentStatsMachine.ts

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)