Skip to content

Commit

Permalink
Clean up lint failures
Browse files Browse the repository at this point in the history
  • Loading branch information
jshufro committed Oct 31, 2024
1 parent 7fd9849 commit 25f075c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
17 changes: 9 additions & 8 deletions src/components/OperatorInfoAlert.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
});

Expand Down Expand Up @@ -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}`;
Expand Down
10 changes: 7 additions & 3 deletions src/hooks/useGetOperatorInfo.tsx
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -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,
},
);
}

0 comments on commit 25f075c

Please sign in to comment.