bitburner-src/src/Infiltration/ui/Countdown.tsx

25 lines
557 B
TypeScript
Raw Normal View History

2022-04-25 01:51:30 +02:00
import { Paper, Typography } from "@mui/material";
import React, { useEffect, useState } from "react";
interface IProps {
2021-09-05 01:09:30 +02:00
onFinish: () => void;
}
export function Countdown(props: IProps): React.ReactElement {
2021-09-05 01:09:30 +02:00
const [x, setX] = useState(3);
useEffect(() => {
if (x === 0) {
props.onFinish();
return;
}
2022-04-25 01:18:39 +02:00
setTimeout(() => setX(x - 1), 300);
2021-09-05 01:09:30 +02:00
});
2021-09-05 01:09:30 +02:00
return (
2022-04-25 01:18:39 +02:00
<Paper sx={{ p: 1, textAlign: "center" }}>
<Typography variant="h4">Get Ready!</Typography>
<Typography variant="h4">{x}</Typography>
</Paper>
2021-09-05 01:09:30 +02:00
);
}