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 { 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()))} remaining {' '} on your commercial-use trial

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

You are able to use Yaak for personal use only

) : null} {check.data?.type !== 'commercial_use' && (

Hey, I'm Greg 👋🏼

Yaak is free for personal projects and learning.{' '} {check.data?.type === 'trialing' ? 'After your trial, a ' : 'A '} license is required for work or commercial use.

Learn More

)} {check.error && {check.error}} {activate.error && {activate.error}} {check.data?.type === 'commercial_use' ? ( ) : ( )} {activateFormVisible && ( { e.preventDefault(); await activate.mutateAsync({ licenseKey: key }); toggleActivateFormVisible(); }} > )}
); }