Skip to content

refactor: migrate account emails to dedicated api#1653

Closed
arpitgupta1214 wants to merge 2 commits intotestfrom
codex/account-emails-chat-clean-pr
Closed

refactor: migrate account emails to dedicated api#1653
arpitgupta1214 wants to merge 2 commits intotestfrom
codex/account-emails-chat-clean-pr

Conversation

@arpitgupta1214
Copy link
Copy Markdown
Collaborator

@arpitgupta1214 arpitgupta1214 commented Apr 7, 2026

Summary

  • switch account email lookups to the dedicated API endpoint
  • remove the old local /api/account-emails route
  • use the new account-scoped account_id contract from the frontend
  • simplify useAccountEmails so it owns its query key

Testing

  • no dedicated lib test retained for fetchAccountEmails

Summary by cubic

Migrated account email lookups to the dedicated accounts API with bearer auth, removed the local route, and switched consumers to a shared hook for simpler and safer fetching.

  • Refactors
    • Added useAccountEmails hook that owns its query key and requires auth.
    • Added fetchAccountEmails to call /api/accounts/emails with account_id params and Authorization header.
    • Replaced manual queries in FileInfoDialog and TasksList with the new hook.
    • Removed legacy Next.js route at /api/account-emails.
    • Standardized on the account-scoped account_id contract.

Written for commit 130d00f. Summary will update on new commits.

Summary by CodeRabbit

  • Refactor
    • Optimized account email fetching mechanism for improved performance and maintainability across the application.

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 7, 2026

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

Project Deployment Actions Updated (UTC)
recoup-chat Ready Ready Preview Apr 7, 2026 10:03pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 7, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The PR removes a Next.js API route handler for fetching account emails and replaces it with a client-side React hook (useAccountEmails) paired with a utility function (fetchAccountEmails). Components previously using inline useQuery now consume the dedicated hook for improved code reusability and cleaner separation of concerns.

Changes

Cohort / File(s) Summary
API Route Removal
app/api/account-emails/route.ts
Removed entire GET handler including request validation, authorization checks, and the force-dynamic export (45 lines). Functionality migrated to client-side pattern.
Client-Side Hook & Utility
hooks/useAccountEmails.ts, lib/accounts/fetchAccountEmails.ts
Added new React hook leveraging Privy authentication and React Query. Paired with a utility function that constructs /api/accounts/emails requests with account ID query parameters and Bearer token authorization.
Component Updates
components/Files/FileInfoDialog.tsx, components/TasksPage/TasksList.tsx
Replaced inline useQuery calls with useAccountEmails hook invocations. Both components now pass only accountIds to the hook and rely on its batching/execution logic rather than managing query state directly.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested Reviewers

  • sweetmantech

Poem

🎣 From route to hook, the emails now flow,
Client-side tides make the logic clean,
Privy tokens lead the way below,
Where once the server stood, now hooks convene. ✨

🚥 Pre-merge checks | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Solid & Clean Code ⚠️ Warning PR improves SOLID principles through better separation of concerns but fails clean code error-handling practices in three areas: silent query failures, unfiltered account IDs, and missing ARIA attributes. Add isOwnerEmailError handling to FileInfoDialog, filter account IDs with .filter((id): id is string => Boolean(id)), and add role="alert" and aria-live="polite" to error div in TasksList.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/account-emails-chat-clean-pr

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 and usage tips.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: This PR refactors API communication, migrates to a new endpoint, and changes authentication logic (Privy bearer tokens), which are high-impact changes requiring human review.

@arpitgupta1214
Copy link
Copy Markdown
Collaborator Author

Reopening from the proper branch name.

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