Item 2 — founder counter is REAL or hidden (kills the hardcoded 47/100)
ClaimMeter rendered a fabricated "47 / 100 CLAIMED" (a hardcoded default; the
comment even said "Cosmetic conversion driver… Static here"). Now:
- GET /api/founders/count counts ONLY real paying founders — user_profiles
where founder_pricing = true AND subscription_status = 'active' (the
Stripe-webhook-synced mirror, so we never hammer the Stripe API). Cached 5
min in Redis on top of that.
- If the source is unavailable (Supabase unconfigured, query error, column not
migrated, client throws) the endpoint returns { available: false } and the
ClaimMeter renders NOTHING — counter and progress bar both hidden. We never
fall back to a number.
- A low real count is shown honestly (0 → "0 / 100"); the truth is the feature.
Next proxy at app/api/founders/count. 6 route tests cover real count, low
count, error/unconfigured/throw → hidden, and cache-hit. Suite 271/3260 green,
web build exit 0.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,17 +1,43 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import SectionHead from '@/components/vyndr/SectionHead';
|
||||
|
||||
interface ClaimMeterProps {
|
||||
interface FounderCount {
|
||||
available: boolean;
|
||||
claimed?: number;
|
||||
total?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Founder-seat scarcity meter (§12 ClaimMeter) — "47 / 100 seats claimed",
|
||||
* amber bar. Cosmetic conversion driver; the live tick-up wires into the
|
||||
* living layer in Session 38. Static here.
|
||||
* Founder-seat scarcity meter (§12 ClaimMeter).
|
||||
*
|
||||
* TRUTH LAW (Truth-Everywhere Part 2, item 2): this used to render a hardcoded
|
||||
* "47 / 100 CLAIMED". It now fetches the REAL count of active paying founders
|
||||
* from /api/founders/count (Stripe-synced, cached). If the source is
|
||||
* unavailable — or the fetch fails — the counter and progress bar HIDE
|
||||
* entirely. We never fall back to a number. A low real count is fine; the
|
||||
* truth is the feature.
|
||||
*/
|
||||
export default function ClaimMeter({ claimed = 47, total = 100 }: ClaimMeterProps) {
|
||||
export default function ClaimMeter() {
|
||||
const [data, setData] = useState<FounderCount | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
fetch('/api/founders/count', { cache: 'no-store' })
|
||||
.then((r) => r.json())
|
||||
.then((d) => { if (active) setData(d); })
|
||||
.catch(() => { if (active) setData({ available: false }); });
|
||||
return () => { active = false; };
|
||||
}, []);
|
||||
|
||||
// Hide until we have a REAL number. Unavailable source → render nothing.
|
||||
if (!data || !data.available || typeof data.claimed !== 'number') return null;
|
||||
|
||||
const total = data.total || 100;
|
||||
const claimed = Math.max(0, Math.min(total, data.claimed));
|
||||
const pct = Math.min(100, Math.round((claimed / total) * 100));
|
||||
|
||||
return (
|
||||
<div style={{ maxWidth: 420, margin: '0 auto', width: '100%' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline', marginBottom: 8 }}>
|
||||
|
||||
Reference in New Issue
Block a user