chore: add ts-ignore where needed

This commit is contained in:
CyberL1 2025-01-16 13:33:08 +01:00
parent e47e87199f
commit 238c5a2cec
6 changed files with 24 additions and 28 deletions

View File

@ -8,6 +8,7 @@ export default function ContainerInfo() {
useEffect(() => { useEffect(() => {
const updateInfo = async () => { const updateInfo = async () => {
const stats = await fetch(`https://api.ssh.surf/info`, { const stats = await fetch(`https://api.ssh.surf/info`, {
// @ts-ignore
headers: { "x-ssh-auth": localStorage.getItem("key") }, headers: { "x-ssh-auth": localStorage.getItem("key") },
}); });

View File

@ -9,6 +9,7 @@ export default function Login() {
const data = Object.fromEntries(formData); const data = Object.fromEntries(formData);
const hello = await fetch(`https://api.ssh.surf/hello`, { const hello = await fetch(`https://api.ssh.surf/hello`, {
// @ts-ignore
headers: { "x-ssh-auth": data.key }, headers: { "x-ssh-auth": data.key },
}); });

View File

@ -58,7 +58,7 @@ export default function WebTerminal() {
terminal.dispose(); terminal.dispose();
}; };
} }
}, []); }, [container]);
return <div ref={terminalRef} style={{ height: "auto" }} />; return <div ref={terminalRef} style={{ height: "auto" }} />;
} }

View File

@ -8,6 +8,7 @@ import TerminalPage from "./pages/container/terminal.tsx";
async function loader() { async function loader() {
const info = await fetch(`https://api.ssh.surf/info`, { const info = await fetch(`https://api.ssh.surf/info`, {
// @ts-ignore
headers: { "x-ssh-auth": localStorage.getItem("key") }, headers: { "x-ssh-auth": localStorage.getItem("key") },
}); });

View File

@ -6,15 +6,15 @@ import ContainerInfo from "../../components/ContainerInfo";
export default function ContainerPage() { export default function ContainerPage() {
let container = useLoaderData(); let container = useLoaderData();
const revalidator = useRevalidator();
const [isPowerStateLocked, setPowerStateLocked] = useState<boolean>();
if (!container.data) { if (!container.data) {
return "Container not found"; return "Container not found";
} }
container = container.data as InfoData; container = container.data as InfoData;
const revalidator = useRevalidator();
const [isPowerStateLocked, setPowerStateLocked] = useState<boolean>();
return ( return (
<Paper square sx={{ padding: 1 }}> <Paper square sx={{ padding: 1 }}>
<Paper sx={{ display: "flex" }} variant="outlined"> <Paper sx={{ display: "flex" }} variant="outlined">

View File

@ -1,24 +1,17 @@
import { useLoaderData } from "react-router"; import { useLoaderData } from "react-router";
import { Container } from "../../types"; import { InfoData } from "../../types";
import { Paper, Typography } from "@mui/material"; import { Paper, Typography } from "@mui/material";
import WebTerminal from "../../components/WebTerminal"; import WebTerminal from "../../components/WebTerminal";
export async function Loader() {
const info = await fetch(`https://api.ssh.surf/info`, {
headers: { "x-ssh-auth": localStorage["key"] },
});
const data = await info.json();
return data;
}
export default function TerminalPage() { export default function TerminalPage() {
const container = useLoaderData() as Container & { statusCode: number }; let container = useLoaderData();
if (container.statusCode === 404) { if (!container.data) {
return "Container not found"; return "Container not found";
} }
container = container.data as InfoData;
return ( return (
<Paper square sx={{ padding: 1 }}> <Paper square sx={{ padding: 1 }}>
<Paper sx={{ display: "flex" }} variant="outlined"> <Paper sx={{ display: "flex" }} variant="outlined">