Skip to content

Commit

Permalink
Merge pull request #17 from neynarxyz/kevin/neyn-1944-explorer-add-ot…
Browse files Browse the repository at this point in the history
…her-hubs-to-explorer-as-option

add other hubs to explorer
  • Loading branch information
MrKevinOConnell authored Jun 28, 2024
2 parents c610075 + e35f808 commit 4b4c958
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
49 changes: 40 additions & 9 deletions src/app/[identifier]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
};
Expand Down Expand Up @@ -42,6 +49,7 @@ export default function Page({ params }: ResponseProps) {
const [modalTitle, setModalTitle] = useState<string>('');
const [isModalOpen, setIsModalOpen] = useState(false);
const [loading, setLoading] = useState(true);
const [showOtherHubs, setShowOtherHubs] = useState(false);

const fetchData = async () => {
setLoading(true);
Expand Down Expand Up @@ -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 || {};
Expand All @@ -167,7 +175,7 @@ export default function Page({ params }: ResponseProps) {

return (
<button onClick={() => openModal(label, data, missingObjects)}>
<Card className="hover:bg-slate-100 rounded-lg relative border-black flex flex-col items-center justify-center">
<Card className="min-w-36 hover:bg-slate-100 rounded-lg relative border-black flex flex-col items-center justify-center">
<CardHeader className="text-center relative w-full">
{label}
</CardHeader>
Expand Down Expand Up @@ -237,13 +245,13 @@ export default function Page({ params }: ResponseProps) {
)}
{renderHeader('Warpcast API', warpcastCast, warpcastCastMissing)}
{renderHeader(
'Warpcast Hub (Hoyt)',
nemesAuthor,
capitalizeNickname(hoyt.name),
hoytAuthor,
warpcastAuthorHubMissing
)}
{renderHeader(
'Warpcast Hub (Hoyt)',
nemesCast,
capitalizeNickname(hoyt.name),
hoytCast,
warpcastCastHubMissing
)}
{renderHeader(
Expand All @@ -257,6 +265,29 @@ export default function Page({ params }: ResponseProps) {
</>
)}
</div>

{!showOtherHubs && (
<Button
className="mt-10 min-h-10 px-4 py-2 bg-purple-500 text-white hover:bg-purple-700 rounded-lg"
onClick={() => setShowOtherHubs(true)}
>
Check other hubs
</Button>
)}

{showOtherHubs && (
<div className="flex md:flex-row flex-col items-center my-5">
{hubs.slice(2).map((hub, index) => (
<div key={index}>
{renderHeader(
`${capitalizeNickname(hub.shortname)}`,
data?.hubData?.[index + 2],
[]
)}
</div>
))}
</div>
)}
</div>
</>
);
Expand Down
3 changes: 1 addition & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 4b4c958

Please sign in to comment.