From 8012e827929f26e6f5d7716115d997018a85b125 Mon Sep 17 00:00:00 2001 From: Kevin O'Connell Date: Fri, 28 Jun 2024 16:18:02 -0400 Subject: [PATCH] add other hubs to explorer --- src/app/[identifier]/page.tsx | 49 ++++++++++++++++++++++++++++------- src/constants.ts | 3 +-- src/lib/utils.ts | 2 +- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/app/[identifier]/page.tsx b/src/app/[identifier]/page.tsx index a8743e9..9f5e959 100644 --- a/src/app/[identifier]/page.tsx +++ b/src/app/[identifier]/page.tsx @@ -3,6 +3,7 @@ import Modal from '@/components/modal-component'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader } from '@/components/ui/card'; import { useClipboard } from '@/hooks/useClipboard'; +import { capitalizeNickname } from '@/lib/helpers'; import { fetchCastAndFidData } from '@/lib/utils'; import { CopyCheckIcon, CopyIcon, UserIcon } from 'lucide-react'; import Link from 'next/link'; @@ -13,6 +14,12 @@ interface ResponseProps { params: { identifier: string }; } +const hubs = [ + { shortname: 'hoyt', url: 'https://hoyt.farcaster.xyz:2281' }, + { shortname: 'Neynar hub', url: 'https://hub-api.neynar.com' }, + { shortname: 'lamia', url: 'https://lamia.farcaster.xyz:2281' }, +]; + const isNumeric = (str: string): boolean => { return !isNaN(Number(str)) && !isNaN(parseFloat(str)) && !/^0x/.test(str); }; @@ -42,6 +49,7 @@ export default function Page({ params }: ResponseProps) { const [modalTitle, setModalTitle] = useState(''); const [isModalOpen, setIsModalOpen] = useState(false); const [loading, setLoading] = useState(true); + const [showOtherHubs, setShowOtherHubs] = useState(false); const fetchData = async () => { setLoading(true); @@ -138,10 +146,10 @@ export default function Page({ params }: ResponseProps) { neynarCastHubMissing, } = data ?? {}; - const hubs = data?.hubData ?? []; - const nemes = hubs[0] ?? {}; - const neynarHub = hubs[1] ?? {}; - const { author: nemesAuthor, cast: nemesCast } = nemes || {}; + const hubsData = data?.hubData ?? []; + const hoyt = hubsData[0] ?? {}; + const neynarHub = hubsData[1] ?? {}; + const { author: hoytAuthor, cast: hoytCast } = hoyt || {}; const { author: neynarHubAuthor, cast: neynarHubCast } = neynarHub || {}; const { author: warpcastAuthor, cast: warpcastCast } = warpcast || {}; const { author: neynarAuthor, cast: neynarCast } = neynar || {}; @@ -167,7 +175,7 @@ export default function Page({ params }: ResponseProps) { return ( + )} + + {showOtherHubs && ( +
+ {hubs.slice(2).map((hub, index) => ( +
+ {renderHeader( + `${capitalizeNickname(hub.shortname)}`, + data?.hubData?.[index + 2], + [] + )} +
+ ))} +
+ )} ); diff --git a/src/constants.ts b/src/constants.ts index 8f917c2..ac754f5 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -6,10 +6,9 @@ export const seo = { }; export const hubs = [ - // {"shortname": "nemes", "url": "https://nemes.farcaster.xyz:2281"}, { shortname: 'hoyt', url: 'https://hoyt.farcaster.xyz:2281' }, { shortname: 'Neynar hub', url: 'https://hub-api.neynar.com' }, - // {"shortname": "lamia", "url": "https://lamia.farcaster.xyz:2281"}, + { shortname: 'lamia', url: 'https://lamia.farcaster.xyz:2281' }, ]; export const neynarHub = { diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 98eb47a..e73b3ac 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -5,7 +5,7 @@ import { hubs, tokenBearer } from '@/constants'; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } -interface HubType { +export interface HubType { shortname: string; url: string; }