/**
* WordPress dependencies
*/
import { Button, ExternalLink, TextControl } from '@safe-wordpress/components';
import { useDispatch, useSelect } from '@safe-wordpress/data';
import { createInterpolateElement } from '@safe-wordpress/element';
import { _x } from '@safe-wordpress/i18n';
/**
* External dependencies
*/
import { LoadingAnimation } from '@nelio-content/components';
import { LICENSE_LENGTH, OLD_LICENSE_LENGTH } from '@nelio-content/constants';
import { store as NC_DATA } from '@nelio-content/data';
import { getSubscribeLink } from '@nelio-content/utils';
/**
* Internal dependencies
*/
import { store as NC_ACCOUNT } from '~/nelio-content-pages/account/store';
import type { LockReason } from '~/nelio-content-pages/account/store/types';
type LicenseConnectionStepProps = {
readonly isDisabled: boolean;
readonly nextStep: () => void;
};
export const LicenseConnectionStep = ( {
isDisabled,
nextStep,
}: LicenseConnectionStepProps ): JSX.Element => {
const isLoading = useIsLoading();
const isSubscribed = useIsSubscribed();
const [ license, setLicense ] = useLicense();
const isLocked = useIsLocked();
const isApplyingLicense = useIsLocked( 'apply-license' );
const { applyLicense } = useDispatch( NC_ACCOUNT );
const today = useSelect( ( select ) => select( NC_DATA ).getToday(), [] );
const link = getSubscribeLink( today, 'wizard-page' );
if ( isLoading ) {
return (
{ _x( 'Congratulations! Your license key is already active.', 'text', 'nelio-content' ) }
{ createInterpolateElement(
_x(
'If you have a license key, enter it here to enable premium features. You can also skip this step and use the free version of Nelio Content.',
'user',
'nelio-content'
),
{
// @ts-expect-error children prop is set by createInterpolateComponent.
a: