import { useLicense } from '@yaakapp-internal/license'; import { format, formatDistanceToNow } from 'date-fns'; import { open } from '@tauri-apps/plugin-shell'; import React, { useState } from 'react'; import { useSettings } from '../../hooks/useSettings'; import { useToggle } from '../../hooks/useToggle'; import { Banner } from '../core/Banner'; import { Button } from '../core/Button'; import { Icon } from '../core/Icon'; import { InlineCode } from '../core/InlineCode'; import { Link } from '../core/Link'; import { PlainInput } from '../core/PlainInput'; import { HStack, VStack } from '../core/Stacks'; export function SettingsLicense() { const { check, activate } = useLicense(); const [key, setKey] = useState(''); const [activateFormVisible, toggleActivateFormVisible] = useToggle(false); const settings = useSettings(); const specialAnnouncement = settings.createdAt < '2024-12-02' && check.data?.type === 'trial_ended'; return (
{check.data?.type === 'trialing' && ( Your trial ends in {formatDistanceToNow(check.data.end)}. If you're using Yaak for commercial use, please purchase a commercial use license. )} {check.data?.type === 'trial_ended' && ( Your trial ended on {format(check.data.end, 'MMMM dd, yyyy')}. A commercial-use license is required if you use Yaak within a for-profit organization of two or more people. )} {check.data?.type === 'personal_use' && You're} {check.data?.type === 'commercial_use' && ( License active! Enjoy using Yaak for commercial use. )} {check.error && {check.error}} {activate.error && {activate.error}} {specialAnnouncement && (

Thank you for being an early supporter of Yaak!

To support the ongoing development of the best local-first API client, Yaak now requires a paid license for the commercial use of prebuilt binaries (personal use and running the open-source code remains free.)

For details, see the{' '} Announcement Post.

As a thank-you, enter code EARLYAAK at checkout for 50% off your first year of the individual plan.

~ Greg

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