BlockHeightWidget.tsx raw

   1  import {
   2    Card,
   3    CardContent,
   4    CardHeader,
   5    CardTitle,
   6  } from "src/components/ui/card";
   7  import { useMempoolApi } from "src/hooks/useMempoolApi";
   8  
   9  export function BlockHeightWidget() {
  10    const { data: blocks } = useMempoolApi<{ height: number }[]>("/v1/blocks");
  11  
  12    if (!blocks?.length) {
  13      return null;
  14    }
  15    return (
  16      <Card>
  17        <CardHeader>
  18          <CardTitle>Block Height</CardTitle>
  19        </CardHeader>
  20        <CardContent className="mt-6">
  21          <p className="text-4xl font-semibold">{blocks[0].height}</p>
  22        </CardContent>
  23      </Card>
  24    );
  25  }
  26