-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add billing banners for paymentStatus to billing page (#14133)
- Loading branch information
Showing
3 changed files
with
82 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
airbyte-webapp/src/packages/cloud/area/billing/utils/useBillingStatusBanner.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import dayjs from "dayjs"; | ||
import { useIntl } from "react-intl"; | ||
|
||
import { ExternalLink } from "components/ui/Link"; | ||
|
||
import { useCurrentOrganizationInfo } from "core/api"; | ||
import { links } from "core/utils/links"; | ||
|
||
interface BillingStatusBanner { | ||
content: React.ReactNode; | ||
level: "warning" | "info"; | ||
} | ||
|
||
export const useBillingStatusBanner = (): BillingStatusBanner | undefined => { | ||
const { formatMessage } = useIntl(); | ||
const { billing } = useCurrentOrganizationInfo(); | ||
|
||
if (!billing) { | ||
return undefined; | ||
} | ||
|
||
if (billing.paymentStatus === "manual") { | ||
return { | ||
level: "info", | ||
content: formatMessage( | ||
{ id: "settings.organization.billing.manualPaymentStatus" }, | ||
{ | ||
lnk: (node: React.ReactNode) => ( | ||
<ExternalLink opensInNewTab href={links.contactSales} variant="primary"> | ||
{node} | ||
</ExternalLink> | ||
), | ||
} | ||
), | ||
}; | ||
} | ||
|
||
if (billing.paymentStatus === "locked") { | ||
return { | ||
level: "warning", | ||
content: formatMessage( | ||
{ id: "settings.organization.billing.lockedPaymentStatus" }, | ||
{ | ||
mail: ( | ||
<ExternalLink href="mailto:[email protected]" variant="primary"> | ||
[email protected] | ||
</ExternalLink> | ||
), | ||
} | ||
), | ||
}; | ||
} | ||
|
||
if (billing.paymentStatus === "disabled") { | ||
return { | ||
level: "warning", | ||
content: formatMessage({ id: "settings.organization.billing.disabledPaymentStatus" }), | ||
}; | ||
} | ||
|
||
if (billing.paymentStatus === "grace_period") { | ||
return { | ||
level: "warning", | ||
content: formatMessage( | ||
{ id: "settings.organization.billing.gracePeriodPaymentStatus" }, | ||
{ | ||
days: billing?.gracePeriodEndsAt | ||
? Math.max(dayjs(billing.gracePeriodEndsAt * 1000).diff(dayjs(), "days"), 0) | ||
: 0, | ||
} | ||
), | ||
}; | ||
} | ||
|
||
return undefined; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters