Skip to content

Commit e9aaabc

Browse files
committed
fix(fe): guard against null addresses in publications table
1 parent 0a2808c commit e9aaabc

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

apps/fe/app/(routes)/publications/_components/table/columns.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
"use client"
22

3-
import { type Publication, PublicationStatusSchema } from "@packages/schema"
4-
import { ChainIdToNetwork } from "@packages/utils"
5-
import type { ColumnDef } from "@tanstack/react-table"
6-
import { CircleOffIcon, CircleSlash2Icon, DicesIcon } from "lucide-react"
73
import { AddressDisplay } from "@/app/_components/address-display"
84
import { NetworkBadge, networkOptions } from "@/app/_components/network-badge"
95
import {
@@ -12,6 +8,10 @@ import {
128
} from "@/app/_components/publication-status-badge"
139
import { TypographySmall } from "@/app/_components/typography"
1410
import { Badge } from "@/components/ui/badge"
11+
import { type Publication, PublicationStatusSchema } from "@packages/schema"
12+
import { ChainIdToNetwork } from "@packages/utils"
13+
import type { ColumnDef } from "@tanstack/react-table"
14+
import { CircleOffIcon, CircleSlash2Icon, DicesIcon } from "lucide-react"
1515

1616
export const columns: ColumnDef<Publication>[] = [
1717
{
@@ -87,7 +87,17 @@ export const columns: ColumnDef<Publication>[] = [
8787
Publisher
8888
</TypographySmall>
8989
),
90-
cell: ({ row }) => <AddressDisplay address={row.getValue("publisher")} />,
90+
cell: ({ row }) => {
91+
const publisher = row.getValue<string | null>("publisher")
92+
if (!publisher) {
93+
return (
94+
<TypographySmall className="text-muted-foreground text-xs">
95+
96+
</TypographySmall>
97+
)
98+
}
99+
return <AddressDisplay address={publisher} />
100+
},
91101
},
92102
{
93103
accessorKey: "reviewers",

apps/fe/app/_components/address-display.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"use client"
22

3-
import { CheckIcon, CopyIcon } from "lucide-react"
4-
import { type FC, useCallback, useState } from "react"
53
import { Button } from "@/components/ui/button"
64
import { cn } from "@/lib/utils"
5+
import { CheckIcon, CopyIcon } from "lucide-react"
6+
import { type FC, useCallback, useState } from "react"
77
import { TypographySmall } from "./typography"
88

99
const DELAY = 2_000
@@ -16,6 +16,8 @@ type Props = {
1616
export const AddressDisplay: FC<Props> = ({ address, className }) => {
1717
const [copied, setCopied] = useState(false)
1818

19+
if (!address) return null
20+
1921
const displayAddress = `${address.slice(0, 6)}...${address.slice(-4)}`
2022

2123
const copyToClipboard = useCallback(

0 commit comments

Comments
 (0)