Skip to content

Commit f9dd6ec

Browse files
committed
feat(web): combine stake boxes, label per-row totals, chain name+id, Delegation Stake copy
- Provider detail: merge Total Stake / Self Stake / Delegation into one StatCard (total as hero, Self Stake + Delegation Stake below). - Provider services + chain providers mobile rows: label "Total Stake" above the amount so it's obvious what the number is. - Provider services mobile row now shows the chain name on top with the specId below (via useChainNames), same shape as the chains list. - Rename "Delegation" → "Delegation Stake" in both detail page table columns and both mobile expand panels.
1 parent ec76bbb commit f9dd6ec

2 files changed

Lines changed: 45 additions & 14 deletions

File tree

‎apps/web/src/app/chain/[specid]/page.tsx‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export default function ChainPage({ params }: { params: Promise<{ specid: string
216216
},
217217
{ id: "total", header: "Total Stake", accessorFn: (r: SpecStake) => Number(toBigInt(r.stake) + toBigInt(r.delegation)), cell: ({ row }: { row: { original: SpecStake } }) => <LavaAmount amount={String(toBigInt(row.original.stake) + toBigInt(row.original.delegation))} /> },
218218
{ id: "stake", header: "Self Stake", meta: { hideOnMobile: true }, accessorFn: (r: SpecStake) => Number(toBigInt(r.stake)), cell: ({ row }: { row: { original: SpecStake } }) => <LavaAmount amount={row.original.stake} /> },
219-
{ id: "delegation", header: "Delegation", meta: { hideOnMobile: true }, accessorFn: (r: SpecStake) => Number(toBigInt(r.delegation)), cell: ({ row }: { row: { original: SpecStake } }) => <LavaAmount amount={row.original.delegation} /> },
219+
{ id: "delegation", header: "Delegation Stake", meta: { hideOnMobile: true }, accessorFn: (r: SpecStake) => Number(toBigInt(r.delegation)), cell: ({ row }: { row: { original: SpecStake } }) => <LavaAmount amount={row.original.delegation} /> },
220220
{ id: "commission", header: "Commission", meta: { hideOnMobile: true }, accessorFn: (r: SpecStake) => Number(r.delegateCommission || "0"), cell: ({ row }: { row: { original: SpecStake } }) => `${Number(row.original.delegateCommission || "0")}%` },
221221
{ id: "cuSum30d", header: "CU (30d)", meta: { hideOnMobile: true }, accessorFn: (r: SpecStake) => Number(toBigInt(r.cuSum30d)), cell: ({ row }: { row: { original: SpecStake } }) => row.original.cuSum30d != null ? formatNumberKMB(row.original.cuSum30d) : "—" },
222222
{ id: "relaySum30d", header: "Relays (30d)", meta: { hideOnMobile: true }, accessorFn: (r: SpecStake) => Number(toBigInt(r.relaySum30d)), cell: ({ row }: { row: { original: SpecStake } }) => row.original.relaySum30d != null ? formatNumberKMB(row.original.relaySum30d) : "—" },
@@ -283,7 +283,7 @@ export default function ChainPage({ params }: { params: Promise<{ specid: string
283283
<dd className="text-base font-semibold"><LavaAmount amount={s.stake} /></dd>
284284
</div>
285285
<div>
286-
<dt className="text-sm uppercase tracking-wider text-muted-foreground mb-1.5">Delegation</dt>
286+
<dt className="text-sm uppercase tracking-wider text-muted-foreground mb-1.5">Delegation Stake</dt>
287287
<dd className="text-base font-semibold"><LavaAmount amount={s.delegation} /></dd>
288288
</div>
289289
<div>
@@ -664,7 +664,10 @@ export default function ChainPage({ params }: { params: Promise<{ specid: string
664664
)}
665665
</div>
666666
</div>
667-
<span className="text-sm font-medium shrink-0"><LavaAmount amount={total.toString()} /></span>
667+
<div className="shrink-0 text-right">
668+
<div className="text-[10px] uppercase tracking-wider text-muted-foreground">Total Stake</div>
669+
<div className="text-sm font-semibold mt-0.5"><LavaAmount amount={total.toString()} /></div>
670+
</div>
668671
<ChevronRight size={18} className={`text-muted-foreground transition-transform shrink-0 ${isExpanded ? "rotate-90" : ""}`} />
669672
</button>
670673
{isExpanded && (

‎apps/web/src/app/provider/[lavaid]/page.tsx‎

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import React, { use, useState, useMemo, useEffect } from "react";
44
import Link from "next/link";
55
import { useApi } from "@/hooks/use-api";
6+
import { useChainNames } from "@/hooks/use-chain-names";
67
import { Skeleton } from "@/components/ui/skeleton";
78
import { StatCard } from "@/components/data/StatCard";
89
import { ChainLink } from "@/components/data/ChainLink";
@@ -133,6 +134,7 @@ function generateProviderMockData(): TimeSeriesEntry[] {
133134
export default function ProviderPage({ params }: { params: Promise<{ lavaid: string }> }) {
134135
const { lavaid } = use(params);
135136
const { data: provider, isLoading: providerLoading } = useApi<ProviderDetail>(`/providers/${lavaid}`);
137+
const { getName } = useChainNames();
136138
const { data: rewards, isLoading: rewardsLoading } = useApi<{ data: ChartEntry[] }>(`/providers/${lavaid}/charts`);
137139
const [rangeDays, setRangeDays] = useState(90);
138140
const chartFrom = rangeDays > 0 ? new Date(Date.now() - rangeDays * 24 * 60 * 60 * 1000).toISOString().slice(0, 10) : "";
@@ -268,7 +270,7 @@ export default function ProviderPage({ params }: { params: Promise<{ lavaid: str
268270
}},
269271
{ id: "total", header: "Total Stake", accessorFn: (r: Stake) => Number(BigInt(r.stake || "0") + BigInt(r.delegation || "0")), cell: ({ row }: { row: { original: Stake } }) => <LavaAmount amount={String(BigInt(row.original.stake || "0") + BigInt(row.original.delegation || "0"))} /> },
270272
{ id: "stake", header: "Self Stake", meta: { hideOnMobile: true }, accessorFn: (r: Stake) => Number(BigInt(r.stake || "0")), cell: ({ row }: { row: { original: Stake } }) => <LavaAmount amount={row.original.stake} /> },
271-
{ id: "delegation", header: "Delegation", meta: { hideOnMobile: true }, accessorFn: (r: Stake) => Number(BigInt(r.delegation || "0")), cell: ({ row }: { row: { original: Stake } }) => <LavaAmount amount={row.original.delegation} /> },
273+
{ id: "delegation", header: "Delegation Stake", meta: { hideOnMobile: true }, accessorFn: (r: Stake) => Number(BigInt(r.delegation || "0")), cell: ({ row }: { row: { original: Stake } }) => <LavaAmount amount={row.original.delegation} /> },
272274
{ id: "commission", header: "Commission", meta: { hideOnMobile: true }, accessorFn: (r: Stake) => Number(r.delegateCommission || "0"), cell: ({ row }: { row: { original: Stake } }) => `${Number(row.original.delegateCommission || "0")}%` },
273275
{ id: "geolocation", header: "Location", meta: { hideOnMobile: true }, accessorFn: (r: Stake) => r.geolocation ?? 0, cell: ({ row }: { row: { original: Stake } }) => {
274276
const regions = geoLabel(row.original.geolocation);
@@ -315,7 +317,7 @@ export default function ProviderPage({ params }: { params: Promise<{ lavaid: str
315317
<dd className="text-base font-semibold"><LavaAmount amount={s.stake} /></dd>
316318
</div>
317319
<div>
318-
<dt className="text-sm uppercase tracking-wider text-muted-foreground mb-1.5">Delegation</dt>
320+
<dt className="text-sm uppercase tracking-wider text-muted-foreground mb-1.5">Delegation Stake</dt>
319321
<dd className="text-base font-semibold"><LavaAmount amount={s.delegation} /></dd>
320322
</div>
321323
<div>
@@ -636,9 +638,27 @@ export default function ProviderPage({ params }: { params: Promise<{ lavaid: str
636638
<StatCard className="hidden md:block" label="Relays (30d)" loading={rewardsLoading} value={formatNumberKMB(relays30d.toString())} fullValue={relays30d.toLocaleString()} icon={<ArrowUpNarrowWide className="h-4 w-4 text-muted-foreground" />} />
637639
<StatCard className="hidden md:block" label="CU (30d)" loading={rewardsLoading} value={formatNumberKMB(cu30d.toString())} fullValue={cu30d.toLocaleString()} icon={<MonitorCog className="h-4 w-4 text-muted-foreground" />} />
638640

639-
<StatCard label="Total Stake" loading={providerLoading} value={<LavaAmount amount={(totalStake + totalDelegation).toString()} />} icon={<Coins className="h-4 w-4 text-muted-foreground" />} />
640-
<StatCard label="Self Stake" loading={providerLoading} value={<LavaAmount amount={totalStake.toString()} />} icon={<Coins className="h-4 w-4 text-muted-foreground" />} />
641-
<StatCard label="Delegation" loading={providerLoading} value={<LavaAmount amount={totalDelegation.toString()} />} icon={<Coins className="h-4 w-4 text-muted-foreground" />} />
641+
<StatCard
642+
label="Total Stake"
643+
loading={providerLoading}
644+
icon={<Coins className="h-4 w-4 text-muted-foreground" />}
645+
className="col-span-1 md:col-span-2 xl:col-span-1"
646+
value={
647+
<div>
648+
<div><LavaAmount amount={(totalStake + totalDelegation).toString()} /></div>
649+
<div className="grid grid-cols-2 gap-x-4 gap-y-1 mt-3 text-xs font-normal">
650+
<div>
651+
<div className="text-muted-foreground">Self Stake</div>
652+
<div className="text-sm font-medium text-foreground mt-0.5"><LavaAmount amount={totalStake.toString()} /></div>
653+
</div>
654+
<div>
655+
<div className="text-muted-foreground">Delegation Stake</div>
656+
<div className="text-sm font-medium text-foreground mt-0.5"><LavaAmount amount={totalDelegation.toString()} /></div>
657+
</div>
658+
</div>
659+
</div>
660+
}
661+
/>
642662
<StatCard label="Commission" loading={providerLoading} value={commissionDisplay ?? "—"} icon={<Percent className="h-4 w-4 text-muted-foreground" />} />
643663
</div>
644664
</div>
@@ -797,10 +817,17 @@ export default function ProviderPage({ params }: { params: Promise<{ lavaid: str
797817
>
798818
<ChainIconImg chainId={s.specId} />
799819
<div className="min-w-0 flex-1">
800-
<div className="flex items-center gap-2">
801-
<span className="text-base font-medium truncate">{s.specId}</span>
802-
</div>
803-
<div className="flex items-center gap-1.5 mt-0.5">
820+
{(() => {
821+
const fullName = getName(s.specId);
822+
const hasFullName = fullName && fullName !== s.specId;
823+
return (
824+
<>
825+
<div className="text-base font-medium truncate">{hasFullName ? fullName : s.specId}</div>
826+
{hasFullName && <div className="text-xs text-muted-foreground truncate mt-0.5">{s.specId}</div>}
827+
</>
828+
);
829+
})()}
830+
<div className="flex items-center gap-1.5 mt-1">
804831
{h ? (
805832
<>
806833
<span className={`w-1.5 h-1.5 rounded-full ${isHealthy ? "bg-green-500" : "bg-red-500"}`} />
@@ -816,8 +843,9 @@ export default function ProviderPage({ params }: { params: Promise<{ lavaid: str
816843
)}
817844
</div>
818845
</div>
819-
<div className="flex flex-col items-end shrink-0">
820-
<span className="text-sm font-medium"><LavaAmount amount={total.toString()} /></span>
846+
<div className="shrink-0 text-right">
847+
<div className="text-[10px] uppercase tracking-wider text-muted-foreground">Total Stake</div>
848+
<div className="text-sm font-semibold mt-0.5"><LavaAmount amount={total.toString()} /></div>
821849
</div>
822850
<ChevronRight size={18} className={`text-muted-foreground transition-transform shrink-0 ${isExpanded ? "rotate-90" : ""}`} />
823851
</button>

0 commit comments

Comments
 (0)