feat: add invoice banner + block additions to teams/orgs (#27327)
* feat: add invoice URL to proration and test seed scripts - Add invoiceUrl field to MonthlyProration schema - Update billing service to return hosted_invoice_url after finalizing - Save invoice URL when creating proration invoices - Add seed script for testing proration with real Stripe data - Add cleanup script for test data removal Co-Authored-By: Claude Opus 4.5 <[email protected]> * feat: add due invoice banner and invitation blocking for orgs - Add DueInvoiceBanner component showing overdue prorations - Add DueInvoiceService for checking blocking status and banner data - Block invitations when proration invoices are 7+ days overdue - Allow sub-team invites for existing org members (exception) - Show banner to users with billing management permissions - Link directly to Stripe invoice URL when available Co-Authored-By: Claude Opus 4.5 <[email protected]> * fix: set subscriptionId in team metadata in seed script The seed script was not setting subscriptionId on the team metadata, causing checkIfOrgNeedsUpgrade to treat the org as needing upgrade and showing the "trialing" banner. Co-Authored-By: Claude Opus 4.5 <[email protected]> * push trigger test to script * fix mocks --------- Co-authored-by: Claude Opus 4.5 <[email protected]>
This commit is contained in:
1 parent
ca5d931165
commit
3c91703415
9 files changed
+742
-26
No files matched your search
@@ -0,0 +1,42 @@
|
||||
"use client";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { TopBanner } from "@calcom/ui/components/top-banner";
|
||||
|
||||
export type DueInvoiceBannerProps = {
|
||||
data: RouterOutputs["viewer"]["me"]["getUserTopBanners"]["dueInvoiceBanner"];
|
||||
};
|
||||
|
||||
export function DueInvoiceBanner({ data }: DueInvoiceBannerProps) {
|
||||
const { t } = useLocale();
|
||||
|
||||
if (!data || data.length === 0) return null;
|
||||
|
||||
// Get the first proration to display (prioritize blocking ones)
|
||||
const blockingProrations = data.filter((d) => d.isBlocking);
|
||||
const displayProration = blockingProrations[0] ?? data[0];
|
||||
const hasBlocking = blockingProrations.length > 0;
|
||||
|
||||
// Use Stripe invoice URL if available, otherwise fall back to billing settings
|
||||
const paymentUrl =
|
||||
displayProration.invoiceUrl ?? `/settings/teams/${displayProration.teamId}/billing`;
|
||||
|
||||
return (
|
||||
<TopBanner
|
||||
variant={hasBlocking ? "error" : "warning"}
|
||||
text={t(hasBlocking ? "invoice_overdue_blocking" : "invoice_due", {
|
||||
teamName: displayProration.teamName,
|
||||
})}
|
||||
actions={
|
||||
<a
|
||||
href={paymentUrl}
|
||||
target={displayProration.invoiceUrl ? "_blank" : undefined}
|
||||
rel={displayProration.invoiceUrl ? "noopener noreferrer" : undefined}
|
||||
className="border-b border-b-black hover:opacity-80">
|
||||
{t("pay_now")}
|
||||
</a>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
DueInvoiceBanner,
|
||||
type DueInvoiceBannerProps,
|
||||
} from "@calcom/web/modules/ee/billing/components/DueInvoiceBanner";
|
||||
import ImpersonatingBanner, {
|
||||
type ImpersonatingBannerProps,
|
||||
} from "@calcom/web/modules/ee/impersonation/components/ImpersonatingBanner";
|
||||
@@ -31,6 +35,7 @@ type BannerTypeProps = {
|
||||
impersonationBanner: ImpersonatingBannerProps;
|
||||
calendarCredentialBanner: CalendarCredentialBannerProps;
|
||||
invalidAppCredentialBanners: InvalidAppCredentialBannersProps;
|
||||
dueInvoiceBanner: DueInvoiceBannerProps;
|
||||
};
|
||||
|
||||
type BannerType = keyof BannerTypeProps;
|
||||
@@ -51,6 +56,7 @@ export const BannerComponent: BannerComponent = {
|
||||
invalidAppCredentialBanners: (props: InvalidAppCredentialBannersProps) => (
|
||||
<InvalidAppCredentialBanners {...props} />
|
||||
),
|
||||
dueInvoiceBanner: (props: DueInvoiceBannerProps) => <DueInvoiceBanner {...props} />,
|
||||
};
|
||||
|
||||
interface BannerContainerProps {
|
||||
@@ -82,6 +88,9 @@ export const BannerContainer: React.FC<BannerContainerProps> = ({ banners }) =>
|
||||
} else if (key === "invalidAppCredentialBanners") {
|
||||
const Banner = BannerComponent[key];
|
||||
return <Banner data={banners[key]} key={key} />;
|
||||
} else if (key === "dueInvoiceBanner") {
|
||||
const Banner = BannerComponent[key];
|
||||
return <Banner data={banners[key]} key={key} />;
|
||||
}
|
||||
})}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user