import { openUrl } from '@tauri-apps/plugin-opener'; import { useLicense } from '@yaakapp-internal/license'; import { differenceInDays } from 'date-fns'; import React, { useState } from 'react'; import { useLicenseConfirmation } from '../../hooks/useLicenseConfirmation'; import { useToggle } from '../../hooks/useToggle'; import { pluralizeCount } from '../../lib/pluralize'; import { Banner } from '../core/Banner'; import { Button } from '../core/Button'; import { Checkbox } from '../core/Checkbox'; import { Icon } from '../core/Icon'; import { Link } from '../core/Link'; import { PlainInput } from '../core/PlainInput'; import { HStack, VStack } from '../core/Stacks'; export function SettingsLicense() { const { check, activate, deactivate } = useLicense(); const [key, setKey] = useState(''); const [activateFormVisible, toggleActivateFormVisible] = useToggle(false); const [licenseDetails, setLicenseDetails] = useLicenseConfirmation(); const [checked, setChecked] = useState(false); if (check.isPending) { return null; } return (
{check.data?.type === 'commercial_use' ? ( License active! Enjoy using Yaak for commercial use. ) : check.data?.type == 'trialing' ? (

You have{' '} {pluralizeCount('day', differenceInDays(check.data.end, new Date()))} remaining {' '} on your commercial use trial. Once the trial ends you agree to only use Yaak for personal use until a license is activated.

) : check.data?.type == 'personal_use' && !licenseDetails?.confirmedPersonalUse ? (

Your 30-day trial has ended. Please activate a license or confirm how you're using Yaak.

{ e.preventDefault(); await setLicenseDetails((v) => ({ ...v, confirmedPersonalUse: true, })); }} >
) : null}

A commercial license is required if using Yaak within a for-profit organization.{' '} Learn More

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