Skip to content

Commit c3a8a1e

Browse files
committed
fix(hub): invalidate billing calculation after chagning the billing plan (#2547)
<!-- Please make sure there is an issue that this PR is correlated to. --> ## Changes <!-- If there are frontend changes, please include screenshots. -->
1 parent 5ba15dd commit c3a8a1e

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

frontend/apps/hub/src/domains/project/components/dialogs/change-plan-dialog.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ import { useProject } from "../../data/project-context";
1616
interface ContentProps extends DialogContentProps {}
1717

1818
export default function ChangePlanDialogContent({ onClose }: ContentProps) {
19-
const { gameId: projectId } = useProject();
19+
const {
20+
gameId: projectId,
21+
developer: { groupId },
22+
} = useProject();
2023
const [plan, setPlan] = useState<Rivet.ee.billing.Plan | null>(null);
2124

2225
const { mutate, isPending } = useUpdateProjectBillingMutation({
@@ -46,7 +49,7 @@ export default function ChangePlanDialogContent({ onClose }: ContentProps) {
4649
<Button
4750
isLoading={isPending}
4851
onClick={() => {
49-
mutate({ plan, projectId });
52+
mutate({ plan, projectId, groupId });
5053
}}
5154
>
5255
Confirm

frontend/apps/hub/src/domains/project/queries/billing/mutations.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { queryClient, rivetEeClient } from "@/queries/global";
22
import type { Rivet as RivetEe } from "@rivet-gg/api-ee";
33
import { useMutation } from "@tanstack/react-query";
44
import { projectBillingQueryOptions } from "../billing/query-options";
5+
import { projectAggregateBillingQueryOptions } from "../query-options";
56

67
export const useUpdateProjectBillingMutation = ({
78
onSuccess,
@@ -13,6 +14,7 @@ export const useUpdateProjectBillingMutation = ({
1314
projectId,
1415
plan,
1516
}: {
17+
groupId: string;
1618
projectId: string;
1719
} & RivetEe.ee.cloud.games.billing.UpdatePlanRequest) =>
1820
rivetEeClient.ee.cloud.games.billing.updatePlan(projectId, {
@@ -22,7 +24,15 @@ export const useUpdateProjectBillingMutation = ({
2224
await queryClient.invalidateQueries(
2325
projectBillingQueryOptions(values.projectId),
2426
);
27+
await queryClient.invalidateQueries({
28+
...projectAggregateBillingQueryOptions({
29+
projectId: values.projectId,
30+
projectNameId: values.projectId,
31+
groupId: values.groupId,
32+
}),
33+
refetchType: "all",
34+
});
2535
onSuccess?.();
2636
},
2737
});
28-
};
38+
};

0 commit comments

Comments
 (0)