From 25f075cf1281e875365c7466d42c26c58500bfe4 Mon Sep 17 00:00:00 2001 From: Jacob Shufro Date: Thu, 31 Oct 2024 02:55:28 -0400 Subject: [PATCH] Clean up lint failures --- src/components/OperatorInfoAlert.tsx | 17 +++++++++-------- src/hooks/useGetOperatorInfo.tsx | 10 +++++++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/components/OperatorInfoAlert.tsx b/src/components/OperatorInfoAlert.tsx index 0838d18..116208d 100644 --- a/src/components/OperatorInfoAlert.tsx +++ b/src/components/OperatorInfoAlert.tsx @@ -1,7 +1,8 @@ import { Alert, Typography } from "@mui/material"; import useIsValidSignedMessage from "../hooks/useIsValidSignedMessage"; -import { OperatorInfo } from "../Api"; +import type { OperatorInfo } from "../Api"; import useGetOperatorInfo from "../hooks/useGetOperatorInfo"; +import React from "react"; export default function OperatorInfoAlert({ signedMessage, @@ -12,9 +13,9 @@ export default function OperatorInfoAlert({ }) { const { data: isValid } = useIsValidSignedMessage(signedMessage); - let { data: opInfo } = useGetOperatorInfo({ - signedMessage: signedMessage, - operatorType: operatorType, + const { data: opInfo } = useGetOperatorInfo({ + signedMessage, + operatorType, enabled: !!isValid, }); @@ -49,11 +50,11 @@ function getQuotaText({ operatorInfo }: { operatorInfo: OperatorInfo }) { const remaining = operatorInfo.quotaSettings.count - operatorInfo.credentialEvents.length; - var usageMsg = `You have not used the Rescue Node in the past ${windowInDays} days.`; - var activeCredMsg = `You do not currently have an active credential.`; - var remainingMsg = `You have ${remaining} usages remaining.`; + let usageMsg = `You have not used the Rescue Node in the past ${windowInDays} days.`; + let activeCredMsg = `You do not currently have an active credential.`; + let remainingMsg = `You have ${remaining} usages remaining.`; - if (used == 0) { + if (used === 0) { return `${usageMsg} ${activeCredMsg} ${remainingMsg}`; diff --git a/src/hooks/useGetOperatorInfo.tsx b/src/hooks/useGetOperatorInfo.tsx index 3536563..de617be 100644 --- a/src/hooks/useGetOperatorInfo.tsx +++ b/src/hooks/useGetOperatorInfo.tsx @@ -1,5 +1,6 @@ import { useQuery } from "wagmi"; -import { Api, OperatorInfo } from "../Api"; +import { Api } from "../Api"; +import type { OperatorInfo } from "../Api"; // Hook to retrieve OperatorInfo from API export default function useGetOperatorInfo({ @@ -26,10 +27,13 @@ export default function useGetOperatorInfo({ if (error) { throw new Error(error); } - return data!; + if (!data) { + throw new Error("null data received from api"); + } + return data; }, { - enabled: enabled, + enabled, }, ); }