import {
Box,
Button,
Card,
CardBody,
CardHeader,
Container,
Heading,
HStack,
Image,
Input,
Link,
Stack,
StackDivider,
Text,
} from "@chakra-ui/react";
import { type FormEvent, useState } from "react";
export async function loader({ context }: { context: RequestContext }) {
const { current_user: currentUser } = context.data;
if (!currentUser)
throw new Response(null, {
status: 401,
});
if (!(currentUser.permissions & (1 << 5)))
throw new Response(null, {
status: 403,
});
return null;
}
export function meta() {
return [{ title: "Hammer - Car Crushers" }];
}
export default function () {
const [username, setUsername] = useState("");
const [uid, setUid] = useState("");
const [status, setStatus] = useState("");
const [visible, setVisible] = useState(false);
const [avatarUrl, setAvatarUrl] = useState("");
const [history, setHistory] = useState([]);
async function getHistory() {
const username = (document.getElementById("username") as HTMLInputElement)
.value;
if (username.length < 4) return alert("Username is too short!");
const historyResp = await fetch(`/api/game-bans/${username}/history`);
if (!historyResp.ok)
return alert(
`ERROR: ${((await historyResp.json()) as { error: string }).error}`,
);
const history: { [k: string]: any }[] = await historyResp.json();
if (!history.length) return alert("No history for this user.");
const cardList = [];
for (const entry of history) {
const url = entry.entity.properties.evidence.stringValue;
const isUrl = () => {
try {
new URL(url).href;
return true;
} catch {
return false;
}
};
cardList.push(
{new Date().toLocaleString()}
} spacing="4">
ACTION
{entry.entity.properties.action.stringValue}
EVIDENCE
{isUrl() ? (
{url}
) : (
url
)}
,
);
}
}
return (
User Lookup
{
const { data }: { data?: string } & FormEvent = e;
if (data?.match(/\W/)) e.preventDefault();
}}
placeholder="Roblox username"
/>
} spacing="6">
USERNAME
{username}
USER ID
{uid}
MODERATION STATUS
{status}
{history}
);
}