2024-07-15 05:12:58 -04:00
|
|
|
import { FC } from 'react'
|
|
|
|
import { ConnectionError } from '@/features/ide-react/connection/types/connection-state'
|
|
|
|
import getMeta from '@/utils/meta'
|
|
|
|
|
2024-10-10 03:38:08 -04:00
|
|
|
const errorMessages = {
|
|
|
|
'io-not-loaded': 'ol-translationIoNotLoaded',
|
|
|
|
'unable-to-join': 'ol-translationUnableToJoin',
|
|
|
|
'i18n-error': 'ol-translationLoadErrorMessage',
|
|
|
|
} as const
|
2024-07-15 05:12:58 -04:00
|
|
|
|
2024-10-10 03:38:08 -04:00
|
|
|
const isHandledCode = (key: string): key is keyof typeof errorMessages =>
|
|
|
|
key in errorMessages
|
2024-07-15 05:12:58 -04:00
|
|
|
|
2024-10-10 03:38:08 -04:00
|
|
|
export type LoadingErrorProps = {
|
|
|
|
errorCode: ConnectionError | 'i18n-error' | ''
|
|
|
|
}
|
2024-07-15 05:12:58 -04:00
|
|
|
|
2024-10-10 03:38:08 -04:00
|
|
|
// NOTE: i18n translations might not be loaded in the client at this point,
|
|
|
|
// so these translations have to be loaded from meta tags
|
|
|
|
export const LoadingError: FC<LoadingErrorProps> = ({ errorCode }) => {
|
|
|
|
return isHandledCode(errorCode) ? (
|
|
|
|
<p className="loading-screen-error">{getMeta(errorMessages[errorCode])}</p>
|
|
|
|
) : null
|
2024-07-15 05:12:58 -04:00
|
|
|
}
|