import Typography from "@material-ui/core/Typography";
import { CheckCircle, Error, RadioButtonUnchecked } from "@material-ui/icons";
import clsx from "clsx";
import React, { useEffect, useState } from "react";
import CircularProgress from "../CircularProgress";
import s from "./Statuses";
const AwaitStatus = -1;
const ErrorStatus = -100;
const CompleteStatus = 100;
const PHASES = [
{
label: "Pending",
events: [s.Pending, s.Sent],
progress: () => CompleteStatus,
},
{
label: "Received",
events: [s.ManifestAccepted, s.ManifestReceived, s.ManifestRejected],
progress: (msg) => {
if (msg === s.ManifestRejected) return ErrorStatus;
return CompleteStatus;
},
},
{
label: "Precondition",
events: [s.PreconditionAwait, s.PreconditionSuceeded],
progress: () => CompleteStatus,
},
{
label: "Download",
events: [
s.Downloading,
s.DownloadStarted,
s.DownloadCompleted,
s.DownloadFailed,
s.PackageDownloadStarted,
],
progress: (msg, progress) => {
if (msg === s.DownloadFailed) return ErrorStatus;
return progress;
},
},
{
label: "Approved",
events: [s.PackageDownloadCompleted, s.InstallApprovalAwait],
progress: () => AwaitStatus,
},
{
label: "Install",
events: [
s.InstallApprovalReceived,
s.InstallStarted,
s.Installing,
s.InstallSucceeded,
s.InstallFailed,
s.RequirementsFailed,
s.InstallScheduled,
],
progress: (msg, progress) => {
if (msg === s.InstallFailed || msg === s.RequirementsFailed) return ErrorStatus;
if (msg === s.PackageInstallCompleted) return CompleteStatus;
return progress;
},
},
{
label: "Updated",
events: [s.ManifestSucceeded],
progress: (_msg, _progress) => CompleteStatus,
},
];
const Progress = ({ value, classes }) => {
if (value === 100)
return (