Skip to content

fix: Reports page i18n, filters, and console spam#56

Open
alanaqrawiacn wants to merge 2 commits into
beck-source:mainfrom
alanaqrawiacn:fix/reports-page-bugs
Open

fix: Reports page i18n, filters, and console spam#56
alanaqrawiacn wants to merge 2 commits into
beck-source:mainfrom
alanaqrawiacn:fix/reports-page-bugs

Conversation

@alanaqrawiacn
Copy link
Copy Markdown

Note: This PR is stacked on top of #53. Until that merges, the diff below will also include the sidebar-redesign changes. Review against feature/sidebar-redesign for the isolated Reports-only diff.

Summary

The Reports view had silently drifted away from every codebase convention (Options API, raw axios, hardcoded English strings, :key="index", 12+ console.log calls firing on every render), and the global filter bar did not affect it at all. This PR brings it in line with Orders.vue / Dashboard.vue and makes the filters work end-to-end.

Changes

Frontend

  • views/Reports.vue — full rewrite
    • Options API → Composition API (setup() with ref/computed/watch/onMounted)
    • Uses useI18n() for all user-facing strings
    • Uses useFilters() composable + watch on selectedPeriod/selectedLocation/selectedCategory/selectedStatus to reload on filter change
    • Direct axios calls → centralized api.getReportsQuarterly(filters) / api.getReportsMonthlyTrends(filters)
    • Removed all console.log noise; kept one console.error in catch
    • Custom buggy formatNumber loop → toLocaleString, with currencySymbol (¥ vs $) driven by currentCurrency
    • formatMonth rewritten to use a local-time new Date(year, monthIndex, 1) so 2025-01 no longer drifts to Dec 2024 in UTC-offset zones
    • v-for :key="index" → stable keys (q.quarter, month.month)
  • components/Sidebar.vue — line 87: label: Reportsget label() { return t(nav.reports) } (matches the getter pattern used by every other nav item)
  • locales/en.js / locales/ja.js — added nav.reports and a full reports.* translation tree (title, description, quarterly., monthlyTrend.title, monthOverMonth., stats.*)
  • api.js — added getReportsQuarterly(filters) and getReportsMonthlyTrends(filters) that serialize warehouse/category/status/month query params like the other filtered endpoints

Backend

  • server/main.py/api/reports/quarterly and /api/reports/monthly-trends now accept warehouse/category/status/month query params and apply them via the existing apply_filters + filter_by_month helpers

Test plan

  • Language switcher: toggle to 日本語 — entire Reports page (headers, table columns, stat labels, sidebar レポート link) renders in Japanese; currency flips to ¥. Toggle back to English — reverts.
  • Time Period filter: set January — Reports narrows to a single Q1-2025 row (18 orders, $1,993,655.74 revenue), bar chart to one bar, month-over-month table to one row. Set back to All Months — everything returns.
  • Console: opening Reports in DevTools produces no log spam (was 92 log entries per render, now 0). Only pre-existing /api/tasks 404s from App.vue remain.
  • Full-page render unchanged in structure (CSS preserved).

🤖 Generated with Claude Code

alanaqrawiacn and others added 2 commits April 21, 2026 11:01
Redesigns the app layout from a horizontal top navigation bar to a
SaaS-style fixed vertical sidebar (220px, #0f172a background).

- Add Sidebar.vue with 6 nav links (SVG icons, active route detection),
  logo block, and ProfileMenu/LanguageSwitcher pinned at the bottom
- Rewrite App.vue layout to flex-direction: row with sidebar + app-body
- Update FilterBar.vue: top offset 70px → 0, remove max-width constraint
- Add docs/architecture.html: tech stack, data flow, API endpoints
- Add .claude/commands/sidebar-redesign.md custom skill

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
The Reports view had drifted away from every codebase convention and
was silently broken. This commit brings it back in line with the other
views (Orders, Dashboard) and makes the filter bar actually affect it.

Changes:
- Reports.vue: full rewrite from Options API to Composition API
  - Import useI18n, useFilters, centralized api client
  - Watch all 4 filter refs to reload data on change
  - Replace hardcoded English strings with t('reports.*') keys
  - Replace direct axios calls with api.getReportsQuarterly/getReportsMonthlyTrends
  - Remove 12+ console.log calls (formatNumber/formatMonth/getBarHeight
    were logging on every render); keep a single console.error on failure
  - Use toLocaleString for number formatting; wire currencySymbol to
    currentCurrency so ¥ shows under ja locale
  - Fix timezone offset bug in formatMonth: parse YYYY-MM into a
    local-time Date instead of ISO string so "2025-01" no longer renders
    as "Dec 2024" in UTC-offset zones
  - Replace v-for :key="index" with stable keys (q.quarter, month.month)
- Sidebar.vue: Reports label uses t('nav.reports') instead of the
  hardcoded 'Reports' string (rest of nav already used the getter)
- locales/{en,ja}.js: add nav.reports and full reports.* translation tree
- api.js: add getReportsQuarterly(filters) and getReportsMonthlyTrends(filters)
- server/main.py: /api/reports/quarterly and /api/reports/monthly-trends
  now accept warehouse/category/status/month via the existing
  apply_filters + filter_by_month helpers

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant