Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move card types to declaration file
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 9a5820c commit b6f0730
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 29 deletions.
20 changes: 7 additions & 13 deletions app/routes/mod-queue.tsx
Expand Up @@ -9,6 +9,7 @@ import {
} from "@chakra-ui/react";
import { useState } from "react";
import AppealCard from "../../components/AppealCard.js";
import ReportCard from "../../components/ReportCard.js";
import { useLoaderData } from "@remix-run/react";

export async function loader({ context }: { context: RequestContext }) {
Expand Down Expand Up @@ -114,19 +115,12 @@ export default function () {
for (const entry of entryData) {
switch (queue_type) {
case "appeal":
newEntries.push(
<AppealCard
{...(entry as {
ban_reason: string;
createdAt: number;
discriminator: string;
id: string;
learned: string;
reason_for_unban: string;
username: string;
})}
/>
);
newEntries.push(<AppealCard {...(entry as AppealCardProps)} />);

break;

case "report":
newEntries.push(<ReportCard {...(entry as ReportCardProps)} />);
}
}

Expand Down
10 changes: 1 addition & 9 deletions components/AppealCard.tsx
Expand Up @@ -12,15 +12,7 @@ import {
} from "@chakra-ui/react";
import { useEffect, useState } from "react";

export default function (props: {
ban_reason: string;
createdAt: number;
discriminator: string;
id: string;
learned: string;
reason_for_unban: string;
username: string;
}) {
export default function (props: AppealCardProps) {
const [dateString, setDateString] = useState(
new Date(props.createdAt).toUTCString()
);
Expand Down
8 changes: 1 addition & 7 deletions components/ReportCard.tsx
Expand Up @@ -13,13 +13,7 @@ import {
} from "@chakra-ui/react";
import { useState } from "react";

export default function (props: {
attachment: string;
attachment_loading?: boolean;
reporter?: { [k: string]: any };
target_ids: number[];
target_usernames: string[];
}) {
export default function (props: ReportCardProps) {
const targetMap: { [k: number]: string } = {};
const [attachmentReady, setAttachmentReady] = useState(
!props.attachment_loading
Expand Down
18 changes: 18 additions & 0 deletions index.d.ts
Expand Up @@ -23,6 +23,24 @@ declare global {
extractCriticalToChunks: (html: string) => EmotionCriticalToChunks;
}

interface AppealCardProps {
ban_reason: string;
createdAt: number;
discriminator: string;
id: string;
learned: string;
reason_for_unban: string;
username: string;
}

interface ReportCardProps {
attachment: string;
attachment_loading?: boolean;
reporter?: { [k: string]: any };
target_ids: number[];
target_usernames: string[];
}

export function createEmotionServer(cache: EmotionCache): EmotionServer;
}

Expand Down

0 comments on commit b6f0730

Please sign in to comment.