From 34075dec1a3ef7c7bf9294a081ec94e62f3a2d5d Mon Sep 17 00:00:00 2001 From: "Kalle (Sendou)" <38327916+Sendouc@users.noreply.github.com> Date: Mon, 27 Dec 2021 16:39:53 +0200 Subject: [PATCH] Fix type errors --- .../to/$organization.$tournament/manage-roster.tsx | 8 ++++---- app/utils/hooks.ts | 12 ++---------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/app/routes/to/$organization.$tournament/manage-roster.tsx b/app/routes/to/$organization.$tournament/manage-roster.tsx index c05dc62df..dfcac5528 100644 --- a/app/routes/to/$organization.$tournament/manage-roster.tsx +++ b/app/routes/to/$organization.$tournament/manage-roster.tsx @@ -12,7 +12,6 @@ import { import invariant from "tiny-invariant"; import { z } from "zod"; import { Alert } from "~/components/Alert"; -import { Button } from "~/components/Button"; import { Catcher } from "~/components/Catcher"; import { FormErrorMessage } from "~/components/FormErrorMessage"; import { FormInfoText } from "~/components/FormInfoText"; @@ -35,7 +34,7 @@ import { import { getTrustingUsers } from "~/services/user"; import styles from "~/styles/tournament-manage-roster.css"; import { parseRequestFormData, requireUser } from "~/utils"; -import { useBaseURL, useIsSubmitting, useTimeoutState } from "~/utils/hooks"; +import { useBaseURL, useTimeoutState } from "~/utils/hooks"; export const links: LinksFunction = () => { return [{ rel: "stylesheet", href: styles }]; @@ -122,7 +121,9 @@ export const action: ActionFunction = async ({ } default: { const exhaustive: never = data; - throw new Response("Bad Request", { status: 400 }); + throw new Response(`Unknown action: ${JSON.stringify(exhaustive)}`, { + status: 400, + }); } } }; @@ -167,7 +168,6 @@ export default function ManageRosterPage() { const { ownTeam, trustingUsers } = useLoaderData(); const baseURL = useBaseURL(); const location = useLocation(); - const isSubmitting = useIsSubmitting("POST"); const urlWithInviteCode = `${baseURL}${location.pathname.replace( "manage-roster", diff --git a/app/utils/hooks.ts b/app/utils/hooks.ts index 8c9708af8..a83cd768e 100644 --- a/app/utils/hooks.ts +++ b/app/utils/hooks.ts @@ -1,6 +1,6 @@ -import { useMatches, useTransition } from "remix"; -import { LoggedInUser } from "."; import * as React from "react"; +import { useMatches } from "remix"; +import { LoggedInUser } from "."; export const useUser = () => { const [root] = useMatches(); @@ -14,14 +14,6 @@ export const useBaseURL = () => { return root.data.baseURL as string; }; -export const useIsSubmitting = (method: "POST" | "DELETE") => { - const transition = useTransition(); - - return ( - transition.state !== "idle" && transition.submission?.method === method - ); -}; - // TODO: fix causes memory leak /** @link https://stackoverflow.com/a/64983274 */ export const useTimeoutState = (