import React, { useState } from 'react'
import useAPIError from './useAPIError'
import ModalWrapper from '../Modal/ModalWrapper'
import TokenProjectSignup from '../Modal/TokenProjectSignup'
import MainHeading from '../Titles/MainHeading'
import ResetUserSettings from '../Buttons/ResetUserSettings'
import styles from './APIErrorMessage.module.scss'
import Button from '../Buttons/Button'
import ButtonWrapper from '../Buttons/ButtonWrapper'
const APIErrorDebugInformation = ({ error }) => {
const [showDebugInformation, setShowDebugInformation] = useState(false)
return (
{error.debug && showDebugInformation
? (
)
: null}
If this error continues please contact
extensions@envato.com.
)
}
const APIErrorMessage = () => {
const { errors, removeError } = useAPIError()
const shouldOpenErrorModal = errors.length > 0
if (!shouldOpenErrorModal) {
return null
}
return (
<>
{errors.map(error => {
if (error.code === 'invalid_subscription') {
return (
{ removeError(error) }} />
)
}
if (error.code === 'zip_failure') {
return (
{ removeError(error) }}>
There was an issue installing this template kit. Please try again.
{error.message}
)
}
if (error.code === 'missing_permissions') {
return (
{ removeError(error) }}>
{error.message}
)
}
if (error.code === 'generic_api_error') {
return (
{ removeError(error) }}>
Sorry there was an unexpected error from API call:
{error.message}
)
}
return null
})}
>
)
}
export default APIErrorMessage