Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
refactor(billing): standardize loading state handling across components
Victor Hugo dos Santosdb6fc9374be4
diff --git a/frontend/src/pages/organization/BillingV2Page/BillingV2Page.tsx b/frontend/src/pages/organization/BillingV2Page/BillingV2Page.tsxindex c902186e0a..0731459607 100644--- a/frontend/src/pages/organization/BillingV2Page/BillingV2Page.tsx+++ b/frontend/src/pages/organization/BillingV2Page/BillingV2Page.tsx@@ -156,7 +156,7 @@ export const BillingV2Page = () => {const isViewingOtherOrg = selectedOrgId !== orgId;const canManageBilling = hasManageBillingPermission && !isViewingOtherOrg;- const isReloadingProducts = useHeldLoading(isPlaceholderData);+ const isReloading = useHeldLoading(isPlaceholderData && !isError);let subState: BillingV2RenderState = "loading";if (isError) {@@ -261,7 +261,7 @@ export const BillingV2Page = () => {rootOrgs={pickerOrgs}rootOrgCount={rootOrgCount}isRootOrgsLoading={isOrgSearchPending}- isReloadingProducts={isReloadingProducts}+ isReloading={isReloading}selectedOrgId={breakdownScope === "instance" ? ALL_ORGS_VALUE : selectedOrgId}onSelectOrg={(nextId) => {if (nextId === ALL_ORGS_VALUE) {diff --git a/frontend/src/pages/organization/BillingV2Page/components/Overview.tsx b/frontend/src/pages/organization/BillingV2Page/components/Overview.tsxindex d123ddebbd..3c2ad51b7f 100644--- a/frontend/src/pages/organization/BillingV2Page/components/Overview.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/Overview.tsx@@ -28,7 +28,7 @@ export type OverviewProps = {rootOrgs: BillingV2Organization[];rootOrgCount: number;isRootOrgsLoading: boolean;- isReloadingProducts: boolean;+ isReloading: boolean;selectedOrgId: string;onSelectOrg: (orgId: string) => void;onSearchOrgs: (search: string) => void;@@ -52,7 +52,7 @@ export const Overview = ({rootOrgs,rootOrgCount,isRootOrgsLoading,- isReloadingProducts,+ isReloading,selectedOrgId,onSelectOrg,onSearchOrgs,@@ -74,21 +74,23 @@ export const Overview = ({/>) : null;- if (subState === "loading") {+ if (subState === "loading" || isReloading) {return (<div className="flex flex-col gap-4"><StatTilesSkeleton /><ProductsCardkey="products"+ overview={overview}catalog={catalog}readOnlyorgFilter={orgFilter}+ isReloadingonManage={onUpgrade}onSetCommitment={onSetCommitment}onViewBreakdown={onViewBreakdown}onContact={onContact}/>- {isInfisicalCloud() && <BillingSectionSkeleton />}+ {(overview?.isCloud ?? isInfisicalCloud()) && <BillingSectionSkeleton />}</div>);}@@ -177,7 +179,6 @@ export const Overview = ({catalog={catalog}readOnly={productsReadOnly}orgFilter={orgFilter}- isReloading={isReloadingProducts}onManage={onUpgrade}onSetCommitment={onSetCommitment}onViewBreakdown={onViewBreakdown}@@ -220,7 +221,6 @@ export const Overview = ({catalog={catalog}readOnly={productsReadOnly}orgFilter={orgFilter}- isReloading={isReloadingProducts}onManage={onUpgrade}onSetCommitment={onSetCommitment}onViewBreakdown={onViewBreakdown}diff --git a/frontend/src/pages/organization/BillingV2Page/components/UsageBreakdownSheet.tsx b/frontend/src/pages/organization/BillingV2Page/components/UsageBreakdownSheet.tsxindex 0aa1878763..37bbd4d915 100644--- a/frontend/src/pages/organization/BillingV2Page/components/UsageBreakdownSheet.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/UsageBreakdownSheet.tsx@@ -29,6 +29,7 @@ import {TabsTrigger} from "@app/components/v3";import { cn } from "@app/components/v3/utils";+import { useHeldLoading } from "@app/hooks";import {BillingV2BreakdownDimension,BillingV2BreakdownScope,@@ -465,7 +466,7 @@ export const UsageBreakdownSheet = ({isPending,isError} = useGetBillingV2UsageBreakdown(orgId, dimensionKey, scope);- const isLoading = isPending && Boolean(dimensionKey);+ const isLoading = useHeldLoading(isPending && Boolean(dimensionKey));return (<Sheet open onOpenChange={(open) => !open && onClose()}>@@ -516,7 +517,9 @@ export const UsageBreakdownSheet = ({</Empty>)}- {breakdown && !isError && <BreakdownBody breakdown={breakdown} scopeKind={scope} />}+ {breakdown && !isError && !isLoading && (+ <BreakdownBody breakdown={breakdown} scopeKind={scope} />+ )}</div><SheetFooter className="flex-row items-center justify-end border-t">