Skip to content

Commit

Permalink
feat: Hide swarm expiry date when it is not configured (#414)
Browse files Browse the repository at this point in the history
* feat: Hide swarm expiry date when it is not configured

* style(web): resolve ts issue

* chore(web): add missing changeset

---------

Co-authored-by: PJColombo <[email protected]>
  • Loading branch information
PabloCastellano and PJColombo authored Jun 20, 2024
1 parent 49455b8 commit dcbd95f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/gold-houses-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@blobscan/web": patch
---

Hidden swarm data expiration metric when swarm is not set
19 changes: 9 additions & 10 deletions apps/web/src/components/ExplorerDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { env } from "~/env.mjs";
import { capitalize, formatNumber, formatTtl } from "~/utils";

type ExplorerDetailsItemProps = {
name: React.ReactNode;
name: string;
value: React.ReactNode;
icon?: React.ReactNode;
};
Expand All @@ -35,24 +35,23 @@ function ExplorerDetailsItem({
export function ExplorerDetails() {
const { data: syncStateData } = api.syncState.getState.useQuery();
const { data: blobStoragesState } = api.blobStoragesState.getState.useQuery();
const explorerDetailsItems = [
const explorerDetailsItems: ExplorerDetailsItemProps[] = [
{ name: "Network", value: capitalize(env.NEXT_PUBLIC_NETWORK_NAME) },
{
name: "Last synced slot",
value: syncStateData
? formatNumber(syncStateData.lastUpperSyncedSlot ?? 0)
: undefined,
},
{
];

if (blobStoragesState && blobStoragesState.swarmDataTTL) {
explorerDetailsItems.push({
name: "Swarm blob data expiry",
value: blobStoragesState
? blobStoragesState.swarmDataTTL
? formatTtl(blobStoragesState.swarmDataTTL)
: null
: undefined,
value: formatTtl(blobStoragesState.swarmDataTTL),
icon: <ClockIcon className="h-4 w-4" />,
},
];
});
}

return (
<div className="sm:fle flex w-full flex-wrap items-center justify-center gap-2 align-middle text-xs text-contentSecondary-light dark:text-contentSecondary-dark sm:h-4 sm:justify-start">
Expand Down

0 comments on commit dcbd95f

Please sign in to comment.