nitro-react/src/components/loading/LoadingView.tsx

44 lines
1.5 KiB
TypeScript
Raw Normal View History

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;
percent: number;
2022-02-21 19:34:12 +01:00
}
export const LoadingView: FC<LoadingViewProps> = props =>
{
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">
<Base className="connecting-duck" />
2022-03-15 10:59:51 +01:00
<Column size={ 6 } className="text-center py-4">
{ isError && (message && message.length) ?
2022-04-04 04:45:47 +02:00
<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:59:51 +01:00
</Column>
</Column>
</Base>
2022-02-21 19:34:12 +01:00
</Column>
);
}