Skip to content

Conversation

@HuberTRoy
Copy link
Member

@HuberTRoy HuberTRoy commented Nov 6, 2025

Description

  • Improve chs.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Summary by CodeRabbit

  • Updates
    • Subscription retrieval now leverages wallet addresses for improved user identification and data accuracy.
    • Hosting plan query functionality enhanced with wallet-based validation and filtering capabilities.
    • Account availability verification added to ensure valid requests before processing data.

@coderabbitai
Copy link

coderabbitai bot commented Nov 6, 2025

Walkthrough

API integration updates modify two user data fetching functions to be wallet-aware. getUserSubscriptions and getUserHostingPlansByProject now accept wallet/address parameters and call updated endpoints. MyHostedPlan component is updated to pass account information to these calls and adds validation guards.

Changes

Cohort / File(s) Summary
Hook API Updates
src/hooks/useConsumerHostServices.tsx
getUserSubscriptions now accepts address parameter and requests GET /subscriptions/wallet/{address}. getUserHostingPlansByProject adds wallet parameter to function signature and request query string.
Consumer Component Integration
src/pages/consumer/MyFlexPlans/MyHostedPlan/MyHostedPlan.tsx
Updated getUserSubscriptions and getUserHostingPlansByProject call sites to pass account/wallet parameters. Removed updateHostingPlanApi from hook return destructuring. Added account validation guard in initSubscriptions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify wallet/address parameters are correctly threaded through all call sites
  • Confirm updated endpoint URLs match API specification
  • Check that guard clause logic for account validation doesn't introduce unexpected early exits
  • Ensure consistency of parameter handling (account || '' fallback behavior)

Possibly related PRs

  • feat: subscription #875: Directly modifies the same hook (src/hooks/useConsumerHostServices.tsx) and call sites (MyHostedPlan.tsx), updating getUserSubscriptions and getUserHostingPlansByProject signatures and their usage patterns.

Suggested reviewers

  • cool-firer

Poem

🐰 Wallets now whisper their secrets so sweet,
To API endpoints where subscriptions meet,
With addresses tucked in each query we send,
The data flows wallet-aware, friend!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning Description is largely incomplete—it lacks ticket reference, detailed summary of changes, test cases, and only minimally addresses the template requirements. Expand description to include: ticket number, detailed summary of API signature changes, dependencies, comprehensive test cases, and rationale for the modifications.
Title check ❓ Inconclusive Title is vague and generic—'Feat/subscription' doesn't clearly convey the specific changes (API endpoint modifications, parameter additions) made to the pull request. Revise title to be more descriptive, such as 'Update subscription and hosting plan API calls to accept wallet/address parameters' or similar.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/subscription

Comment @coderabbitai help to get the list of available commands and usage tips.

@HuberTRoy HuberTRoy merged commit befd7f2 into main Nov 6, 2025
2 of 3 checks passed
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/pages/consumer/MyFlexPlans/MyHostedPlan/MyHostedPlan.tsx (2)

132-135: Remove redundant empty string fallback.

The guard on line 132 already ensures account is truthy before proceeding. The account || '' fallback on line 135 is unnecessary and creates confusion about the expected value.

Apply this diff to simplify:

   const initSubscriptions = async () => {
     if (!account) return;
     try {
       setLoading(true);
-      const res = await getUserSubscriptions(account || '');
+      const res = await getUserSubscriptions(account);
       if (!isConsumerHostError(res.data)) {

149-179: Consider adding an account guard for consistency.

While fetchHostingPlans will only be called when subscriptions exist (which requires account), adding an explicit guard would make the code more defensive and consistent with initSubscriptions.

Apply this diff:

   const fetchHostingPlans = async (projectId: number) => {
+    if (!account) return;
     try {
       setExpandLoading(true);
-      const res = await getUserHostingPlansByProject(projectId, account || '');
+      const res = await getUserHostingPlansByProject(projectId, account);
       if (!isConsumerHostError(res.data)) {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f9fbdb and d4f47a4.

📒 Files selected for processing (2)
  • src/hooks/useConsumerHostServices.tsx (2 hunks)
  • src/pages/consumer/MyFlexPlans/MyHostedPlan/MyHostedPlan.tsx (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/pages/consumer/MyFlexPlans/MyHostedPlan/MyHostedPlan.tsx (1)
src/hooks/useConsumerHostServices.tsx (1)
  • isConsumerHostError (22-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (2)
src/hooks/useConsumerHostServices.tsx (2)

510-522: Implementation looks good with query parameter approach.

Using query parameters for the wallet parameter is a safer approach than path parameters, as it makes empty values more explicit (?wallet=) and easier for the backend to validate.


453-462: Verify backend validation and confirm address cannot be empty.

The function has ONE call site at src/pages/consumer/MyFlexPlans/MyHostedPlan/MyHostedPlan.tsx:135 which calls getUserSubscriptions(account || ''). While a guard condition (if (!account) return;) exists on line 132, the defensive fallback || '' suggests the code expects empty addresses as possible. The endpoint directly injects this into the path without validation.

Confirm:

  • Does the backend validate and reject empty wallet addresses?
  • Can account ever be an empty string despite the guard condition?
  • Is the || '' fallback necessary, or can it be removed for clarity?

const res = await getUserSubscriptions();
const res = await getUserSubscriptions(account || '');
if (!isConsumerHostError(res.data)) {
console.warn(res.data);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove debug logging statement.

The console.warn statement appears to be leftover debug code and should be removed before merging to production.

Apply this diff:

       const res = await getUserSubscriptions(account);
       if (!isConsumerHostError(res.data)) {
-        console.warn(res.data);
         setSubscriptions(res.data);
       } else {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.warn(res.data);
const res = await getUserSubscriptions(account);
if (!isConsumerHostError(res.data)) {
setSubscriptions(res.data);
} else {
🤖 Prompt for AI Agents
In src/pages/consumer/MyFlexPlans/MyHostedPlan/MyHostedPlan.tsx around line 137,
remove the leftover debug logging statement `console.warn(res.data);` so no
debug console output remains in production; delete that line (or replace with
proper user-facing/error handling logic if needed) and run lint/tests to ensure
nothing else depends on it.

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.

3 participants