Add ability to deactivate license

This commit is contained in:
Gregory Schier
2025-03-05 07:13:19 -08:00
parent 9ead45d67a
commit 7a1a0689b0
16 changed files with 218 additions and 36 deletions

View File

@@ -27,13 +27,26 @@ const details: Record<
commercial_use: null,
invalid_license: { label: 'License Error', color: 'danger' },
personal_use: { label: 'Personal Use', color: 'success' },
trialing: { label: 'Active Trial', color: 'success' },
trialing: { label: 'Personal Use', color: 'success' },
};
export function LicenseBadge() {
const { check } = useLicense();
const [licenseDetails, setLicenseDetails] = useLicenseConfirmation();
if (check.error) {
return (
<LicenseBadgeButton
color="danger"
onClick={() => {
openSettings.mutate(SettingsTab.License);
}}
>
License Error
</LicenseBadgeButton>
);
}
// Hasn't loaded yet
if (licenseDetails == null || check.data == null) {
return null;
@@ -56,10 +69,7 @@ export function LicenseBadge() {
}
return (
<Button
size="2xs"
variant="border"
className="!rounded-full mx-1"
<LicenseBadgeButton
color={detail.color}
onClick={async () => {
if (check.data.type === 'trialing') {
@@ -72,6 +82,10 @@ export function LicenseBadge() {
}}
>
{detail.label}
</Button>
</LicenseBadgeButton>
);
}
function LicenseBadgeButton({ ...props }: ButtonProps) {
return <Button size="2xs" variant="border" className="!rounded-full mx-1" {...props} />;
}