"use client";
import Link from "next/link";
import { formatDistanceToNow } from "date-fns";
import type { SourceState } from "@/lib/types";
import { CardBody } from "./CardBodies";
export function CardShell({
title,
meta,
onRefresh,
refreshing,
children,
}: {
title: string;
meta?: string;
onRefresh?: () => void;
refreshing?: boolean;
children: React.ReactNode;
}) {
return (
);
}
export function SourceCard({
state,
onRefresh,
refreshing,
}: {
state: SourceState;
onRefresh: () => void;
refreshing: boolean;
}) {
const { source, configured, hasModule, snapshot } = state;
const meta = snapshot?.ok
? `${formatDistanceToNow(new Date(snapshot.fetchedAt))} ago`
: undefined;
let body: React.ReactNode;
if (!hasModule) {
body = No fetcher for this source.;
} else if (!configured) {
body = (
Needs configuration.{" "}
Open settings →
);
} else if (!snapshot) {
body = Loading…;
} else if (!snapshot.ok) {
body = {snapshot.error ?? "Failed to load."};
} else {
body = ;
}
return (
{body}
);
}
function Note({ children, tone }: { children: React.ReactNode; tone?: "error" }) {
return (
{children}
);
}