Skip to content

Commit 4d7695b

Browse files
geroplroboquat
authored andcommitted
[dashboard] Fix BillingMode UI glitches
1 parent 2d2c70f commit 4d7695b

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

components/dashboard/src/Menu.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,6 @@ export default function Menu() {
152152
server.isStudent().then((v) => () => setIsStudent(v)),
153153
server.isChargebeeCustomer().then((v) => () => setIsChargebeeCustomer(v)),
154154
]).then((setters) => setters.forEach((s) => s()));
155-
156-
// Refresh billing mode
157-
refreshUserBillingMode();
158155
}, []);
159156

160157
useEffect(() => {
@@ -163,6 +160,11 @@ export default function Menu() {
163160
}
164161
}, [team]);
165162

163+
useEffect(() => {
164+
// Refresh billing mode
165+
refreshUserBillingMode();
166+
}, [teams]);
167+
166168
const teamOrUserSlug = !!team ? "/t/" + team.slug : "/projects";
167169
const leftMenu: Entry[] = (() => {
168170
// Project menu

components/dashboard/src/teams/TeamBilling.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { UserContext } from "../user-context";
2828
type PendingPlan = Plan & { pendingSince: number };
2929

3030
export default function TeamBilling() {
31-
const { user, userBillingMode } = useContext(UserContext);
31+
const { user } = useContext(UserContext);
3232
const { teams } = useContext(TeamsContext);
3333
const location = useLocation();
3434
const team = getCurrentTeam(location, teams);
@@ -308,15 +308,23 @@ export default function TeamBilling() {
308308
);
309309
}
310310

311-
const showUBP = BillingMode.showUsageBasedBilling(userBillingMode);
311+
const showUBP = BillingMode.showUsageBasedBilling(teamBillingMode);
312312
return (
313313
<PageWithSubMenu
314314
subMenu={getTeamSettingsMenu({ team, billingMode: teamBillingMode })}
315315
title="Billing"
316316
subtitle="Manage team billing and plans."
317317
>
318-
{showUBP && <TeamUsageBasedBilling />}
319-
{!showUBP && renderTeamBilling()}
318+
{teamBillingMode === undefined ? (
319+
<div className="p-20">
320+
<Spinner className="h-5 w-5 animate-spin" />
321+
</div>
322+
) : (
323+
<>
324+
{showUBP && <TeamUsageBasedBilling />}
325+
{!showUBP && renderTeamBilling()}
326+
</>
327+
)}
320328
</PageWithSubMenu>
321329
);
322330
}

0 commit comments

Comments
 (0)