| 1 |
import { __ } from '@wordpress/i18n'; |
| 2 |
import { UPGRADE_LINK } from '../../constants'; |
| 3 |
import { getUpgradeLink } from '../../../../../../assets/dev/js/utils'; |
| 4 |
|
| 5 |
const getErrorButton = ( { errorType, imagesLeft, allowRetry } ) => { |
| 6 |
const isElementorOne = window?.imageOptimizerUserData?.isElementorOne || false; |
| 7 |
if ( 'auth-error' === errorType ) { |
| 8 |
const connectLink = window?.imageOptimizerControlSettings?.connectLink; |
| 9 |
|
| 10 |
return ` |
| 11 |
<a class="button button-secondary button-large image-optimization-control__button" |
| 12 |
href="${ connectLink }" |
| 13 |
target="_blank" rel="noopener noreferrer"> |
| 14 |
${ __( 'Connect', 'image-optimization' ) } |
| 15 |
</a> |
| 16 |
`; |
| 17 |
} else if ( 'connection-error' === errorType ) { |
| 18 |
return ` |
| 19 |
<button class="button button-secondary button-large button-link-delete image-optimization-control__button image-optimization-control__button--try-again" |
| 20 |
type="button"> |
| 21 |
${ __( 'Try again', 'image-optimization' ) } |
| 22 |
</button> |
| 23 |
`; |
| 24 |
} else if ( typeof imagesLeft !== 'undefined' && 0 === imagesLeft ) { |
| 25 |
if ( isElementorOne ) { |
| 26 |
return ''; |
| 27 |
} |
| 28 |
|
| 29 |
const subscriptionId = window?.imageOptimizerUserData?.planData?.subscription_id; |
| 30 |
return ` |
| 31 |
<a class="button button-secondary button-large image-optimization-control__button" |
| 32 |
href="${ getUpgradeLink( UPGRADE_LINK, subscriptionId ) }" |
| 33 |
target="_blank" rel="noopener noreferrer"> |
| 34 |
${ __( 'Upgrade', 'image-optimization' ) } |
| 35 |
</a> |
| 36 |
`; |
| 37 |
} else if ( allowRetry ) { |
| 38 |
return ` |
| 39 |
<button class="button button-secondary button-large button-link-delete image-optimization-control__button image-optimization-control__button--try-again" |
| 40 |
type="button"> |
| 41 |
${ __( 'Try again', 'image-optimization' ) } |
| 42 |
</button> |
| 43 |
`; |
| 44 |
} |
| 45 |
}; |
| 46 |
|
| 47 |
export { |
| 48 |
getErrorButton, |
| 49 |
}; |
| 50 |
|