import {
Description,
DialogTitle,
Field,
Input,
Label,
} from '@headlessui/react';
import { __, _n } from '@wordpress/i18n';
import { check, chevronRight, external, Icon } from '@wordpress/icons';
import { isEmail } from '@wordpress/url';
import classNames from 'classnames';
export const SetupPlugins = ({
plugins,
setPlugins,
handleCreateAccounts,
email,
setEmail,
handleClose,
marketingConsent,
setMarketingConsent,
termsAgreed,
setTermsAgreed,
}) => {
const offeredCount = plugins.length;
const isCreateAccountsEnabled =
isEmail(email) && termsAgreed && plugins?.some((plugin) => plugin.selected);
const togglePlugin = (pluginTitle) => {
setPlugins(
plugins?.map((plugin) => {
if (plugin.title !== pluginTitle) {
return plugin;
}
return {
...plugin,
selected: !plugin?.selected,
};
}),
);
};
return (
{_n(
"Almost done! Let's finish setting up your plugin",
"Almost done! Let's finish setting up your plugins",
offeredCount,
'extendify-local',
)}
{plugins?.map((plugin) => {
const isSelected = plugin.selected;
return (
togglePlugin(plugin.title)}
className={classNames(
'shrink-0 rounded-full transition-colors cursor-pointer',
isSelected
? 'bg-[#1A5130] fill-white'
: 'bg-gray-200 fill-transparent',
)}
/>
);
})}
{__('Email address', 'extendify-local')}
setEmail(e.target.value)}
placeholder="admin@example.com"
className="text-gray-900 w-full px-4 py-3 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-extendify-main focus:border-transparent"
/>
{_n(
'This email will be used to create an account with the selected plugin provider. Form protected by reCAPTCHA.',
'This email will be used to create accounts with the selected plugin providers. Form protected by reCAPTCHA.',
offeredCount,
'extendify-local',
)}
setTermsAgreed(e.target.checked)}
className="mt-0.5 h-4 w-4 shrink-0 rounded border-gray-300 accent-extendify-main focus:ring-extendify-main"
/>
{_n(
'I agree to create an account with the selected provider using my email address, and to their applicable Terms of Service.',
'I agree to create accounts with the selected providers using my email address, and to their applicable Terms of Service.',
offeredCount,
'extendify-local',
)}
setMarketingConsent(e.target.checked)}
className="mt-0.5 h-4 w-4 shrink-0 rounded border-gray-300 accent-extendify-main focus:ring-extendify-main"
/>
{_n(
'I wish to receive communications about news and/or promotions from the selected provider.',
'I wish to receive communications about news and/or promotions from selected providers.',
offeredCount,
'extendify-local',
)}
handleClose()}
className="px-6 py-3 text-base font-medium text-gray-900 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-extendify-main"
>
{__('No thanks', 'extendify-local')}
{_n(
'Create account',
'Create accounts',
offeredCount,
'extendify-local',
)}
);
};