All Downloads are FREE. Search and download functionalities are using the official Maven repository.

components.errors.errorTemplates.jsx Maven / Gradle / Ivy

The newest version!
import React from 'react'

import translation from '../../locales/ru/translation'
import { PageTitle as DocumentTitle } from '../core/PageTitle'

import ErrorPage from './ErrorPage'

const ForbiddenPage = () => (
    <>
        
        
    
)

const NotFoundPage = () => (
    <>
        
        
    
)

const ServerErrorPage = () => (
    <>
        
        
    
)

const BadGatewayPage = () => (
    <>
        
        
    
)

const ServiceUnavailablePage = () => (
    <>
        
        
    
)

const NetworkErrorPage = () => (
    <>
        
        
    
)

const InternalErrorPage = ({ error }) => {
    const { text } = error

    return (
        <>
            
            
        
    )
}
const defaultComponents = {
    403: ForbiddenPage,
    404: NotFoundPage,
    500: ServerErrorPage,
    502: BadGatewayPage,
    503: ServiceUnavailablePage,
    networkError: NetworkErrorPage,
    internalError: InternalErrorPage,
}

/* example config = {404: CustomComponent} */
// eslint-disable-next-line @typescript-eslint/default-param-last
export const errorTemplates = (config = {}, isOnline) => {
    const components = {
        ...defaultComponents,
        ...config,
    }

    return (error) => {
        if (error.status) { return components[error.status] }
        if (!isOnline) { return components.networkError }

        return components.internalError
    }
}

export default errorTemplates




© 2015 - 2024 Weber Informatics LLC | Privacy Policy