2022-03-15 10:59:51 +01:00
|
|
|
import { FC, useEffect } from 'react';
|
2022-03-12 06:23:57 +01:00
|
|
|
import { NotificationUtilities } from '../../api';
|
2022-03-24 03:56:18 +01:00
|
|
|
import { Base, Column, LayoutProgressBar, Text } from '../../common';
|
2022-02-21 19:34:12 +01:00
|
|
|
|
|
|
|
interface LoadingViewProps
|
|
|
|
{
|
|
|
|
isError: boolean;
|
|
|
|
message: string;
|
2022-03-15 10:11:11 +01:00
|
|
|
percent: number;
|
2022-02-21 19:34:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export const LoadingView: FC<LoadingViewProps> = props =>
|
|
|
|
{
|
2022-03-15 10:11:11 +01:00
|
|
|
const { isError = false, message = '', percent = 0 } = props;
|
2022-02-21 19:34:12 +01:00
|
|
|
|
|
|
|
useEffect(() =>
|
|
|
|
{
|
|
|
|
if(!isError) return;
|
|
|
|
|
|
|
|
NotificationUtilities.simpleAlert(message, null, null, null, 'Connection Error');
|
|
|
|
}, [ isError, message ]);
|
|
|
|
|
|
|
|
return (
|
2022-03-15 10:59:51 +01:00
|
|
|
<Column fullHeight position="relative" className="nitro-loading">
|
|
|
|
<Base fullHeight className="container h-100">
|
|
|
|
<Column fullHeight alignItems="center" justifyContent="end">
|
2022-03-15 10:11:11 +01:00
|
|
|
<Base className="connecting-duck" />
|
2022-03-15 10:59:51 +01:00
|
|
|
<Column size={ 6 } className="text-center py-4">
|
2022-03-15 10:11:11 +01:00
|
|
|
{ isError && (message && message.length) ?
|
|
|
|
<Base className="fs-4 text-shadow">{message}</Base>
|
|
|
|
:
|
|
|
|
<>
|
2022-03-15 10:59:51 +01:00
|
|
|
<Text fontSize={ 4 } variant="white" className="text-shadow">{ percent.toFixed() }%</Text>
|
2022-03-24 03:56:18 +01:00
|
|
|
<LayoutProgressBar progress={ percent } className="mt-2 large" />
|
2022-03-15 10:11:11 +01:00
|
|
|
</>
|
|
|
|
}
|
|
|
|
|
2022-03-15 10:59:51 +01:00
|
|
|
</Column>
|
|
|
|
</Column>
|
|
|
|
</Base>
|
2022-02-21 19:34:12 +01:00
|
|
|
</Column>
|
|
|
|
);
|
|
|
|
}
|