mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-31 01:16:01 +02:00
https://linear.app/unleash/issue/CTO-95/unleash-billing-page-for-enterprise-payg Adds support for PAYG in Unleash's billing page. Includes some refactoring, like splitting Pro and PAYG into different details components. We're now also relying on shared billing-related constants (see `BillingPlan.tsx`). This should make it much easier to change any of these values in the future. I already changed a few that were static / wrongly relying on instanceStatus.seats (we decided we're not doing that for now). 
48 lines
1.8 KiB
TypeScript
48 lines
1.8 KiB
TypeScript
import { PageContent } from 'component/common/PageContent/PageContent';
|
|
import { useEffect } from 'react';
|
|
import { ADMIN } from 'component/providers/AccessProvider/permissions';
|
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
|
import { PermissionGuard } from 'component/common/PermissionGuard/PermissionGuard';
|
|
import { useInstanceStatus } from 'hooks/api/getters/useInstanceStatus/useInstanceStatus';
|
|
import { Alert } from '@mui/material';
|
|
import { BillingDashboard } from './BillingDashboard/BillingDashboard';
|
|
import { BillingHistory } from './BillingHistory/BillingHistory';
|
|
import useInvoices from 'hooks/api/getters/useInvoices/useInvoices';
|
|
|
|
export const Billing = () => {
|
|
const { isBilling, refetchInstanceStatus, refresh, loading } =
|
|
useInstanceStatus();
|
|
const { invoices } = useInvoices();
|
|
|
|
useEffect(() => {
|
|
const hardRefresh = async () => {
|
|
await refresh();
|
|
refetchInstanceStatus();
|
|
};
|
|
hardRefresh();
|
|
}, [refetchInstanceStatus, refresh]);
|
|
|
|
return (
|
|
<div>
|
|
<PageContent header='Billing' isLoading={loading}>
|
|
<ConditionallyRender
|
|
condition={isBilling}
|
|
show={
|
|
<PermissionGuard permissions={ADMIN}>
|
|
<>
|
|
<BillingDashboard />
|
|
<BillingHistory data={invoices} />
|
|
</>
|
|
</PermissionGuard>
|
|
}
|
|
elseShow={
|
|
<Alert severity='error'>
|
|
Billing is not enabled for this instance.
|
|
</Alert>
|
|
}
|
|
/>
|
|
</PageContent>
|
|
</div>
|
|
);
|
|
};
|