import { openUrl } from '@tauri-apps/plugin-opener'; import { useLicense } from '@yaakapp-internal/license'; import { differenceInDays } from 'date-fns'; import React, { useState } from 'react'; import { useToggle } from '../../hooks/useToggle'; import { pluralizeCount } from '../../lib/pluralize'; import { CargoFeature } from '../CargoFeature'; import { Banner } from '../core/Banner'; import { Button } from '../core/Button'; import { Icon } from '../core/Icon'; import { Link } from '../core/Link'; import { PlainInput } from '../core/PlainInput'; import { Separator } from '../core/Separator'; import { HStack, VStack } from '../core/Stacks'; import { LocalImage } from '../LocalImage'; export function SettingsLicense() { return ( ); } function SettingsLicenseCmp() { const { check, activate, deactivate } = useLicense(); const [key, setKey] = useState(''); const [activateFormVisible, toggleActivateFormVisible] = useToggle(false); if (check.isPending) { return null; } 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.

Contact Support Learn More

) : check.data?.type === 'personal_use' ? (

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} {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' ? ( ) : ( )} {activateFormVisible && ( { e.preventDefault(); await activate.mutateAsync({ licenseKey: key }); toggleActivateFormVisible(); }} > )}
); }