From bd3bc877f5be120c80f47cc8d403c8331e50a940 Mon Sep 17 00:00:00 2001
From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com>
Date: Sat, 25 May 2024 13:07:08 -0400
Subject: [PATCH] fix(stats-web): linting issues
---
.../deployments/[dseq]/DeploymentInfo.tsx | 15 ++--------
.../[address]/deployments/[dseq]/EventRow.tsx | 30 +++++++++++++++++++
.../transactions/TransactionTypeCell.tsx | 22 ++++++++++++++
.../[address]/transactions/columns.tsx | 14 ++-------
stats-web/src/components/SearchBar.tsx | 1 +
.../components/blockchain/TransactionRow.tsx | 5 ++--
stats-web/src/components/table/data-table.tsx | 2 ++
stats-web/src/store/networkStore.ts | 4 ++-
8 files changed, 65 insertions(+), 28 deletions(-)
create mode 100644 stats-web/src/app/addresses/[address]/deployments/[dseq]/EventRow.tsx
create mode 100644 stats-web/src/app/addresses/[address]/transactions/TransactionTypeCell.tsx
diff --git a/stats-web/src/app/addresses/[address]/deployments/[dseq]/DeploymentInfo.tsx b/stats-web/src/app/addresses/[address]/deployments/[dseq]/DeploymentInfo.tsx
index fac6b9e65..813025f93 100644
--- a/stats-web/src/app/addresses/[address]/deployments/[dseq]/DeploymentInfo.tsx
+++ b/stats-web/src/app/addresses/[address]/deployments/[dseq]/DeploymentInfo.tsx
@@ -8,15 +8,14 @@ import { Title } from "@/components/Title";
import { Badge } from "@/components/ui/badge";
import { Card, CardContent } from "@/components/ui/card";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
-import { useFriendlyMessageType } from "@/hooks/useFriendlyMessageType";
import { getSplitText } from "@/hooks/useShortText";
import { roundDecimal, udenomToDenom } from "@/lib/mathHelpers";
import { bytesToShrink } from "@/lib/unitUtils";
import { UrlService } from "@/lib/urlUtils";
-import { cn } from "@/lib/utils";
import { DeploymentDetail } from "@/types";
import Link from "next/link";
import { FormattedNumber, FormattedTime } from "react-intl";
+import { EventRow } from "./EventRow";
interface IProps {
deployment: DeploymentDetail;
@@ -90,17 +89,7 @@ export function DeploymentInfo({ deployment }: IProps) {
{deployment.events.map((event, i) => (
-
-
-
- {getSplitText(event.txHash, 6, 6)}
-
-
- {useFriendlyMessageType(event.type)}
-
-
-
-
+
))}
diff --git a/stats-web/src/app/addresses/[address]/deployments/[dseq]/EventRow.tsx b/stats-web/src/app/addresses/[address]/deployments/[dseq]/EventRow.tsx
new file mode 100644
index 000000000..7615c4f39
--- /dev/null
+++ b/stats-web/src/app/addresses/[address]/deployments/[dseq]/EventRow.tsx
@@ -0,0 +1,30 @@
+import { TableCell, TableRow } from "@/components/ui/table";
+import { useFriendlyMessageType } from "@/hooks/useFriendlyMessageType";
+import { getSplitText } from "@/hooks/useShortText";
+import { UrlService } from "@/lib/urlUtils";
+import Link from "next/link";
+import { FormattedTime } from "react-intl";
+
+export const EventRow = ({
+ event
+}: React.PropsWithChildren<{
+ event: {
+ txHash: string;
+ date: string;
+ type: string;
+ };
+}>) => {
+ return (
+
+
+
+ {getSplitText(event.txHash, 6, 6)}
+
+
+ {useFriendlyMessageType(event.type)}
+
+
+
+
+ );
+};
diff --git a/stats-web/src/app/addresses/[address]/transactions/TransactionTypeCell.tsx b/stats-web/src/app/addresses/[address]/transactions/TransactionTypeCell.tsx
new file mode 100644
index 000000000..2b83fcf22
--- /dev/null
+++ b/stats-web/src/app/addresses/[address]/transactions/TransactionTypeCell.tsx
@@ -0,0 +1,22 @@
+import { Badge } from "@/components/ui/badge";
+import { useFriendlyMessageType } from "@/hooks/useFriendlyMessageType";
+import { TransactionRowType } from "@/lib/zod/transactionRow";
+import { Row } from "@tanstack/react-table";
+
+export const EventRow = ({
+ row
+}: React.PropsWithChildren<{
+ row: Row;
+}>) => {
+ const friendlyMessage = useFriendlyMessageType(row.original.messages[0].type);
+ const firstMessageType = row.original.messages[0].isReceiver ? "Receive" : friendlyMessage;
+
+ return (
+ <>
+
+ {firstMessageType}
+
+ {row.original.messages.length > 1 ? " +" + (row.original.messages.length - 1) : ""}
+ >
+ );
+};
diff --git a/stats-web/src/app/addresses/[address]/transactions/columns.tsx b/stats-web/src/app/addresses/[address]/transactions/columns.tsx
index 1658389ea..2886e2fe2 100644
--- a/stats-web/src/app/addresses/[address]/transactions/columns.tsx
+++ b/stats-web/src/app/addresses/[address]/transactions/columns.tsx
@@ -4,12 +4,11 @@ import { DataTableColumnHeader } from "@/components/table/data-table-column-head
import { UrlService } from "@/lib/urlUtils";
import { AccessorColumnDef } from "@tanstack/react-table";
import Link from "next/link";
-import { Badge } from "@/components/ui/badge";
import { getSplitText } from "@/hooks/useShortText";
-import { useFriendlyMessageType } from "@/hooks/useFriendlyMessageType";
import { AKTAmount } from "@/components/AKTAmount";
import { FormattedRelativeTime } from "react-intl";
import { TransactionRowType } from "@/lib/zod/transactionRow";
+import { EventRow } from "./TransactionTypeCell";
export const columns: AccessorColumnDef[] = [
{
@@ -28,16 +27,7 @@ export const columns: AccessorColumnDef[] = [
enableSorting: false,
header: ({ column }) => ,
cell: ({ row }) => {
- const firstMessageType = row.original.messages[0].isReceiver ? "Receive" : useFriendlyMessageType(row.original.messages[0].type);
-
- return (
- <>
-
- {firstMessageType}
-
- {row.original.messages.length > 1 ? " +" + (row.original.messages.length - 1) : ""}
- >
- );
+ return ;
}
},
{
diff --git a/stats-web/src/components/SearchBar.tsx b/stats-web/src/components/SearchBar.tsx
index f088348bd..c34e57cde 100644
--- a/stats-web/src/components/SearchBar.tsx
+++ b/stats-web/src/components/SearchBar.tsx
@@ -29,6 +29,7 @@ const SearchBar: React.FunctionComponent = ({}) => {
useEffect(() => {
setSearchType(getSearchType(searchTerms));
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [searchTerms]);
function onSearchTermsChange(ev: React.ChangeEvent) {
diff --git a/stats-web/src/components/blockchain/TransactionRow.tsx b/stats-web/src/components/blockchain/TransactionRow.tsx
index a1ea04416..c242aba29 100644
--- a/stats-web/src/components/blockchain/TransactionRow.tsx
+++ b/stats-web/src/components/blockchain/TransactionRow.tsx
@@ -18,7 +18,8 @@ type Props = {
export const TransactionRow: React.FunctionComponent = ({ transaction, blockHeight, isSimple }) => {
const txHash = getSplitText(transaction.hash, 6, 6);
- const firstMessageType = transaction.messages[0].isReceiver ? "Receive" : useFriendlyMessageType(transaction.messages[0].type);
+ const friendlyMessage = useFriendlyMessageType(transaction.messages[0].type);
+ const firstMessageType = transaction.messages[0].isReceiver ? "Receive" : friendlyMessage;
return (
@@ -46,7 +47,7 @@ export const TransactionRow: React.FunctionComponent = ({ transaction, bl
{blockHeight}
-
+
({
table.resetPageIndex();
}
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [sorting]);
useEffect(() => {
@@ -126,6 +127,7 @@ export function DataTable({
table.resetPageIndex();
}
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [columnFilters]);
return (
diff --git a/stats-web/src/store/networkStore.ts b/stats-web/src/store/networkStore.ts
index 9adbab9cd..32e3b2da5 100644
--- a/stats-web/src/store/networkStore.ts
+++ b/stats-web/src/store/networkStore.ts
@@ -59,6 +59,8 @@ export const initiateNetworkData = async () => {
const selectedNetwork = atom(networks[0]);
-export default {
+const networkStore = {
selectedNetwork
};
+
+export default networkStore;