Skip to content

Fix orga plan expiration warning #8730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 20 additions & 46 deletions frontend/javascripts/admin/organization/organization_cards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,56 +161,30 @@ export function PlanExceededAlert({ organization }: { organization: APIOrganizat
}

export function PlanAboutToExceedAlert({ organization }: { organization: APIOrganization }) {
const alerts = [];
const activeUser = useWkSelector((state) => state.activeUser);
const isAboutToExpire =
dayjs.duration(dayjs(organization.paidUntil).diff(dayjs())).asWeeks() <= 6 &&
!hasPricingPlanExpired(organization);

if (isAboutToExpire)
alerts.push({
message:
"Your WEBKNOSSOS plan is about to expire soon. Renew your plan now to avoid being downgraded, users being blocked, and losing access to features.",
actionButton: (
<Button
size="small"
type="primary"
onClick={() => UpgradePricingPlanModal.extendPricingPlan(organization)}
>
Extend Plan Now
</Button>
),
});
else {
alerts.push({
message:
"Your organization is about to exceed the storage space included in your current plan. Upgrade now to avoid your account from being blocked.",
actionButton: (
<Button
size="small"
type="primary"
onClick={() => UpgradePricingPlanModal.upgradePricingPlan(organization)}
>
Upgrade Now
</Button>
),
});
}
if (isAboutToExpire) {
const actionButton = (
<Button
size="small"
type="primary"
onClick={() => UpgradePricingPlanModal.extendPricingPlan(organization)}
>
Extend Plan Now
</Button>
);

return (
<>
{alerts.map((alert) => (
<Alert
key={alert.message.slice(0, 10)}
showIcon
type="warning"
message={alert.message}
action={
activeUser && isUserAllowedToRequestUpgrades(activeUser) ? alert.actionButton : null
}
style={{ marginBottom: 20 }}
/>
))}
</>
);
return (
<Alert
showIcon
type="warning"
message="Your WEBKNOSSOS plan is about to expire soon. Renew your plan now to avoid being downgraded, users being blocked, and losing access to features."
action={activeUser && isUserAllowedToRequestUpgrades(activeUser) ? actionButton : null}
style={{ marginBottom: 20 }}
/>
);
} else return null;
}