Skip to content

Conversation

@sweetmantech
Copy link
Collaborator

Summary

  • Remove /api/account, /api/account/update, and /api/account/add_artist endpoints from Recoup-Chat
  • Update useUser.tsx to call Recoup-API's POST /api/accounts and PATCH /api/accounts endpoints
  • Update useOrgSettings.ts to call Recoup-API's PATCH /api/accounts endpoint
  • This completes the migration of account endpoints to Recoup-API (PR hotfix: segment error #152)

Changes

Old Endpoint New Endpoint
POST /api/account POST https://recoup-api.vercel.app/api/accounts
POST /api/account/update PATCH https://recoup-api.vercel.app/api/accounts
GET /api/account/add_artist POST https://recoup-api.vercel.app/api/accounts/artists

Test plan

  • Run pnpm build to verify compilation
  • Test user login flow (creates/retrieves account)
  • Test user profile update (name, image, instruction)
  • Test organization settings update

🤖 Generated with Claude Code

- Update useUser.tsx to use Recoup-API for account creation and updates
- Update useOrgSettings.ts to use Recoup-API for account updates
- Remove /api/account, /api/account/update, /api/account/add_artist endpoints
- Use PATCH method for account updates per new API design

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@vercel
Copy link
Contributor

vercel bot commented Jan 22, 2026

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

Project Deployment Review Updated (UTC)
recoup-chat Ready Ready Preview Jan 22, 2026 7:15pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestion:

The response structure expected by the PATCH /api/accounts endpoint appears to be incorrect, matching the same issue in useUser.tsx. The code should access data.account instead of data.data.

View Details
📝 Patch Details
diff --git a/hooks/useOrgSettings.ts b/hooks/useOrgSettings.ts
index ce91da1b..d429f69e 100644
--- a/hooks/useOrgSettings.ts
+++ b/hooks/useOrgSettings.ts
@@ -155,7 +155,7 @@ const useOrgSettings = (orgId: string | null) => {
 
       if (response.ok) {
         const data = await response.json();
-        setOrgData(data.data);
+        setOrgData(data.account);
         // Invalidate org list cache so sidebar shows updated image/name immediately
         await queryClient.invalidateQueries({ queryKey: ["accountOrganizations"] });
         return true;
diff --git a/hooks/useUser.tsx b/hooks/useUser.tsx
index b2899d16..de3cb62a 100644
--- a/hooks/useUser.tsx
+++ b/hooks/useUser.tsx
@@ -86,7 +86,7 @@ const useUser = () => {
       }
 
       const data = await response.json();
-      setUserData(data.data);
+      setUserData(data.account);
       setIsModalOpen(false);
     } catch {
       // Error handled silently
@@ -139,14 +139,14 @@ const useUser = () => {
       }
 
       const data = await response.json();
-      setUserData(data.data);
-      setImage(data.data?.image || "");
-      setInstruction(data.data?.instruction || "");
-      setName(data?.data?.name || "");
-      setOrganization(data?.data?.organization || "");
-      setJobTitle(data?.data?.job_title || "");
-      setRoleType(data?.data?.role_type || "");
-      setCompanyName(data?.data?.company_name || "");
+      setUserData(data.account);
+      setImage(data.account?.image || "");
+      setInstruction(data.account?.instruction || "");
+      setName(data?.account?.name || "");
+      setOrganization(data?.account?.organization || "");
+      setJobTitle(data?.account?.job_title || "");
+      setRoleType(data?.account?.role_type || "");
+      setCompanyName(data?.account?.company_name || "");
     };
     if (!email && !address) return;
     init();

Analysis

Incorrect API response field access for Recoup-API /api/accounts endpoint

What fails: The PATCH endpoint response handling in useOrgSettings.ts (line 157) and useUser.tsx (lines 88 and 141) incorrectly accesses data.data instead of data.account, causing the organization and user data to be set to undefined after updates.

How to reproduce:

  1. In useOrgSettings.ts, call the save() function to update organization settings via PATCH /api/accounts
  2. Observe that after the PATCH request completes, orgData becomes null instead of containing the updated account information

Result: Organization settings persist on the server but the UI state is cleared, losing the loaded organization data and breaking the settings display.

Expected: The PATCH /api/accounts endpoint returns the same response structure as the GET /api/accounts/{id} endpoint, which follows the format { status: "success", account: {...} }. The response field should be accessed via data.account, consistent with the GET endpoint implementation (useOrgSettings.ts line 72) which was already corrected in commit b2c15b0.

Files fixed:

  • hooks/useOrgSettings.ts line 157: Changed setOrgData(data.data) to setOrgData(data.account)
  • hooks/useUser.tsx line 88: Changed setUserData(data.data) to setUserData(data.account) in PATCH handler
  • hooks/useUser.tsx lines 141-150: Changed all data.data references to data.account in POST handler for account initialization
Fix on Vercel

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