Skip to content

fix: make calculator, publish, profile and Excel import work - #113

Open
paccloud wants to merge 2 commits into
mainfrom
fix/calculator-p0-bugs
Open

paccloud wants to merge 2 commits into
mainfrom
fix/calculator-p0-bugs

Conversation

@paccloud

Copy link
Copy Markdown
Owner

Fixes the four functional P0 bugs from the September 2026 platform review (#112).

Changes

Calculator works without /api/fish-data. None of the 655 bundled FISH_DATA_V3 conversions carried from/to fields, so the "From" dropdown was empty whenever the API failed: offline, in local dev, or on a fresh deploy. The new app/src/lib/fishDataShape.js derives them from the "From → To" keys. An API response replaces the bundled data only if it contains usable conversions.

  • A yield of 0 used to be silently treated as 100%. Yields outside 0 < y ≤ 100 now disable Calculate and show an inline message.
  • The result is cleared when an input changes, so a stale price never stays on screen.

Publish/unpublish sent no auth header. DataContext called user?.getAuthHeaders?.(), a method the user object doesn't have. Requests got a 401 and the modal closed silently. It now uses getAuthHeaders from useAuth(). On a permanent failure the preview modal stays open and shows an error.

Contributor profile loaded blank in production. /api/contributor/me exists only in Express, so it now calls /api/contributor. show_on_page also accepts Postgres booleans, not just SQLite 1.

Excel "42%" imported as 0.42%. rowsFromWorksheet stringified every cell, so the XLSX fraction check never ran. XLSX numeric cells are now kept as numbers, while CSV values stay strings, so "0.5" means 0.5%. The local server/importRows.js now behaves the same; it used to scale CSV "0.5" to 50%.

Once this is deployed, production user_data rows with a yield ≤ 1 may need a manual look. They could be past imports that hit this bug.

Testing

  • New fishDataShape.test.js: every bundled conversion gets from/to, Pink Salmon offers Round → Skinless Fillet at 42% (range 41–46), and yield validation works.
  • New end-to-end import tests using a real in-memory XLSX with a 0%-formatted 0.42 cell, and a CSV. The XLSX test fails on main (it gets 0.42) and passes here.
  • npm run lint: 0 errors, with 2 pre-existing warnings. npm test: 2205 pass. npm run build: passes.
  • Browser check with every /api/** request blocked: Pink Salmon lists its starting forms, a price is computed, and Calculate is disabled at a yield of 0.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PnPh61Aps5neY87hh1pu9T


Generated by Claude Code

- Calculator: derive from/to states from bundled FISH_DATA_V3 keys so it
  works offline and when /api/fish-data fails; only replace bundled data
  with a usable API response. Reject yields outside (0, 100] instead of
  silently treating 0 as 100%, and clear stale results on input edits.
- Publish/unpublish: use getAuthHeaders from useAuth (user had no such
  method, so requests went out unauthenticated and failed silently);
  show an error in the preview modal on permanent failure.
- Contributor profile: call /api/contributor (the /me path only exists
  in Express) and accept Postgres booleans for show_on_page.
- Import: keep numeric XLSX cells so a "42%" cell imports as 42, not
  0.42; CSV "0.5" stays 0.5% in both backends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PnPh61Aps5neY87hh1pu9T
@vercel

vercel Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
fish-cost-calculator Ready Ready Preview Sep 28, 2026 7:46pm UTC

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T19:49:40.379944Z a5d3c6f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 44 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 13aa6aad-18f3-4eb3-991c-cec79e236ea8

📥 Commits

Reviewing files that changed from the base of the PR and between d6ee642 and a5d3c6f.

📒 Files selected for processing (9)
  • api/_lib/importRows.js
  • app/src/components/Calculator.jsx
  • app/src/components/ContributorProfile.jsx
  • app/src/components/PreviewPublishModal.jsx
  • app/src/context/DataContext.jsx
  • app/src/lib/__tests__/importRows.test.js
  • app/src/lib/fishDataShape.js
  • app/src/lib/fishDataShape.test.js
  • server/importRows.js

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.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 22dbe218fb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/src/context/DataContext.jsx Outdated

This branch was successfully deployed

1 active deployment
Preview — a5d3c6f3 Deployed Sep 28, 2026 by vercel[bot]
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.

2 participants