Skip to content

Commit

Permalink
for now use local hosted api and update infoView
Browse files Browse the repository at this point in the history
  • Loading branch information
Moonded committed Feb 9, 2025
1 parent b82338b commit 4f3b29c
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 42 deletions.
Binary file added bun.lockb
Binary file not shown.
81 changes: 43 additions & 38 deletions src/lib/lizzy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,57 @@ export interface Warning {
ID: number;
IssuedTime: string; // ISO 8601 date string
Reason: string;
Issuer: string;
IssuerName: string;
}

export interface LizzyMemberInfo {
DiscordId: string;
Status: "Warned" | "Kicked" | "Banned";
Status: "Warn" | "Kick" | "Ban";
WarningLevel: number;
WarningCount: number;
LastWarning: string; // ISO 8601 date string
LastReason: string;
Resolve: null;
Resolved: boolean;
Warnings: Warning[];
}

export const data: LizzyMemberInfo = {
DiscordId: "879182739817238123",
Status: "Warned",
WarningLevel: 3,
WarningCount: 14,
LastWarning: "2021-10-10T12:00:00Z",
LastReason: "Because they've been a dick.",
Resolve: null,
Warnings: [
{
ID: 1,
IssuedTime: "2021-10-10T12:00:00Z",
Reason: "Because",
Issuer: "Manfred",
},
{
ID: 2,
IssuedTime: "2021-10-10T12:00:00Z",
Reason: "Because",
Issuer: "Gustaf",
},
{
ID: 3,
IssuedTime: "2021-10-10T12:00:00Z",
Reason: "Because",
Issuer: "Zhin",
},
{
ID: 4,
IssuedTime: "2021-10-10T12:00:00Z",
Reason: "Because",
Issuer: "Everyone",
},
],
};
export const data: LizzyMemberInfo = await fetch("http://localhost:3000/api/web/user/moderation/697882016892321843")
.then((response) => response)
.then((res) => res.json())
.catch((error) => console.error(error));

// export const data: LizzyMemberInfo = {
// DiscordId: "879182739817238123",
// Status: "Warned",
// WarningLevel: 3,
// WarningCount: 14,
// LastWarning: "2021-10-10T12:00:00Z",
// LastReason: "Because they've been a dick.",
// Resolve: null,
// Warnings: [
// {
// ID: 1,
// IssuedTime: "2021-10-10T12:00:00Z",
// Reason: "Because",
// Issuer: "Manfred",
// },
// {
// ID: 2,
// IssuedTime: "2021-10-10T12:00:00Z",
// Reason: "Because",
// Issuer: "Gustaf",
// },
// {
// ID: 3,
// IssuedTime: "2021-10-10T12:00:00Z",
// Reason: "Because",
// Issuer: "Zhin",
// },
// {
// ID: 4,
// IssuedTime: "2021-10-10T12:00:00Z",
// Reason: "Because",
// Issuer: "Everyone",
// },
// ],
// };
20 changes: 16 additions & 4 deletions src/views/InfoView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { DataRow } from "../components/DataRow";
import { discordData } from "../lib/discord";

export function InfoView() {
console.log(data);

const [info] = createResource(() => data);
const [user] = createResource(() => discordData);

Expand All @@ -15,18 +17,25 @@ export function InfoView() {

<div class="flex w-full flex-wrap items-start gap-x-8 gap-y-4">
<dl class="mr-auto grid grid-cols-[auto_auto] gap-x-4 gap-y-2 text-xl">
<DataRow key="Status:" value={info()?.Status} />
<DataRow key="Status:" value={info()?.Status ?? "Clear"} />
<DataRow key="Warning Level:" value={info()?.WarningLevel || 0} />
<DataRow key="Warning Count:" value={info()?.WarningCount || 0} />
</dl>

<dl class="mr-auto grid grid-cols-[auto_auto] gap-x-4 gap-y-2 text-xl">
<DataRow
key="Last Warning:"
value={<time datetime={info()?.LastWarning}>{new Date(info()?.LastWarning || 0).toLocaleString()}</time>}
value={<time datetime={info()?.LastWarning}>{ info()?.LastWarning ? new Date(info()?.LastWarning || 0).toLocaleString() : ""}</time>}
/>
<DataRow key="Last Reason:" value={info()?.LastReason} />
<DataRow key="Resolve:" value={info()?.Resolve} />
<DataRow
key="Resolved:"
value={
String(info()?.Resolved ?? true)
.charAt(0)
.toUpperCase() + String(info()?.Resolved ?? true).slice(1)
}
/>
</dl>
</div>

Expand All @@ -42,7 +51,10 @@ export function InfoView() {

<dl class="inline-grid grid-cols-[auto_auto] gap-x-4">
<DataRow key="Reason:" value={warning.Reason} />
<DataRow key="Issuer:" value={warning.Issuer} />
<DataRow
key="Issuer:"
value={warning.IssuerName.charAt(0).toUpperCase() + warning.IssuerName.slice(1)}
/>
</dl>
</li>
)}
Expand Down

0 comments on commit 4f3b29c

Please sign in to comment.