import React from 'react'; import { __ } from '@wordpress/i18n'; import { decodeEntities } from '@wordpress/html-entities'; import { useStateValue } from '../../store/store'; import Button from '../../components/button/button'; import './style.scss'; import { getSupportLink } from '../../utils/functions'; const ErrorScreen = () => { const [ { importErrorMessages, currentIndex, tryAgainCount, templateId }, dispatch, ] = useStateValue(); const supportLink = getSupportLink( templateId, importErrorMessages.errorText ); const tryAgain = () => { dispatch( { type: 'set', // Reset errors. importErrorMessages: {}, importErrorResponse: [], importError: false, // Try again count. tryAgainCount: tryAgainCount + 1, // Reset import flags. xmlImportDone: false, resetData: [], importStart: false, importEnd: false, importPercent: 0, requiredPluginsDone: false, notInstalledList: [], notActivatedList: [], // Go to previous step. currentIndex: currentIndex - 1, } ); }; const solutionHeading = (
{ __( 'Still no luck? Other potential solution:', 'astra-sites' ) }
); return (
{ __( 'Sorry, something went wrong.', 'astra-sites' ) }
{ __( 'What went wrong?', 'astra-sites' ) }
{ importErrorMessages.primaryText && (

{ importErrorMessages.primaryText }

) }
{ importErrorMessages.secondaryText && (
{ importErrorMessages.secondaryText && (

) }

) }
{ __( 'More technical information from console:', 'astra-sites' ) }
{ importErrorMessages.errorText && 'object' !== typeof importErrorMessages.errorText && (

{ importErrorMessages.errorText }

) } { importErrorMessages.errorText && 'object' === typeof importErrorMessages.errorText && (
									{ JSON.stringify(
										importErrorMessages.errorText,
										undefined,
										2
									) }
								
) }
{ importErrorMessages.tryAgain && tryAgainCount < 3 && ( ) }
{ importErrorMessages.solutionText && ( <> { solutionHeading }

) } { ( ! importErrorMessages.solutionText && ! importErrorMessages.tryAgain ) || ( importErrorMessages.tryAgain && tryAgainCount > 1 && ( <> { solutionHeading }

{ decodeEntities( __( 'Please report this error ', 'astra-sites' ) ) } { 'here' } { decodeEntities( __( ' so we can fix it.', 'astra-sites' ) ) }

) ) }
); }; export default ErrorScreen;