mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-26 11:10:58 +02:00
41 lines
991 B
TypeScript
41 lines
991 B
TypeScript
import { Typography } from "@mui/material";
|
|
import React, { useState, useEffect } from "react";
|
|
import WifiIcon from "@mui/icons-material/Wifi";
|
|
import WifiOffIcon from "@mui/icons-material/WifiOff";
|
|
|
|
interface baubleProps {
|
|
isConnected: () => boolean;
|
|
}
|
|
|
|
export const ConnectionBauble = (props: baubleProps): React.ReactElement => {
|
|
const [connection, setConnection] = useState(props.isConnected());
|
|
|
|
useEffect(() => {
|
|
const timer = setInterval(() => {
|
|
setConnection(props.isConnected());
|
|
}, 1000);
|
|
return () => clearInterval(timer);
|
|
});
|
|
|
|
return (
|
|
<>
|
|
<Typography>
|
|
Status:
|
|
<Typography component="span" color={connection ? "primary" : "error"}>
|
|
{connection ? (
|
|
<>
|
|
Online
|
|
<WifiIcon />
|
|
</>
|
|
) : (
|
|
<>
|
|
Offline
|
|
<WifiOffIcon />
|
|
</>
|
|
)}
|
|
</Typography>
|
|
</Typography>
|
|
</>
|
|
);
|
|
};
|