Commit Graph
13 Commits
Author SHA1 Message Date
GandClaude Opus 5 3d6ac9bed3 fix: prices were 100x wrong for zero-decimal currencies (#58)
Two real defects in the repo I can actually reach, found by auditing my own
work rather than someone else's.

formatPrice divided by 100 unconditionally. That assumes every currency has two
decimals, and several have none: with NEXT_PUBLIC_APP_CURRENCY=JPY a 2999-unit
product rendered as ¥30 instead of ¥2,999 — a hundredfold error, silently, on
every price in the shop. KRW, VND and ISK behave the same way, and KWD errs in
the other direction with three decimals. APP_CURRENCY is an environment
variable, so this was one deployment away from being real.

It now delegates to commercekit's money module, which takes the exponent from
the currency. That also removes a second money formatter from a repo that had
just adopted the first — exactly the duplication this whole exercise is about,
introduced by me.

TEMPLATE_MAP typed its payload as `any`, so the cron dispatching welcome emails
could hand a template the wrong shape and the compiler would agree — on mail
that goes to real users, built from a jsonb column nothing else validates. All
four templates take the same WelcomePayload, so the `any` bought nothing.

Typing it immediately produced an error, which turned out to be a typing gap
rather than a live bug: the cron spread `item.payload as object`, erasing the
shape, while enqueueWelcomeSequence does write { name, email }. So the emails
were correct and the types were lying about why. The cast now narrows to
WelcomePayload and the compiler can see it.

Verification: lint, tsc, css-vars, 901 tests / 87 files (8 new, including the
JPY case that would have caught the price bug).

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 16:07:54 +00:00
GandClaude Fable 5 9beac50989 fix(ui): kill dead ps-* overrides on form inputs; deterministic price/date formatting (#23)
* fix(ui): form-input-icon semantic class ends dead ps-* overrides; deterministic en formatting defaults

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs(agents): utilities cannot override unlayered semantic classes — use modifier classes

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* chore: drop stray audit screenshots

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-13 11:58:14 +00:00
g-butandClaude Sonnet 4.6 ada3c4a391 fix(ssot): close all SSOT and DRY gaps in UI layer
SIGNAL_TEXT_CLASSES: add to pet-signal.ts config; replace duplicated
  ternary (sig==="concern" ? danger-text : warn-text) in dashboard,
  health, and checkin pages — was 3 identical inline mappings

formatPrice: admin overview was computing revenue inline
  ($${(revenue/100).toLocaleString(...)}) — now uses shared formatPrice()

formatDateShort: extend to accept full ISO timestamps (not just
  date-only strings); admin users page was calling toLocaleDateString
  inline — now uses formatDateShort()

User role colors: veterinarian/pet_sitter/admin used Tailwind named
  colors (text-blue-700 etc.) while pet_owner used CSS vars — inconsistent
  within the SSOT config; added --role-vet/sitter/admin CSS vars to
  globals.css and updated lib/config/users.ts to reference them

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-07 19:49:00 +02:00
g-butandClaude Sonnet 4.6 6a16dbc4c5 fix(i18n): replace hardcoded \$ with Intl.NumberFormat driven by APP_CURRENCY
formatPrice and formatAdoptionFee now use Intl.NumberFormat(locale, { style: "currency",
currency: APP_CURRENCY }) so the symbol and number formatting are locale-aware.
APP_CURRENCY reads from NEXT_PUBLIC_APP_CURRENCY env (default "USD"), making the
deployment currency a single config value rather than a hardcoded symbol.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-07 17:43:41 +02:00
g-butandClaude Sonnet 4.6 8b75d4c72b fix(i18n): make pet age display locale-aware across all 9 languages
formatPetAge and formatPetAgeShort now accept a t() function so callers
pass their locale context instead of receiving hardcoded English. Adds 7
translation keys to the public namespace (petAgeMonths, petAgeYears,
petAgeYearsMonths, petAgeShortMonths, etc.) with proper plural forms and
natural phrasing for DE/FR/ES/JA/ZH/KO/TR/AR. Also adds unnamedPet key
to eliminate the last hardcoded English fallback in the booking modal,
and routes OG image price/fee strings through formatPrice/formatAdoptionFee
instead of inline $ calculations.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-07 17:29:06 +02:00
g-butandClaude Sonnet 4.6 124db06bb3 fix(i18n): make relative dates locale-aware via Intl.RelativeTimeFormat
Replaces the hardcoded English strings ("Today", "Tomorrow", "In 7 days")
in formatRelativeDate with Intl.RelativeTimeFormat, so German users see
"heute/morgen/gestern", French see "aujourd'hui/demain/hier", etc.
Updates all call sites (pets list, health log, vaccinations) to pass
locale. Also routes sitter per-day price through formatAdoptionFee to
eliminate a rogue inline $-calculation in the Find page.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-07 17:03:29 +02:00
g-butandClaude Sonnet 4.6 dced92979e refactor(ssot): consolidate price formatting to lib/utils/format.ts
Add formatAdoptionFee(feeCents: number | null): string — returns "Free"
for null/0, whole-dollar amount ("$25") otherwise. Eliminates 7 copies
of the same null-check + division + toFixed pattern scattered across
adoption pages and the admin panel.

Also wire formatPrice() in orders/route.ts and orders/[orderId]/route.ts
(5 instances) instead of inlining the dollar/cent division idiom.

No behavior change; all 534 tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 14:05:49 +02:00
g-butandClaude Opus 4.7 2dd76e2d28 fix(i18n): thread locale through portal server components
Portal routes live outside next-intl's [locale] segment, so server
pages couldn't get the user's locale via getLocale() — date helpers
fell back to en. Non-English users saw English dates on the pet
profile and health page despite the language switcher.

- New lib/i18n/portal-locale.ts: getPortalLocale() reads the
  NEXT_LOCALE cookie, validates it against routing.locales, falls
  back to defaultLocale. The portal layout now uses this helper
  instead of inlining the cookie read.
- formatIsoDate / formatIsoDateTime: accept optional locale (matches
  the formatDateShort signature shipped last commit).
- Pet profile + health pages: resolve locale via getPortalLocale()
  and pass it to all formatDateShort calls.
- SignalHistoryTimeline: accept optional locale prop, threaded from
  the pet profile.

Client-side date callers (orders, bookings, etc.) intentionally
left as-is — they get the user's browser locale via undefined.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 17:39:21 +02:00
g-butandClaude Opus 4.7 9629911d90 fix(i18n): respect user locale in date formatting
SignalHistoryTimeline hardcoded 'en-US', so non-English users on
the pet profile saw English dates regardless of their locale.

- SignalHistoryTimeline: route through formatIsoDate (uses runtime
  locale) for consistency with the rest of the app
- formatDateShort: accept optional locale param so localized server
  components can pass the resolved locale; default unchanged
- Public pet profile (under /[locale]/): pass locale to formatDateShort
  so 'Born …' renders in the visitor's language
- Tests: cover both en and ja explicitly so a non-en CI runtime
  doesn't break them (the prior implicit dependency on en-locale
  CI is what made the suite fragile)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 17:21:09 +02:00
g-butandClaude Sonnet 4.6 98db84d430 refactor(utils): consolidate formatPrice/formatDate/formatDateTime into lib/utils/format.ts
Four copies of formatPrice() and three copies of formatDate() were scattered
across portal and admin pages. Centralising eliminates future drift (e.g. a
currency symbol change or locale preference would previously require updating
4 files). Added formatIsoDate() and formatIsoDateTime() alongside the existing
domain formatters; updated all call-sites.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-24 20:03:20 +02:00
g-butandClaude Sonnet 4.6 8aa95c300e test: add format utils tests + fix formatRelativeDate timezone bug
formatRelativeDate used local midnight for the target date but all other
date operations in the codebase use UTC. For users in non-UTC timezones,
"today" could show as "yesterday". Fixed by using UTC midnight on both
sides of the comparison.

Also adds 11 unit tests for formatDateShort, formatWeight,
formatTemperature, and formatRelativeDate; and 2 missing pet-signal
cases (no metrics + overdue vaccinations → concern; high anxiety →
out-of-range watch).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-24 09:18:56 +02:00
g-butandClaude Sonnet 4.6 d4c36fd162 refactor(dry): extract pet age formatting into shared format utils
Add formatPetAgeShort() and formatPetAge() to lib/utils/format.ts.
Replace 4 identical inline ageLabel/ageString functions across adopt
listing cards (compact) and adopt/pet detail pages (verbose).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-24 06:23:58 +02:00
g-butandClaude Sonnet 4.6 ddfb647149 feat: scaffold Petvity — global pet care platform
Full Phase 1 scaffold:
- Next.js 16 + TypeScript strict + Tailwind 4 + Neon/Drizzle + NextAuth 5
- 9-language i18n (EN DE FR ES JA ZH KO TR AR) with RTL support for Arabic
- SSOT config: species (10 types), health metrics (7 KPIs), pet signal system
- DB schema: pets, healthMetrics (unique per pet+day), vaccinations, medications,
  healthRecords, emailQueue
- Numeric storage: weight=grams, temperature=centidegrees (no float drift)
- computePetSignal() — pure domain function, 9 unit tests passing
- API routes: auth, account, pets CRUD, health metrics (upsert), records,
  vaccinations, medications, public pet profiles (no auth)
- Cron: health-alerts, vaccination-reminders, email queue (all Bearer-protected)
- Portal UI: dashboard, pet list, add pet, health tracking, log page, vaccinations
- Public influencer pet profiles at /[locale]/pets/[handle]
- Email templates: welcome sequence, health alert, vaccination reminder

pnpm build ✓  pnpm test ✓ (9/9)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 19:19:52 +02:00