Files
yaak/src-web/components/LicenseBadge.tsx
Gregory Schier 40f0f5387a Fix lint problems
2024-12-03 09:43:16 -08:00

43 lines
1.0 KiB
TypeScript

import type { LicenseCheckStatus } from '@yaakapp-internal/license';
import { useLicense } from '@yaakapp-internal/license';
import { useOpenSettings } from '../hooks/useOpenSettings';
import { Button } from './core/Button';
import { SettingsTab } from './Settings/Settings';
const labels: Record<LicenseCheckStatus['type'], string | null> = {
commercial_use: null,
personal_use: 'Personal Use',
trial_ended: 'Personal Use',
trialing: 'Active Trial',
};
export function LicenseBadge() {
const openSettings = useOpenSettings(SettingsTab.License);
const { check } = useLicense();
if (check.data == null) {
return null;
}
const label = labels[check.data.type];
if (label == null) {
return null;
}
return (
<Button
size="2xs"
variant="border"
className="!rounded-full mx-1"
onClick={() => openSettings.mutate()}
color={
check.data.type == 'trial_ended' || check.data.type === 'personal_use'
? 'primary'
: 'success'
}
>
{label}
</Button>
);
}