MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / BillingPage

Function BillingPage

apps/cloud/src/routes/app/billing.tsx:140–350  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

138}
139
140function BillingPage() {
141 const {
142 data: customer,
143 openCustomerPortal,
144 setupPayment,
145 refetch: refetchCustomer,
146 isLoading: customerLoading,
147 } = useCustomer({ expand: ["payment_method"] });
148 const { data: plans, isLoading: plansLoading } = useListPlans();
149 const card = cardOnFile(customer?.paymentMethod);
150 const cardUpdating = useRefreshAfterCardUpdate(card, refetchCustomer);
151 const [openingCardForm, setOpeningCardForm] = useState(false);
152
153 if (customerLoading || plansLoading) {
154 return (
155 <PageContainer>
156 <div className="mb-10">
157 <div className="h-8 w-28 animate-pulse rounded bg-muted" />
158 </div>
159 <div className="h-16 animate-pulse rounded-lg bg-muted" />
160 </PageContainer>
161 );
162 }
163
164 const allPlans: Plan[] = plans ?? [];
165 const activePlan = allPlans.find(
166 (p) => p.customerEligibility?.status === "active" && p.id !== "free",
167 );
168 const scheduledPlan = allPlans.find(
169 (p) => p.customerEligibility?.status === "scheduled" && p.id !== "free",
170 );
171 const isCanceling = activePlan?.customerEligibility?.canceling ?? false;
172 const isSwitching = isCanceling && scheduledPlan != null;
173 const isTrialing = activePlan?.customerEligibility?.trialing ?? false;
174
175 const displayPlan = isSwitching ? scheduledPlan : activePlan;
176 const planId = displayPlan?.id ?? "free";
177 const planName = displayPlan?.name ?? "Free";
178 const tagline = PLAN_TAGLINES[planId] ?? "";
179
180 const sub = customer?.subscriptions?.find(
181 (s) =>
182 s.planId === (activePlan?.id ?? "free") && (s.status === "active" || s.status === "trialing"),
183 );
184
185 const executions = customer?.balances?.executions;
186 const members = customer?.balances?.members;
187
188 return (
189 <PageContainer>
190 <PageHeader title="Billing" />
191
192 {/* Current plan */}
193 <div className="flex items-center justify-between py-4">
194 <div>
195 <div className="flex items-center gap-2">
196 <p className="text-sm font-medium text-foreground leading-none">{planName}</p>
197 {isSwitching && <Badge className="bg-muted text-muted-foreground">Switching</Badge>}

Callers

nothing calls this directly

Calls 6

trackEventFunction · 0.90
cardOnFileFunction · 0.85
cardBrandLabelFunction · 0.85
returnToFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected