| 1 |
import { DialogTitle } from '@headlessui/react'; |
| 2 |
import { Spinner } from '@wordpress/components'; |
| 3 |
import { __, _n } from '@wordpress/i18n'; |
| 4 |
import { check, Icon } from '@wordpress/icons'; |
| 5 |
import { ACCOUNT_STATUS } from './usePluginsActivation'; |
| 6 |
|
| 7 |
const SuccessIcon = () => ( |
| 8 |
<div className="p-2 rounded-full bg-[#4AB866]/25"> |
| 9 |
<Icon |
| 10 |
icon={check} |
| 11 |
className="h-10 w-10 rounded-full bg-[#4AB866] fill-white" |
| 12 |
/> |
| 13 |
</div> |
| 14 |
); |
| 15 |
|
| 16 |
const isPending = (plugin) => plugin.status === ACCOUNT_STATUS.pending; |
| 17 |
|
| 18 |
export const SetupComplete = ({ plugins, handleClose }) => { |
| 19 |
const isRunning = plugins.some(isPending); |
| 20 |
const accountCount = plugins.length; |
| 21 |
const heading = isRunning |
| 22 |
? _n( |
| 23 |
'Setting up your plugin account', |
| 24 |
'Setting up your plugin accounts', |
| 25 |
accountCount, |
| 26 |
'extendify-local', |
| 27 |
) |
| 28 |
: __('Setup complete', 'extendify-local'); |
| 29 |
const body = isRunning |
| 30 |
? _n( |
| 31 |
'You can close this window. We will finish creating your account in the background.', |
| 32 |
'You can close this window. We will finish creating your accounts in the background.', |
| 33 |
accountCount, |
| 34 |
'extendify-local', |
| 35 |
) |
| 36 |
: _n( |
| 37 |
'Your plugin account has been set up. Account activation may take a moment to complete.', |
| 38 |
'Your plugin accounts have been set up. Account activation may take a moment to complete.', |
| 39 |
accountCount, |
| 40 |
'extendify-local', |
| 41 |
); |
| 42 |
|
| 43 |
return ( |
| 44 |
<div className="px-16 py-10 flex flex-col items-center justify-center"> |
| 45 |
<div className="mb-6"> |
| 46 |
{isRunning ? ( |
| 47 |
<Spinner className="h-10 w-10 text-[#1A5130]" /> |
| 48 |
) : ( |
| 49 |
<SuccessIcon /> |
| 50 |
)} |
| 51 |
</div> |
| 52 |
<DialogTitle className="text-xl font-semibold text-center text-gray-900 mb-2 font-sans"> |
| 53 |
{heading} |
| 54 |
</DialogTitle> |
| 55 |
<p className="text-center text-gray-700 mb-2 text-base">{body}</p> |
| 56 |
|
| 57 |
<div className="w-full mt-6 space-y-3"> |
| 58 |
{plugins.map((plugin) => ( |
| 59 |
<div |
| 60 |
key={plugin.slug} |
| 61 |
aria-busy={isPending(plugin)} |
| 62 |
className="flex items-center gap-3" |
| 63 |
> |
| 64 |
<img |
| 65 |
alt="" |
| 66 |
src={plugin.image} |
| 67 |
className="w-6 h-6 rounded-full shrink-0" |
| 68 |
/> |
| 69 |
<span className="text-sm text-gray-900">{plugin.title}</span> |
| 70 |
{isPending(plugin) ? ( |
| 71 |
<Spinner className="ml-auto h-5 w-5 text-gray-700" /> |
| 72 |
) : ( |
| 73 |
<Icon |
| 74 |
icon={check} |
| 75 |
className="ml-auto shrink-0 rounded-full bg-[#1A5130] fill-white" |
| 76 |
/> |
| 77 |
)} |
| 78 |
</div> |
| 79 |
))} |
| 80 |
</div> |
| 81 |
|
| 82 |
<button |
| 83 |
type="button" |
| 84 |
onClick={handleClose} |
| 85 |
className="mt-6 px-6 py-3 text-base font-medium text-white bg-extendify-main rounded-lg hover:bg-extendify-main-dark focus:outline-none focus:ring-2 focus:ring-extendify-main focus:ring-offset-2" |
| 86 |
> |
| 87 |
{__('Close', 'extendify-local')} |
| 88 |
</button> |
| 89 |
</div> |
| 90 |
); |
| 91 |
}; |
| 92 |
|