feat: add previous companies information#132
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
More reviews will be available in 55 minutes and 52 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds previous company names to the Companies House API output, introduces a ChangesCompany Name History Timeline
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Actionable comments posted: 0 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/src/utils.ts (1)
1-115:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winPipeline failure: Format check failed.
The CI pipeline reports formatting issues in this file. You must run
bun format(or the equivalent formatter command) to fix the formatting before this PR can be merged.#!/bin/bash # Run the formatter to fix the formatting issues bun format🤖 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 `@apps/web/src/utils.ts` around lines 1 - 115, The file fails CI due to formatting; run the project formatter (bun format) to reformat this file and commit the changes so the pipeline passes. Locate the utilities in this diff—functions like titleCase, slugify, formatAddress, dlog, formatLocation, and formatDate—and run `bun format` (or your repo's configured formatter) to automatically fix spacing/linebreaks, then review and stage the reformatted file and push the commit.
🧹 Nitpick comments (1)
apps/web/src/routes/company.$id.$slug.tsx (1)
103-114: ⚡ Quick winConsider extracting the displayName/registeredAs computation logic.
The
head()function (lines 103-114) and theCompanyDetailcomponent (lines 220-229) both implement similar logic to compute the display name and determine whether the HMRC name differs from the Companies House name. Extracting this into a shared helper would reduce duplication and ensure consistency.♻️ Proposed refactor to extract shared logic
+// Compute display name and alternate registration, preferring Companies House over HMRC. +function computeDisplayNames( + hmrcName: string, + companiesHouseName?: string | null, +) { + const displayName = companiesHouseName + ? titleCase(companiesHouseName) + : titleCase(hmrcName); + const currentKey = normalizeName(companiesHouseName ?? hmrcName); + const alsoRegisteredAs = + normalizeName(hmrcName) !== currentKey ? titleCase(hmrcName) : null; + return { displayName, alsoRegisteredAs, currentKey }; +} + export const Route = createFileRoute('/company/$id/$slug')({Then use it in both locations:
head: ({ match }) => { // ... - const name = loaderData - ? titleCase( - loaderData.profile?.company_name ?? - loaderData.sponsor.organisationName, - ) - : 'Company Details'; - const registeredAs = - loaderData && - normalizeName(loaderData.sponsor.organisationName) !== normalizeName(name) - ? titleCase(loaderData.sponsor.organisationName) - : ''; + const { displayName: name, alsoRegisteredAs: registeredAs } = loaderData + ? computeDisplayNames( + loaderData.sponsor.organisationName, + loaderData.profile?.company_name, + ) + : { displayName: 'Company Details', alsoRegisteredAs: null };function CompanyDetail() { // ... - const hmrcName = titleCase(sponsor.organisationName); - const displayName = profile?.company_name - ? titleCase(profile.company_name) - : hmrcName; - const currentKey = normalizeName( - profile?.company_name ?? sponsor.organisationName, - ); - const alsoRegisteredAs = - normalizeName(sponsor.organisationName) !== currentKey ? hmrcName : null; + const { displayName, alsoRegisteredAs, currentKey } = computeDisplayNames( + sponsor.organisationName, + profile?.company_name, + );Also applies to: 220-229
🤖 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 `@apps/web/src/routes/company`.$id.$slug.tsx around lines 103 - 114, The display-name/registered-as logic is duplicated in head() and CompanyDetail; extract it into a single exported helper (e.g., getCompanyDisplayNames or computeDisplayNames) that accepts loaderData and returns { displayName, registeredAs } using normalizeName and titleCase, preserve the current fallback ('Company Details') behavior, and update head() and the CompanyDetail component to call this helper instead of duplicating the logic; ensure the helper has correct typing/exports so both modules can import it.
🤖 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.
Outside diff comments:
In `@apps/web/src/utils.ts`:
- Around line 1-115: The file fails CI due to formatting; run the project
formatter (bun format) to reformat this file and commit the changes so the
pipeline passes. Locate the utilities in this diff—functions like titleCase,
slugify, formatAddress, dlog, formatLocation, and formatDate—and run `bun
format` (or your repo's configured formatter) to automatically fix
spacing/linebreaks, then review and stage the reformatted file and push the
commit.
---
Nitpick comments:
In `@apps/web/src/routes/company`.$id.$slug.tsx:
- Around line 103-114: The display-name/registered-as logic is duplicated in
head() and CompanyDetail; extract it into a single exported helper (e.g.,
getCompanyDisplayNames or computeDisplayNames) that accepts loaderData and
returns { displayName, registeredAs } using normalizeName and titleCase,
preserve the current fallback ('Company Details') behavior, and update head()
and the CompanyDetail component to call this helper instead of duplicating the
logic; ensure the helper has correct typing/exports so both modules can import
it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: c7b81020-98b1-407b-a7c3-d2dacd60bd0b
📒 Files selected for processing (5)
apps/web/src/api/companiesHouse.tsapps/web/src/components/NameHistory.tsxapps/web/src/routes/company.$id.$slug.tsxapps/web/src/utils.tsapps/web/src/utils/jsonld.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- apps/web/src/api/companiesHouse.ts
- apps/web/src/components/NameHistory.tsx
Summary by CodeRabbit