Skip to content

refactor(vendor): extract shared VENDOR_CATEGORIES and VENDOR_CATEGORY_LABELS constants - #280

Draft
dccakes wants to merge 1 commit into
mainfrom
claude/sharp-feynman-0okbd7
Draft

dccakes wants to merge 1 commit into
mainfrom
claude/sharp-feynman-0okbd7

Conversation

@dccakes

@dccakes dccakes commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Daily Product Improvement

Summary

Extracted the duplicated CATEGORY_LABELS and vendor category list into a single shared vendor-constants.ts module, removing identical definitions that existed across three files.

Recommendations Reviewed

1. Extract duplicated CATEGORY_LABELS into a shared vendor constants file

  • Area: vendor-form.tsx, vendor-category-section.tsx, vendor/index.tsx
  • Issue: CATEGORY_LABELS was defined identically in two files. The ordered category list appeared as VENDOR_CATEGORIES in one file and CATEGORY_ORDER in another — same values, different names.
  • Recommendation: Consolidate into a single vendor-constants.ts module imported by all three files.
  • Type: Frontend cleanup
  • Priority: Medium
  • Effort: Small

2. Remove redundant dual state in QuoteFileUploader

  • Area: vendor-detail-panel.tsx
  • Issue: isSubmitting and isUploading are always set to the same value simultaneously; const busy = isSubmitting || isUploading is never independently differentiated.
  • Recommendation: Collapse to a single isBusy state.
  • Type: Frontend cleanup
  • Priority: Low
  • Effort: Small

3. VendorApiWithEnrichment type cast bypasses TypeScript safety

  • Area: vendor-detail-panel.tsx
  • Issue: The manual VendorApiWithEnrichment type is cast onto api.vendor, indicating the enrichment endpoints aren't in the tRPC router type.
  • Recommendation: Surface enrichment endpoints in the actual router type and remove the cast.
  • Type: Frontend cleanup / Backend cleanup
  • Priority: Medium
  • Effort: Large

4. Vendor scratchpad requires explicit save — inconsistent with auto-saving toggles

  • Area: vendor-detail-panel.tsx
  • Issue: The scratchpad needs a button click while the "Contacted" toggle saves immediately. Creates an inconsistent mental model.
  • Recommendation: Auto-save on blur with a debounce, or add a visible saved indicator.
  • Type: UX/UI, Product flow
  • Priority: Medium
  • Effort: Medium

5. vendor-detail-panel.tsx is 936 lines and handles too many responsibilities

  • Area: vendor-detail-panel.tsx
  • Issue: Images, scratchpad, interaction log, custom fields, and quotes are all in one component. Hard to maintain and test.
  • Recommendation: Split into focused sub-components (e.g. VendorQuotesSection, VendorNotesSection).
  • Type: Frontend cleanup
  • Priority: Low
  • Effort: Large

Selected Improvement

Extract CATEGORY_LABELS and the ordered category list out of three separate vendor files into a single vendor-constants.ts module.

Why This Was Selected

Both CATEGORY_LABELS records were byte-for-byte identical. The category order list carried two different names (VENDOR_CATEGORIES vs CATEGORY_ORDER) for the same eight values. Any future addition of a vendor category (or label correction) required finding and updating multiple files — a classic drift risk. This fix is small, safe, and immediately reduces maintenance surface with zero behavior change.

Changes Made

  • Created src/components/vendor/vendor-constants.ts exporting VENDOR_CATEGORIES and VENDOR_CATEGORY_LABELS
  • Removed local CATEGORY_LABELS definition from vendor-form.tsx and vendor-category-section.tsx
  • Removed local VENDOR_CATEGORIES from vendor-form.tsx and CATEGORY_ORDER from vendor/index.tsx
  • Updated all three files to import from the new shared module

Files Changed

  • src/components/vendor/vendor-constants.ts (new)
  • src/components/vendor/index.tsx
  • src/components/vendor/vendor-category-section.tsx
  • src/components/vendor/vendor-form.tsx

Verification

  • tsc --noEmit — no new type errors
  • biome check — 17 pre-existing nursery warnings, no new errors
  • All 2080 unit tests pass (run by pre-commit lint-staged hook)
  • Diff reviewed: no behavior change, only import sources changed

Future Recommendations

Collapse redundant dual state in QuoteFileUploader

  • Priority: Low
  • Effort: Small
  • Reason not included: Small cleanup, lower priority than the duplication fix
  • Should become GitHub issue: No

Remove VendorApiWithEnrichment type cast

  • Priority: Medium
  • Effort: Large — requires surfacing enrichment endpoints in the tRPC router type
  • Reason not included: Large; needs investigation of server-side enrichment setup
  • Should become GitHub issue: Yes

Auto-save vendor scratchpad on blur

  • Priority: Medium
  • Effort: Medium — needs debounce logic and a saved indicator
  • Reason not included: Product flow change that warrants separate review
  • Should become GitHub issue: Yes

Split vendor-detail-panel.tsx into focused sub-components

  • Priority: Low
  • Effort: Large
  • Reason not included: Large refactor; no functional benefit without additional context on pain points
  • Should become GitHub issue: No

GitHub Issues Created or Proposed

No issues created. The two Medium-priority recommendations above (type cast cleanup and auto-save scratchpad) are proposed as future GitHub issues. Neither met the bar for creation today — the type cast requires investigation scope and the auto-save is a product UX decision that should have design input before tracking.


Generated by Claude Code

…Y_LABELS constants

CATEGORY_LABELS was defined identically in vendor-form.tsx and
vendor-category-section.tsx. The ordered category list appeared as
VENDOR_CATEGORIES in vendor-form.tsx and CATEGORY_ORDER in index.tsx.

Consolidates both into a single vendor-constants.ts module so any future
category label change is made in one place with no drift risk.
@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
scv Error Error Aug 31, 2026 2:17pm

@github-actions

Copy link
Copy Markdown
Contributor

Jest Test Coverage

Coverage Summary

Lines Statements Branches Functions
Coverage: 83%
83.11% (36256/43621) 82.14% (3813/4642) 69.49% (1073/1544)

This branch had an error being deployed

1 failed deployment
Preview — b464a1e2 Deployed Aug 31, 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.

1 participant