2024-05-24 09:17:19 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { useState, useEffect } from '@wordpress/element';
|
|
|
|
|
2021-10-14 14:04:17 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import { Card, CardBody } from '@wordpress/components';
|
2024-05-24 09:17:19 +00:00
|
|
|
import { Spinner } from '@woocommerce/components';
|
2021-10-14 14:04:17 +00:00
|
|
|
import { Text } from '@woocommerce/experimental';
|
2024-05-24 09:17:19 +00:00
|
|
|
import { WooHeaderPageTitle } from '@woocommerce/admin-layout';
|
2021-10-14 14:04:17 +00:00
|
|
|
|
|
|
|
const NoMatch: React.FC = () => {
|
2024-05-24 09:17:19 +00:00
|
|
|
const [ isDelaying, setIsDelaying ] = useState( true );
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Delay for 3 seconds to wait if there are routing pages added after the
|
|
|
|
* initial routing pages to reduce the chance of flashing the error message
|
|
|
|
* on this page.
|
|
|
|
*/
|
|
|
|
useEffect( () => {
|
|
|
|
const timerId = setTimeout( () => {
|
|
|
|
setIsDelaying( false );
|
|
|
|
}, 3000 );
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
clearTimeout( timerId );
|
|
|
|
};
|
|
|
|
}, [] );
|
|
|
|
|
|
|
|
if ( isDelaying ) {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<WooHeaderPageTitle>
|
|
|
|
{ __( 'Loading…', 'woocommerce' ) }
|
|
|
|
</WooHeaderPageTitle>
|
|
|
|
<div className="woocommerce-layout__loading">
|
|
|
|
<Spinner />
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-10-14 14:04:17 +00:00
|
|
|
return (
|
|
|
|
<div className="woocommerce-layout__no-match">
|
|
|
|
<Card>
|
|
|
|
<CardBody>
|
|
|
|
<Text>
|
|
|
|
{ __(
|
|
|
|
'Sorry, you are not allowed to access this page.',
|
2022-03-30 09:00:04 +00:00
|
|
|
'woocommerce'
|
2021-10-14 14:04:17 +00:00
|
|
|
) }
|
|
|
|
</Text>
|
|
|
|
</CardBody>
|
|
|
|
</Card>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export { NoMatch };
|