mirror of
https://github.com/docmost/docmost.git
synced 2026-08-28 01:07:08 +08:00
fix: license display
This commit is contained in:
@@ -34,6 +34,7 @@ export default function LicenseDetails() {
|
||||
<Table.Td>
|
||||
{license.licenseType === "business" ? "Business" : "Enterprise"}{" "}
|
||||
{license.trial && <Badge color="green">Trial</Badge>}
|
||||
{license.lifetime && <Badge color="blue">Lifetime</Badge>}
|
||||
</Table.Td>
|
||||
</Table.Tr>
|
||||
|
||||
@@ -59,7 +60,14 @@ export default function LicenseDetails() {
|
||||
<Table.Tr>
|
||||
<Table.Th>Expires at</Table.Th>
|
||||
<Table.Td>
|
||||
{formatLocalized(license.expiresAt, "dd MMMM, yyyy", "PPP", locale)}
|
||||
{license.lifetime
|
||||
? "Never"
|
||||
: formatLocalized(
|
||||
license.expiresAt,
|
||||
"dd MMMM, yyyy",
|
||||
"PPP",
|
||||
locale,
|
||||
)}
|
||||
</Table.Td>
|
||||
</Table.Tr>
|
||||
<Table.Tr>
|
||||
|
||||
@@ -4,10 +4,12 @@ import { differenceInDays, isAfter } from "date-fns";
|
||||
export const GRACE_PERIOD_DAYS = 10;
|
||||
|
||||
export function isLicenseExpired(license: ILicenseInfo): boolean {
|
||||
if (license.lifetime) return false;
|
||||
return isAfter(new Date(), license.expiresAt);
|
||||
}
|
||||
|
||||
export function daysToExpire(license: ILicenseInfo): number {
|
||||
if (license.lifetime) return Infinity;
|
||||
const days = differenceInDays(license.expiresAt, new Date());
|
||||
return days > 0 ? days : 0;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ export interface ILicenseInfo {
|
||||
seatCount: number;
|
||||
licenseType: LicenseType;
|
||||
issuedAt: Date;
|
||||
expiresAt: Date;
|
||||
expiresAt: Date | null;
|
||||
trial: boolean;
|
||||
lifetime: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user