Skip to content

feat: add PlatformStats widget with Recharts line/bar charts for tran…#384

Merged
Luluameh merged 1 commit into
LightForgeHub:mainfrom
sudo-robi:feature/platform-stats
Jun 30, 2026
Merged

feat: add PlatformStats widget with Recharts line/bar charts for tran…#384
Luluameh merged 1 commit into
LightForgeHub:mainfrom
sudo-robi:feature/platform-stats

Conversation

@sudo-robi

@sudo-robi sudo-robi commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

closes #337

Summary by CodeRabbit

  • New Features
    • Added a new Platform Stats section to the marketplace page.
    • Users can switch between weekly and monthly views to see key marketplace metrics and a responsive chart.
    • The marketplace now also includes a new data visualization library to support these charts.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

A new PlatformStats client component is added to the marketplace, rendering metric cards and a toggle-driven Recharts chart (bar for weekly, area for monthly) using hardcoded datasets. The component is mounted in MarketplacePage, and recharts is added as a production dependency.

Changes

PlatformStats Chart Widget

Layer / File(s) Summary
PlatformStats component and MetricCard
src/components/marketplace/PlatformStats.tsx
Defines hardcoded weekly/monthly datasets, a MetricCard presentational component, and PlatformStats with local view state, toggle buttons, a metric card grid, and conditional BarChart/AreaChart rendering via Recharts.
Dependency and page wiring
package.json, src/app/marketplace/page.tsx
Adds recharts ^3.9.0 to dependencies and renders <PlatformStats /> after <TrendingExpert /> in MarketplacePage.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A chart hops into view with a bar or a wave,
Weekly or monthly, the metrics behave.
Recharts joins the burrow, all snug in the deps,
MetricCards lined up in tidy little steps.
The marketplace blooms with a graph full of cheer! 🌱

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly names the new PlatformStats widget and its Recharts charts, matching the main change.
Linked Issues check ✅ Passed The PR adds a Recharts-powered PlatformStats widget with weekly/monthly transaction volume charts in the key file, meeting #337.
Out of Scope Changes check ✅ Passed The only extra change is the Recharts dependency needed by the new widget, so no unrelated scope appears introduced.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/marketplace/PlatformStats.tsx`:
- Around line 19-42: The PlatformStats widget is currently rendering hardcoded
weekly/monthly volume series and KPI card values instead of live analytics.
Update PlatformStats and its related KPI rendering logic to source these metrics
from real data (props, API, or shared analytics state) rather than static
arrays/constants, and keep the existing chart/card components wired to those
dynamic values so the displayed platform stats reflect actual analytics.
- Around line 150-160: The transaction volume chart in PlatformStats is
rendering plain integers on both the axis and tooltip, which is inconsistent
with the currency-based headline metric. Update the chart formatting in the
stats chart section that uses XAxis, YAxis, and Tooltip so the displayed values
are formatted as currency (for example via the chart’s tick/value formatter and
tooltip formatter), and apply the same change to the second matching chart block
referenced in the review.
- Around line 89-110: The Weekly/Monthly toggle in PlatformStats currently only
communicates selection through styling, so screen readers can’t detect the
active range. Update the button controls in the view switcher to expose their
pressed state with aria-pressed (or refactor the control to a proper tabs
pattern) and keep it in sync with the existing view state used by setView and
view.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ec1df6bc-b042-4f2d-b5f3-38e17b4a3267

📥 Commits

Reviewing files that changed from the base of the PR and between 9781272 and b7bc5ec.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • package.json
  • src/app/marketplace/page.tsx
  • src/components/marketplace/PlatformStats.tsx

Comment on lines +19 to +42
const weeklyVolume = [
{ name: "Mon", volume: 2400 },
{ name: "Tue", volume: 1398 },
{ name: "Wed", volume: 3800 },
{ name: "Thu", volume: 3908 },
{ name: "Fri", volume: 4800 },
{ name: "Sat", volume: 3800 },
{ name: "Sun", volume: 4300 },
]

const monthlyVolume = [
{ name: "Jan", volume: 4000 },
{ name: "Feb", volume: 3000 },
{ name: "Mar", volume: 5000 },
{ name: "Apr", volume: 4500 },
{ name: "May", volume: 6000 },
{ name: "Jun", volume: 5500 },
{ name: "Jul", volume: 7000 },
{ name: "Aug", volume: 6500 },
{ name: "Sep", volume: 8000 },
{ name: "Oct", volume: 7500 },
{ name: "Nov", volume: 9000 },
{ name: "Dec", volume: 8500 },
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Wire this widget to real analytics instead of shipping fixed numbers.

The weekly/monthly series and the KPI cards are all hardcoded, so this will render placeholder values as if they were live public platform metrics.

Suggested direction
-const weeklyVolume = [...]
-const monthlyVolume = [...]
-
-export default function PlatformStats() {
+type VolumePoint = { name: string; volume: number }
+
+type PlatformStatsProps = {
+  weeklyVolume: VolumePoint[]
+  monthlyVolume: VolumePoint[]
+  totalVolume: number
+  totalTransactions: number
+  growthRate: number
+}
+
+export default function PlatformStats({
+  weeklyVolume,
+  monthlyVolume,
+  totalVolume,
+  totalTransactions,
+  growthRate,
+}: PlatformStatsProps) {

Also applies to: 115-135

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/marketplace/PlatformStats.tsx` around lines 19 - 42, The
PlatformStats widget is currently rendering hardcoded weekly/monthly volume
series and KPI card values instead of live analytics. Update PlatformStats and
its related KPI rendering logic to source these metrics from real data (props,
API, or shared analytics state) rather than static arrays/constants, and keep
the existing chart/card components wired to those dynamic values so the
displayed platform stats reflect actual analytics.

Comment on lines +89 to +110
<button
onClick={() => setView("weekly")}
className={cn(
"px-4 py-2 rounded-lg text-sm font-medium transition-all duration-200",
view === "weekly"
? "bg-[#9B59FF] text-white shadow-lg shadow-[#9B59FF]/25"
: "text-slate-400 hover:text-white"
)}
>
Weekly
</button>
<button
onClick={() => setView("monthly")}
className={cn(
"px-4 py-2 rounded-lg text-sm font-medium transition-all duration-200",
view === "monthly"
? "bg-[#9B59FF] text-white shadow-lg shadow-[#9B59FF]/25"
: "text-slate-400 hover:text-white"
)}
>
Monthly
</button>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Expose the active range to assistive tech.

These buttons only show the selected state visually. Add aria-pressed (or switch to a tabs pattern) so screen readers can tell whether Weekly or Monthly is active.

Suggested fix
             <button
               onClick={() => setView("weekly")}
+              aria-pressed={view === "weekly"}
               className={cn(
@@
             <button
               onClick={() => setView("monthly")}
+              aria-pressed={view === "monthly"}
               className={cn(
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<button
onClick={() => setView("weekly")}
className={cn(
"px-4 py-2 rounded-lg text-sm font-medium transition-all duration-200",
view === "weekly"
? "bg-[#9B59FF] text-white shadow-lg shadow-[#9B59FF]/25"
: "text-slate-400 hover:text-white"
)}
>
Weekly
</button>
<button
onClick={() => setView("monthly")}
className={cn(
"px-4 py-2 rounded-lg text-sm font-medium transition-all duration-200",
view === "monthly"
? "bg-[#9B59FF] text-white shadow-lg shadow-[#9B59FF]/25"
: "text-slate-400 hover:text-white"
)}
>
Monthly
</button>
<button
onClick={() => setView("weekly")}
aria-pressed={view === "weekly"}
className={cn(
"px-4 py-2 rounded-lg text-sm font-medium transition-all duration-200",
view === "weekly"
? "bg-[`#9B59FF`] text-white shadow-lg shadow-[`#9B59FF`]/25"
: "text-slate-400 hover:text-white"
)}
>
Weekly
</button>
<button
onClick={() => setView("monthly")}
aria-pressed={view === "monthly"}
className={cn(
"px-4 py-2 rounded-lg text-sm font-medium transition-all duration-200",
view === "monthly"
? "bg-[`#9B59FF`] text-white shadow-lg shadow-[`#9B59FF`]/25"
: "text-slate-400 hover:text-white"
)}
>
Monthly
</button>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/marketplace/PlatformStats.tsx` around lines 89 - 110, The
Weekly/Monthly toggle in PlatformStats currently only communicates selection
through styling, so screen readers can’t detect the active range. Update the
button controls in the view switcher to expose their pressed state with
aria-pressed (or refactor the control to a proper tabs pattern) and keep it in
sync with the existing view state used by setView and view.

Comment on lines +150 to +160
<XAxis dataKey="name" stroke="#64748b" tick={{ fill: "#64748b", fontSize: 12 }} />
<YAxis stroke="#64748b" tick={{ fill: "#64748b", fontSize: 12 }} />
<Tooltip
contentStyle={{
backgroundColor: "rgba(15, 15, 15, 0.95)",
border: "1px solid rgba(255,255,255,0.1)",
borderRadius: "12px",
color: "#fff",
}}
cursor={{ fill: "rgba(155, 89, 255, 0.1)" }}
/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Format chart output as currency.

This chart is labeled as transaction volume, but both the axis and tooltip render bare integers. That makes the units ambiguous and inconsistent with the $124,592 headline card.

Suggested fix
+  const currency = new Intl.NumberFormat("en-US", {
+    style: "currency",
+    currency: "USD",
+    maximumFractionDigits: 0,
+  })
@@
-                    <XAxis dataKey="name" stroke="`#64748b`" tick={{ fill: "`#64748b`", fontSize: 12 }} />
-                    <YAxis stroke="`#64748b`" tick={{ fill: "`#64748b`", fontSize: 12 }} />
+                    <XAxis dataKey="name" stroke="`#64748b`" tick={{ fill: "`#64748b`", fontSize: 12 }} />
+                    <YAxis
+                      stroke="`#64748b`"
+                      tick={{ fill: "`#64748b`", fontSize: 12 }}
+                      tickFormatter={(value) => currency.format(value)}
+                    />
                     <Tooltip
+                      formatter={(value: number) => currency.format(value)}
@@
-                    <XAxis dataKey="name" stroke="`#64748b`" tick={{ fill: "`#64748b`", fontSize: 12 }} />
-                    <YAxis stroke="`#64748b`" tick={{ fill: "`#64748b`", fontSize: 12 }} />
+                    <XAxis dataKey="name" stroke="`#64748b`" tick={{ fill: "`#64748b`", fontSize: 12 }} />
+                    <YAxis
+                      stroke="`#64748b`"
+                      tick={{ fill: "`#64748b`", fontSize: 12 }}
+                      tickFormatter={(value) => currency.format(value)}
+                    />
                     <Tooltip
+                      formatter={(value: number) => currency.format(value)}

Also applies to: 172-181

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/marketplace/PlatformStats.tsx` around lines 150 - 160, The
transaction volume chart in PlatformStats is rendering plain integers on both
the axis and tooltip, which is inconsistent with the currency-based headline
metric. Update the chart formatting in the stats chart section that uses XAxis,
YAxis, and Tooltip so the displayed values are formatted as currency (for
example via the chart’s tick/value formatter and tooltip formatter), and apply
the same change to the second matching chart block referenced in the review.

@Luluameh Luluameh merged commit 4b23a92 into LightForgeHub:main Jun 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Daily Volume and System Revenue Chart Widget

2 participants