mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-18 07:24:07 +01:00
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
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 details: Record<
|
|
LicenseCheckStatus['type'],
|
|
{ label: string; color: ButtonProps['color'] } | null
|
|
> = {
|
|
commercial_use: null,
|
|
invalid_license: { label: 'License Error', color: 'danger' },
|
|
personal_use: { label: 'Personal Use', color: 'primary' },
|
|
trialing: { label: 'Personal Use', color: 'primary' },
|
|
};
|
|
|
|
export function LicenseBadge() {
|
|
const openSettings = useOpenSettings(SettingsTab.License);
|
|
const { check } = useLicense();
|
|
|
|
if (check.data == null) {
|
|
return null;
|
|
}
|
|
|
|
const detail = details[check.data.type];
|
|
if (detail == null) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<Button
|
|
size="2xs"
|
|
variant="border"
|
|
className="!rounded-full mx-1"
|
|
onClick={() => openSettings.mutate()}
|
|
color={detail.color}
|
|
event={{ id: 'license-badge', status: check.data.type }}
|
|
>
|
|
{detail.label}
|
|
</Button>
|
|
);
|
|
}
|