import { Button, MantineRadius } from "@mantine/core";
import { IconRefresh } from "@tabler/icons-react";
import { AnimatedRoundedProgress } from "../AnimatedRoundedProgress/AnimatedRoundedProgress";
import { UpdateStatus, useUpdater } from "@/app/hooks/useUpdater";
interface UpdateAlertProps {
radius?: MantineRadius;
}
export function UpdateAlert(props : UpdateAlertProps) {
const radius = props.radius || 0;
const {
appUpdateUrl,
kernelUpdateUrl,
downloadProgress,
updateStatus,
kernelOutdatedForNextAppUpdates,
downloadLastApplicationUpdate,
restartAppForUpdateApply,
} = useUpdater();
return (
<>
{updateStatus == UpdateStatus.IDLE && <>
{kernelOutdatedForNextAppUpdates && <>
>}
{!kernelOutdatedForNextAppUpdates && appUpdateUrl != "" && <>
>}
>}
{updateStatus == UpdateStatus.DOWNLOADING && <>
} fullWidth variant={'gradient'} gradient={{ from: 'blue', to: 'green', deg: 233 }} radius={radius}>
Downloading... {downloadProgress}%
>}
{updateStatus == UpdateStatus.COMPILE && <>
} onClick={restartAppForUpdateApply} fullWidth variant={'gradient'} gradient={{ from: 'teal', to: 'lime', deg: 233 }} radius={radius}>
Installing...
>}
{updateStatus == UpdateStatus.READY_FOR_RESTART && <>
>}
>
);
}