2022-09-15 03:58:47 +00:00
|
|
|
|
/**
|
|
|
|
|
* External dependencies
|
|
|
|
|
*/
|
|
|
|
|
import { __, sprintf } from '@wordpress/i18n';
|
2022-09-15 08:26:43 +00:00
|
|
|
|
import { useEffect } from '@wordpress/element';
|
|
|
|
|
import { recordEvent } from '@woocommerce/tracks';
|
|
|
|
|
import { useSelect } from '@wordpress/data';
|
|
|
|
|
import { OPTIONS_STORE_NAME } from '@woocommerce/data';
|
2022-09-15 03:58:47 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Internal dependencies
|
|
|
|
|
*/
|
|
|
|
|
import { ModalContentLayoutWithTitle } from '../layouts/ModalContentLayoutWithTitle';
|
|
|
|
|
import { SendMagicLinkButton } from '../components';
|
2022-10-13 08:12:40 +00:00
|
|
|
|
import { SendMagicLinkStates } from '../components/useSendMagicLink';
|
2022-09-15 03:58:47 +00:00
|
|
|
|
|
|
|
|
|
interface JetpackAlreadyInstalledPageProps {
|
|
|
|
|
wordpressAccountEmailAddress: string | undefined;
|
2022-09-15 08:26:43 +00:00
|
|
|
|
isRetryingMagicLinkSend: boolean;
|
2022-09-15 03:58:47 +00:00
|
|
|
|
sendMagicLinkHandler: () => void;
|
2022-10-13 08:12:40 +00:00
|
|
|
|
sendMagicLinkStatus: SendMagicLinkStates;
|
2022-09-15 03:58:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const JetpackAlreadyInstalledPage: React.FC<
|
|
|
|
|
JetpackAlreadyInstalledPageProps
|
2022-09-15 08:26:43 +00:00
|
|
|
|
> = ( {
|
|
|
|
|
wordpressAccountEmailAddress,
|
|
|
|
|
sendMagicLinkHandler,
|
2022-10-13 08:12:40 +00:00
|
|
|
|
sendMagicLinkStatus,
|
2022-09-15 08:26:43 +00:00
|
|
|
|
isRetryingMagicLinkSend,
|
|
|
|
|
} ) => {
|
|
|
|
|
const DISMISSED_MOBILE_APP_MODAL_OPTION =
|
|
|
|
|
'woocommerce_admin_dismissed_mobile_app_modal';
|
|
|
|
|
|
|
|
|
|
const { repeatUser, isLoading } = useSelect( ( select ) => {
|
|
|
|
|
const { hasFinishedResolution, getOption } =
|
|
|
|
|
select( OPTIONS_STORE_NAME );
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
isLoading: ! hasFinishedResolution( 'getOption', [
|
|
|
|
|
DISMISSED_MOBILE_APP_MODAL_OPTION,
|
|
|
|
|
] ),
|
|
|
|
|
repeatUser:
|
|
|
|
|
getOption( DISMISSED_MOBILE_APP_MODAL_OPTION ) === 'yes',
|
|
|
|
|
};
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
useEffect( () => {
|
|
|
|
|
if ( ! isLoading && ! isRetryingMagicLinkSend ) {
|
|
|
|
|
recordEvent( 'magic_prompt_view', {
|
|
|
|
|
// jetpack_state value is implied by the precondition of rendering this screen
|
|
|
|
|
jetpack_state: 'full-connection',
|
|
|
|
|
repeat_user: repeatUser,
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
}, [ repeatUser, isLoading, isRetryingMagicLinkSend ] );
|
|
|
|
|
|
2022-09-15 03:58:47 +00:00
|
|
|
|
return (
|
|
|
|
|
<ModalContentLayoutWithTitle>
|
|
|
|
|
<>
|
|
|
|
|
<div className="modal-subheader jetpack-already-installed">
|
|
|
|
|
<h3>
|
|
|
|
|
{ sprintf(
|
|
|
|
|
/* translators: %s: user's WordPress.com account email address */
|
|
|
|
|
__(
|
|
|
|
|
'We’ll send a magic link to %s. Open it on your smartphone or tablet to sign into your store instantly.',
|
|
|
|
|
'woocommerce'
|
|
|
|
|
),
|
|
|
|
|
wordpressAccountEmailAddress
|
|
|
|
|
) }
|
|
|
|
|
</h3>
|
|
|
|
|
</div>
|
2022-10-13 08:12:40 +00:00
|
|
|
|
<SendMagicLinkButton
|
|
|
|
|
isFetching={
|
|
|
|
|
sendMagicLinkStatus === SendMagicLinkStates.FETCHING
|
|
|
|
|
}
|
|
|
|
|
onClickHandler={ sendMagicLinkHandler }
|
|
|
|
|
/>
|
2022-09-15 03:58:47 +00:00
|
|
|
|
</>
|
|
|
|
|
</ModalContentLayoutWithTitle>
|
|
|
|
|
);
|
|
|
|
|
};
|