Tweak license flow

This commit is contained in:
Gregory Schier
2024-12-16 13:46:58 -08:00
parent 20140148bf
commit e2253786dc
4 changed files with 37 additions and 77 deletions

View File

@@ -1,14 +1,18 @@
import type { LicenseCheckStatus } from '@yaakapp-internal/license';
import { useLicense } from '@yaakapp-internal/license';
import { useOpenSettings } from '../hooks/useOpenSettings';
import type { ButtonProps } from './core/Button';
import { Button } from './core/Button';
import { SettingsTab } from './Settings/Settings';
const labels: Record<LicenseCheckStatus['type'], string | null> = {
const details: Record<
LicenseCheckStatus['type'],
{ label: string; color: ButtonProps['color'] } | null
> = {
commercial_use: null,
personal_use: 'Personal Use',
trial_ended: 'Personal Use',
trialing: 'Active Trial',
invalid_license: { label: 'Invalid License', color: 'danger' },
personal_use: { label: 'Personal Use', color: 'success' },
trialing: { label: 'Personal Use', color: 'success' },
};
export function LicenseBadge() {
@@ -19,8 +23,8 @@ export function LicenseBadge() {
return null;
}
const label = labels[check.data.type];
if (label == null) {
const detail = details[check.data.type];
if (detail == null) {
return null;
}
@@ -30,13 +34,9 @@ export function LicenseBadge() {
variant="border"
className="!rounded-full mx-1"
onClick={() => openSettings.mutate()}
color={
check.data.type == 'trial_ended' || check.data.type === 'personal_use'
? 'primary'
: 'success'
}
color={detail.color}
>
{label}
{detail.label}
</Button>
);
}