diff --git a/src/app/dashboard/reader/page.tsx b/src/app/dashboard/reader/page.tsx index 7e942456..61a0da82 100644 --- a/src/app/dashboard/reader/page.tsx +++ b/src/app/dashboard/reader/page.tsx @@ -21,13 +21,14 @@ async function fetchDonationPage( if (!supabase) return { rows: [], totalCount: 0 }; const from = page * PAGE_SIZE; const to = from + PAGE_SIZE - 1; - const { data, count } = await supabase + const { data, count, error } = await supabase .from("donations") .select("*", { count: "exact" }) .eq("donor_address", address.toLowerCase()) .order("block_timestamp", { ascending: false }) .range(from, to) .returns(); + if (error) throw error; return { rows: data ?? [], totalCount: count ?? 0 }; } @@ -40,7 +41,7 @@ export default function ReaderDashboard() { setPage(0); }, [address]); - const { data, isLoading } = useQuery({ + const { data, isLoading, error } = useQuery({ queryKey: ["reader-donations", address, page], queryFn: () => fetchDonationPage(address!, page), enabled: isConnected && !!address, @@ -100,11 +101,17 @@ export default function ReaderDashboard() { {isLoading &&

Loading...

} + {error && ( +

+ Failed to load donations. Please try again. +

+ )} +
{donations.map((d) => ( ))} - {!isLoading && donations.length === 0 && ( + {!isLoading && !error && donations.length === 0 && (

No donations yet.

diff --git a/src/app/dashboard/writer/page.tsx b/src/app/dashboard/writer/page.tsx index 17e26eb3..929a08c0 100644 --- a/src/app/dashboard/writer/page.tsx +++ b/src/app/dashboard/writer/page.tsx @@ -11,20 +11,21 @@ async function fetchWriterStorylines( address: string, ): Promise { if (!supabase) return []; - const { data } = await supabase + const { data, error } = await supabase .from("storylines") .select("*") .eq("writer_address", address.toLowerCase()) .eq("hidden", false) .order("block_timestamp", { ascending: false }) .returns(); + if (error) throw error; return data ?? []; } export default function WriterDashboard() { const { address, isConnected } = useAccount(); - const { data: storylines = [], isLoading } = useQuery({ + const { data: storylines = [], isLoading, error } = useQuery({ queryKey: ["writer-storylines", address], queryFn: () => fetchWriterStorylines(address!), enabled: isConnected && !!address, @@ -53,11 +54,17 @@ export default function WriterDashboard() { {isLoading &&

Loading...

} + {error && ( +

+ Failed to load storylines. Please try again. +

+ )} +
{storylines.map((s) => ( ))} - {!isLoading && storylines.length === 0 && ( + {!isLoading && !error && storylines.length === 0 && (

No storylines yet.