,
+ leftSlot: ,
+ rightSlot: ,
+ hidden: data.data.changesUrl == null,
+ onSelect: () => openUrl(data.data.billingUrl),
+ },
+ {
+ label: 'Enter License Key',
+ leftSlot: ,
+ hidden: data.data.changesUrl == null,
+ onSelect: openLicenseDialog,
+ },
+ { type: 'separator' },
+ {
+ label: Remind me Later,
+ leftSlot: ,
+ onSelect: () => jotaiStore.set(dismissedAtom, new Date().toISOString()),
+ },
+ ],
+ };
+ }
+}
export function LicenseBadge() {
return (
@@ -29,10 +93,15 @@ export function LicenseBadge() {
function LicenseBadgeCmp() {
const { check } = useLicense();
const settings = useAtomValue(settingsAtom);
+ const dismissed = useAtomValue(dismissedAtom);
+
+ // Dismissed license badge
+ if (settings.hideLicenseBadge) {
+ return null;
+ }
if (check.error) {
- // Failed to check for license. Probably a network or server error so just don't
- // show anything.
+ // Failed to check for license. Probably a network or server error, so just don't show anything.
return null;
}
@@ -41,19 +110,30 @@ function LicenseBadgeCmp() {
return null;
}
- // Dismissed license badge
- if (settings.hideLicenseBadge) {
- return null;
- }
-
- const detail = details[check.data.type];
+ const detail = getDetail(check.data, dismissed);
if (detail == null) {
return null;
}
+ if (detail.options && detail.options.length > 0) {
+ return (
+
+
+
+ {detail.label}
+
+
+
+ );
+ }
+
return (
- openSettings.mutate('license')}>
+
{detail.label}
);
}
+
+function openLicenseDialog() {
+ openSettings.mutate('license');
+}
diff --git a/src-web/components/Settings/SettingsLicense.tsx b/src-web/components/Settings/SettingsLicense.tsx
index fc198d01..ea0134e1 100644
--- a/src-web/components/Settings/SettingsLicense.tsx
+++ b/src-web/components/Settings/SettingsLicense.tsx
@@ -1,6 +1,7 @@
import { openUrl } from '@tauri-apps/plugin-opener';
import { useLicense } from '@yaakapp-internal/license';
import { differenceInDays } from 'date-fns';
+import { formatDate } from 'date-fns/format';
import { useState } from 'react';
import { useToggle } from '../../hooks/useToggle';
import { pluralizeCount } from '../../lib/pluralize';
@@ -31,71 +32,120 @@ function SettingsLicenseCmp() {
return null;
}
+ const renderBanner = () => {
+ if (!check.data) return null;
+
+ switch (check.data.status) {
+ case 'active':
+ return Your license is active 🥳;
+
+ case 'trialing':
+ return (
+
+
+
+
+ {pluralizeCount('day', differenceInDays(check.data.data.end, new Date()))}
+ {' '}
+ left to evaluate Yaak for commercial use.
+
+ Personal use is always free, forever.
+
+
+
+ Contact Support
+
+
+
+ Learn More
+
+
+
+
+ );
+
+ case 'personal_use':
+ return (
+
+
+
+ Your commercial-use trial has ended.
+
+
+ You may continue using Yaak for personal use free, forever.
+ A license is required for commercial use.
+
+
+
+
+ Contact Support
+
+
+
+ Learn More
+
+
+
+
+ );
+
+ case 'inactive':
+ return (
+
+ Your license is invalid. Please Sign In{' '}
+ for more details
+
+ );
+
+ case 'expired':
+ return (
+
+ Your license expired{' '}
+ {formatDate(check.data.data.periodEnd, 'MMMM dd, yyyy')}. Please{' '}
+ Resubscribe to continue receiving
+ updates.
+ {check.data.data.changesUrl && (
+ <>
+
+ What's new in latest builds
+ >
+ )}
+
+ );
+
+ case 'past_due':
+ return (
+
+ Your payment method needs attention.
+
+ To re-activate your license, please{' '}
+ update your billing info.
+
+ );
+
+ case 'error':
+ return (
+
+ License check failed: {check.data.data.message} (Code: {check.data.data.code})
+
+ );
+ }
+ };
+
return (
- {check.data?.type === 'commercial_use' ? (
- Your license is active 🥳
- ) : check.data?.type === 'trialing' ? (
-
-
-
- {pluralizeCount('day', differenceInDays(check.data.end, new Date()))}{' '}
- left to evaluate Yaak for commercial use.
-
- Personal use is always free, forever.
-
-
- Your commercial-use trial has ended.
-
-
- You may continue using Yaak for personal use free, forever.
- A license is required for commercial use.
-
-
-
-
- Contact Support
-
-
-
- Learn More
-
-
-
-
- ) : null}
+ {renderBanner()}
{check.error && {check.error}}
{activate.error && {activate.error}}
- {check.data?.type === 'invalid_license' && (
-
- Your license is invalid. Please Sign In for
- more details
-
- )}
-
- {check.data?.type === 'commercial_use' ? (
+ {check.data?.status === 'active' ? (