From 36f91ab4047b883321f580ec415445180d1dd103 Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Mon, 16 Mar 2026 13:30:36 +0000 Subject: [PATCH 1/2] [#158] Show donation stats prominently, clarify deadline wording - Replace redundant "Deadline 72h" column with donation total + count - Change "Deadline: XX:XX:XX remaining" to "Next plot due in XX:XX:XX" - Replace cryptic "D:" / "R:" labels with "Royalties:" in earnings breakdown Fixes #158 Co-Authored-By: Claude Opus 4.6 (1M context) --- src/app/dashboard/writer/page.tsx | 36 ++++++++++++++++++++++++--- src/components/DeadlineCountdown.tsx | 6 ++--- src/components/WriterTradingStats.tsx | 3 +-- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/app/dashboard/writer/page.tsx b/src/app/dashboard/writer/page.tsx index 2e2a8c11..40f8c672 100644 --- a/src/app/dashboard/writer/page.tsx +++ b/src/app/dashboard/writer/page.tsx @@ -2,6 +2,7 @@ import { useAccount } from "wagmi"; import { useQuery } from "@tanstack/react-query"; +import { formatUnits } from "viem"; import { supabase, type Storyline } from "../../../../lib/supabase"; import { DeadlineCountdown } from "../../../components/DeadlineCountdown"; import { ClaimRoyalties } from "../../../components/ClaimRoyalties"; @@ -119,11 +120,9 @@ function StorylineDetail({ storyline, writerAddress }: { storyline: Storyline; w
- Deadline - - - {storyline.has_deadline ? "72h" : "none"} + Donations +
@@ -146,3 +145,32 @@ function StorylineDetail({ storyline, writerAddress }: { storyline: Storyline; w ); } + +function DonationCount({ storylineId }: { storylineId: number }) { + const { data } = useQuery({ + queryKey: ["donation-count", storylineId], + queryFn: async () => { + if (!supabase) return { total: BigInt(0), count: 0 }; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const { data: rows } = await (supabase.from("donations") as any) + .select("amount") + .eq("storyline_id", storylineId); + if (!rows) return { total: BigInt(0), count: 0 }; + const total = (rows as { amount: string }[]).reduce( + (sum, d) => sum + BigInt(d.amount), + BigInt(0), + ); + return { total, count: rows.length }; + }, + }); + + if (!data || data.count === 0) { + return ; + } + + return ( + + {formatUnits(data.total, 18)} ({data.count}) + + ); +} diff --git a/src/components/DeadlineCountdown.tsx b/src/components/DeadlineCountdown.tsx index 8b8d619d..07cb5a9b 100644 --- a/src/components/DeadlineCountdown.tsx +++ b/src/components/DeadlineCountdown.tsx @@ -19,9 +19,8 @@ export function DeadlineCountdown({ lastPlotTime }: { lastPlotTime: string }) { if (remaining === null) { return (
- Deadline: + Next plot due in --:--:-- - remaining
); } @@ -40,12 +39,11 @@ export function DeadlineCountdown({ lastPlotTime }: { lastPlotTime: string }) { return (
- Deadline: + Next plot due in {String(hours).padStart(2, "0")}:{String(minutes).padStart(2, "0")}: {String(seconds).padStart(2, "0")} - remaining
); } diff --git a/src/components/WriterTradingStats.tsx b/src/components/WriterTradingStats.tsx index 552e8fca..1aa36d3b 100644 --- a/src/components/WriterTradingStats.tsx +++ b/src/components/WriterTradingStats.tsx @@ -100,8 +100,7 @@ export function WriterTradingStats({ storyline }: WriterTradingStatsProps) { : "—"} - {donationsTotal !== undefined && decimals !== undefined && `D: ${formatUnits(donationsTotal, decimals)}`} - {royaltyData && decimals !== undefined && ` R: ${formatUnits(royaltyData.unclaimed, decimals)}`} + {royaltyData && decimals !== undefined && `Royalties: ${formatUnits(royaltyData.unclaimed, decimals)}`}
From c2e76db140656d4751bbf1563c2146754334b30f Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Mon, 16 Mar 2026 13:35:14 +0000 Subject: [PATCH 2/2] [#158] Use dynamic reserve token decimals for donation display Fetch decimals via getTokenTVL instead of hardcoding 18. DonationCount now takes tokenAddress prop to resolve the reserve token metadata. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/app/dashboard/writer/page.tsx | 32 ++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/app/dashboard/writer/page.tsx b/src/app/dashboard/writer/page.tsx index 40f8c672..6db83ebb 100644 --- a/src/app/dashboard/writer/page.tsx +++ b/src/app/dashboard/writer/page.tsx @@ -4,6 +4,7 @@ import { useAccount } from "wagmi"; import { useQuery } from "@tanstack/react-query"; import { formatUnits } from "viem"; import { supabase, type Storyline } from "../../../../lib/supabase"; +import { getTokenTVL } from "../../../../lib/price"; import { DeadlineCountdown } from "../../../components/DeadlineCountdown"; import { ClaimRoyalties } from "../../../components/ClaimRoyalties"; import { WriterTradingStats } from "../../../components/WriterTradingStats"; @@ -122,7 +123,10 @@ function StorylineDetail({ storyline, writerAddress }: { storyline: Storyline; w Donations - + {storyline.token_address + ? + : + }
@@ -146,21 +150,27 @@ function StorylineDetail({ storyline, writerAddress }: { storyline: Storyline; w ); } -function DonationCount({ storylineId }: { storylineId: number }) { +function DonationCount({ storylineId, tokenAddress }: { storylineId: number; tokenAddress: string }) { const { data } = useQuery({ - queryKey: ["donation-count", storylineId], + queryKey: ["donation-count", storylineId, tokenAddress], queryFn: async () => { - if (!supabase) return { total: BigInt(0), count: 0 }; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const { data: rows } = await (supabase.from("donations") as any) - .select("amount") - .eq("storyline_id", storylineId); - if (!rows) return { total: BigInt(0), count: 0 }; + const [tvlData, rows] = await Promise.all([ + getTokenTVL(tokenAddress as Address), + supabase + ? // eslint-disable-next-line @typescript-eslint/no-explicit-any + (supabase.from("donations") as any) + .select("amount") + .eq("storyline_id", storylineId) + .then((r: { data: { amount: string }[] | null }) => r.data) + : null, + ]); + const decimals = tvlData?.decimals ?? 18; + if (!rows || rows.length === 0) return { total: BigInt(0), count: 0, decimals }; const total = (rows as { amount: string }[]).reduce( (sum, d) => sum + BigInt(d.amount), BigInt(0), ); - return { total, count: rows.length }; + return { total, count: rows.length, decimals }; }, }); @@ -170,7 +180,7 @@ function DonationCount({ storylineId }: { storylineId: number }) { return ( - {formatUnits(data.total, 18)} ({data.count}) + {formatUnits(data.total, data.decimals)} ({data.count}) ); }