Skip to content

Commit 71d2f81

Browse files
committed
[dashboard] In Team Billing, if UBP flag is on but you still have an active Chargebee team plan, also nudge towards cancelling
1 parent 3dec626 commit 71d2f81

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

components/dashboard/src/teams/TeamBilling.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import TeamUsageBasedBilling from "./TeamUsageBasedBilling";
2626
import { UserContext } from "../user-context";
2727
import { FeatureFlagContext } from "../contexts/FeatureFlagContext";
2828
import { publicApiTeamMembersToProtocol, teamsService } from "../service/public-api";
29+
import Alert from "../components/Alert";
30+
import { getExperimentsClient } from "../experiments/client";
2931

3032
type PendingPlan = Plan & { pendingSince: number };
3133

@@ -38,6 +40,7 @@ export default function TeamBilling() {
3840
const [isUserOwner, setIsUserOwner] = useState(true);
3941
const [teamSubscription, setTeamSubscription] = useState<TeamSubscription2 | undefined>();
4042
const { currency, setCurrency } = useContext(PaymentContext);
43+
const [isUsageBasedBillingEnabled, setIsUsageBasedBillingEnabled] = useState<boolean>(false);
4144
const [teamBillingMode, setTeamBillingMode] = useState<BillingMode | undefined>(undefined);
4245
const [pendingTeamPlan, setPendingTeamPlan] = useState<PendingPlan | undefined>();
4346
const [pollTeamSubscriptionTimeout, setPollTeamSubscriptionTimeout] = useState<NodeJS.Timeout | undefined>();
@@ -114,6 +117,20 @@ export default function TeamBilling() {
114117
};
115118
}, [pendingTeamPlan, pollTeamSubscriptionTimeout, team, teamSubscription]);
116119

120+
useEffect(() => {
121+
if (!team || !user) {
122+
return;
123+
}
124+
(async () => {
125+
const isEnabled = await getExperimentsClient().getValueAsync("isUsageBasedBillingEnabled", false, {
126+
user,
127+
teamId: team.id,
128+
teamName: team.name,
129+
});
130+
setIsUsageBasedBillingEnabled(isEnabled);
131+
})();
132+
}, [team, user]);
133+
117134
const availableTeamPlans = Plans.getAvailableTeamPlans(currency || "USD").filter((p) => p.type !== "student");
118135

119136
const checkout = async (plan: Plan) => {
@@ -161,6 +178,20 @@ export default function TeamBilling() {
161178
function renderTeamBilling(): JSX.Element {
162179
return (
163180
<>
181+
{isUsageBasedBillingEnabled && (
182+
<Alert type="message" className="mb-4">
183+
To access{" "}
184+
<a className="gp-link" href="https://www.gitpod.io/docs/configure/workspaces/workspace-classes">
185+
large workspaces
186+
</a>{" "}
187+
and{" "}
188+
<a className="gp-link" href="https://www.gitpod.io/docs/configure/billing/pay-as-you-go">
189+
pay-as-you-go
190+
</a>
191+
, first cancel your existing plan. Existing plans will keep working until the end of March,
192+
2023.
193+
</Alert>
194+
)}
164195
<h3>{!teamPlan ? "Select Team Plan" : "Team Plan"}</h3>
165196
<h2 className="text-gray-500">
166197
{!teamPlan ? (

0 commit comments

Comments
 (0)