2022-04-25 01:51:30 +02:00
|
|
|
import { Paper, Typography } from "@mui/material";
|
|
|
|
import React, { useEffect, useState } from "react";
|
2021-06-13 17:05:40 +02:00
|
|
|
|
|
|
|
interface IProps {
|
2021-09-05 01:09:30 +02:00
|
|
|
onFinish: () => void;
|
2021-06-13 17:05:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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-06-13 17:05:40 +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
|
|
|
);
|
|
|
|
}
|