Skip to content

Conversation

@huamanraj
Copy link
Collaborator

@huamanraj huamanraj commented Nov 27, 2025

fix #213

  • added cache invalidation and fetching for subscription status in PaymentFlow
  • implemented a manual refetch function in useSubscription for immediate updates
  • adjusted stale time for subscription data from 5 minutes to 2 minutes

Summary by CodeRabbit

  • Bug Fixes

    • Payment verification now redirects immediately and triggers a best-effort background refresh of subscription status (short race timeout); refresh failures are non-blocking and logged.
    • Subscription status refresh is more frequent and now also occurs on window focus.
    • Payment initiation errors: authentication errors redirect to login preserving the current page return path; other errors show a user-friendly alert.
    • Session checks now re-authenticate when an access token is missing.
  • New Features

    • Exposes a manual subscription refetch action for components to trigger status refresh.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Nov 27, 2025

@huamanraj is attempting to deploy a commit to the AJEET PRATAP SINGH's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 27, 2025

Walkthrough

PaymentFlow now captures the current pathname for login callbacks, immediately redirects to /checkout after payment verification, and starts a best-effort background invalidate+refetch of subscriptionStatus (raced against a 3s timeout). useSubscription adds refetchSubscription() and tightens cache timings. TRPC client/server defaults changed from port 4000 to 8080 when env var is absent.

Changes

Cohort / File(s) Summary
Payment Flow Cache Sync & Redirects
apps/web/src/components/payment/PaymentFlow.tsx
Uses usePathname() for encoded login callback, adds trpc.useUtils(), performs fire-and-forget invalidate(subscriptionStatus) + background refetch() raced with a 3s timeout. Redirects to /checkout immediately on success. Auth-related create-order failures redirect to login with encoded pathname; other errors show an alert.
Subscription Hook Refetch Mechanism
apps/web/src/hooks/useSubscription.ts
Adds trpc.useUtils(), exposes refetchSubscription() which invalidates subscriptionStatus then calls the query's refetch. Changes query options: refetchOnWindowFocus: true, staleTime reduced from 5m to 2m (gcTime unchanged).
TRPC Default URL change
apps/web/src/lib/trpc-server.ts, apps/web/src/providers/trpc-provider.tsx
Default TRPC base URL when NEXT_PUBLIC_API_URL is unset changed from http://localhost:4000 (or /trpc at port 4000) to http://localhost:8080 (and /trpc at port 8080). No header/auth logic changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PaymentFlow
    participant Auth as LoginRedirect
    participant TRPCUtils as trpc.useUtils()
    participant SubQuery as subscriptionStatus
    participant Router

    User->>PaymentFlow: complete payment
    PaymentFlow->>PaymentFlow: verify payment (trpc)
    alt verification requires auth
        PaymentFlow->>Auth: redirect to /api/auth/signin?callbackUrl=encoded(pathname)
    else verification succeeds
        PaymentFlow->>Router: immediate redirect to /checkout
        PaymentFlow->>TRPCUtils: invalidate(subscriptionStatus)  (fire-and-forget)
        TRPCUtils->>SubQuery: refetch() (background)
        par background race
            SubQuery-->>TRPCUtils: refetch result
        and 3s timeout
            Note right of PaymentFlow: timeout ends wait (non-blocking)
        end
        Note right of PaymentFlow: log non-fatal errors
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Inspect PaymentFlow race/timeout to avoid unhandled promise rejections or leaks.
  • Verify refetchSubscription() sequences utils.invalidate() before calling refetch().
  • Confirm TRPC URL default change won't break local dev or deployment assumptions.

Possibly related PRs

Poem

🐰 I nudged the cache and gave it a twitch,
A three-second hop before the switch,
Checkout bounced off while back-refresh runs light,
Logged whispers hush errors — all polite,
Now pro plans wake and take a bite! ✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes changes to default localhost URLs (port 4000 to 8080) across three files, which appears unrelated to the stated objective of fixing pro user verification issues. Clarify whether the localhost URL changes are necessary for this fix or should be separated into a different PR. If unrelated, revert the changes in trpc-server.ts and trpc-provider.tsx.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: pro user instant verification' directly relates to the main objective of fixing the bug where pro users aren't marked as verified/active immediately after plan activation.
Linked Issues check ✅ Passed The PR implements cache invalidation for subscription status and adds a refetch function to ensure immediate updates when users activate pro plans, directly addressing the bug where pro users weren't marked active without logging out.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@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 (1)
apps/web/src/hooks/useSubscription.ts (1)

75-79: type the refetchSubscription const and consider avoiding new as any usage

the new refetch helper is a good addition, but to match the project style you should give the const an explicit function type and, when feasible, avoid introducing another as any around the utils call.

for example:

+type RefetchSubscription = () => Promise<void>;
+
-  const refetchSubscription = async () => {
-    await (utils.user as any).subscriptionStatus.invalidate();
-    await refetch();
-  };
+  const refetchSubscription: RefetchSubscription = async () => {
+    await utils.user.subscriptionStatus.invalidate();
+    await refetch();
+  };

if the typed utils access doesn’t compile yet because of how trpc is declared, consider at least centralizing the as any in one place instead of repeating it. this keeps the hook’s public api clearer and makes later type cleanups easier. as per coding guidelines.

Also applies to: 85-85

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b1eaff and a0dc4f4.

📒 Files selected for processing (2)
  • apps/web/src/components/payment/PaymentFlow.tsx (2 hunks)
  • apps/web/src/hooks/useSubscription.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (11)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx,js,jsx}: Always use lowercase when writing comments
Avoid unnecessary comments; code should be self-documenting when possible
Use comments to explain 'why', not 'what'
Remove unused imports
Use UPPER_SNAKE_CASE for constants
Use camelCase for functions and variables

Files:

  • apps/web/src/hooks/useSubscription.ts
  • apps/web/src/components/payment/PaymentFlow.tsx
apps/web/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

apps/web/src/**/*.{ts,tsx}: Always follow the design system defined in apps/web/src/lib/design-tokens.ts and apps/web/tailwind.config.ts
NEVER use hardcoded hex values (e.g., #5519f7) directly in components; ALWAYS reference colors from the design token system using Tailwind classes
Use semantic color names that describe purpose, not appearance
Use font-sans for standard UI text (Geist Sans) and font-mono for code, technical content, or monospace needs (DM Mono)
Follow Tailwind's spacing scale (0.25rem increments); for section padding use mobile p-4 (1rem) and desktop p-[60px]
Use appropriate border radius: small elements rounded-lg, medium rounded-xl, large rounded-2xl, buttons rounded-[16px]
Use animation durations: fast duration-100 (0.1s), normal duration-300 (0.3s), slow duration-600 (0.6s)

Files:

  • apps/web/src/hooks/useSubscription.ts
  • apps/web/src/components/payment/PaymentFlow.tsx
**/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{tsx,ts}: Prefer functional components with TypeScript and use proper TypeScript types, avoid any
Extract reusable logic into custom hooks
Use descriptive prop names and define prop types using TypeScript interfaces or types
Prefer controlled components over uncontrolled
Use zustand for global state (located in src/store/)
Use absolute imports from @/ prefix when available
Include proper aria labels for accessibility
Ensure keyboard navigation works
Maintain proper heading hierarchy
Provide alt text for images
Avoid unnecessary re-renders

Files:

  • apps/web/src/hooks/useSubscription.ts
  • apps/web/src/components/payment/PaymentFlow.tsx
**/*.{tsx,ts,jsx,js}

📄 CodeRabbit inference engine (.cursorrules)

Organize imports: react → third-party → local components → utils → types

Files:

  • apps/web/src/hooks/useSubscription.ts
  • apps/web/src/components/payment/PaymentFlow.tsx
**/*[A-Z]*.{tsx,ts}

📄 CodeRabbit inference engine (.cursorrules)

Use PascalCase for component file names (e.g., UserProfile.tsx)

Files:

  • apps/web/src/hooks/useSubscription.ts
  • apps/web/src/components/payment/PaymentFlow.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx}: Use PascalCase for types and interfaces with descriptive names
Use dynamic imports for code splitting when appropriate
Memoize expensive computations

Files:

  • apps/web/src/hooks/useSubscription.ts
  • apps/web/src/components/payment/PaymentFlow.tsx
apps/web/src/**/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursorrules)

Optimize images using next/image

apps/web/src/**/*.{tsx,ts}: Use Zustand for global state, located in src/store/
Use PascalCase for types and interfaces with descriptive names
Use dynamic imports for code splitting when appropriate
Optimize images using next/image
Memoize expensive computations
Define a type when defining const functions

Files:

  • apps/web/src/hooks/useSubscription.ts
  • apps/web/src/components/payment/PaymentFlow.tsx
**/*.{js,jsx,ts,tsx,py,java,go,rb,php}

📄 CodeRabbit inference engine (.cursor/rules/general_rules.mdc)

**/*.{js,jsx,ts,tsx,py,java,go,rb,php}: Always use lowercase when writing comments
Avoid unnecessary comments; code should be self-documenting when possible
Use comments to explain 'why', not 'what'

Files:

  • apps/web/src/hooks/useSubscription.ts
  • apps/web/src/components/payment/PaymentFlow.tsx
apps/web/src/**/*.{tsx,ts,jsx,js}

📄 CodeRabbit inference engine (apps/web/.cursor/rules/frontend_rules.mdc)

apps/web/src/**/*.{tsx,ts,jsx,js}: Organize imports in order: React → third-party → local components → utils → types
Use absolute imports from @/ prefix when available
Remove unused imports
Use UPPER_SNAKE_CASE for constants
Use camelCase for functions and variables
Always use Tailwind classes for styling HTML elements; avoid using CSS or style tags
Use descriptive variable and function names; name event functions with a 'handle' prefix (e.g., handleClick, handleKeyDown)
Use const with arrow functions instead of function declarations (e.g., 'const toggle = () =>')

Files:

  • apps/web/src/hooks/useSubscription.ts
  • apps/web/src/components/payment/PaymentFlow.tsx
apps/web/src/components/**/*.{tsx,ts,jsx,js}

📄 CodeRabbit inference engine (apps/web/.cursor/rules/frontend_rules.mdc)

apps/web/src/components/**/*.{tsx,ts,jsx,js}: Never use hardcoded hex values directly in components; always reference colors from the design token system using Tailwind classes
Use semantic color names from the design token system that describe purpose, not appearance (e.g., bg-brand-purple, bg-surface-primary, text-text-primary)
Use font-sans for standard UI text (Geist Sans) and font-mono for code, technical content, or monospace needs (DM Mono)
Follow Tailwind's spacing scale for section padding: p-4 (1rem) on mobile, p-[60px] on desktop
Use rounded-lg (0.5rem) for small elements, rounded-xl (1rem) for medium elements, rounded-2xl (1.5rem) for large elements, and rounded-[16px] for buttons
Use duration-100 (0.1s) for fast transitions, duration-300 (0.3s) for normal transitions, and duration-600 (0.6s) for slow transitions
Use available custom animations: animate-accordion-down, animate-accordion-up, animate-scrollRight, animate-scrollLeft, animate-customspin, animate-spin-slow, animate-spin-slow-reverse, animate-marquee, animate-marquee-vertical, animate-shine
Prefer functional components with TypeScript
Extract reusable logic into custom hooks
Prefer controlled components over uncontrolled
Include proper aria labels for accessibility
Ensure keyboard navigation works in interactive components
Maintain proper heading hierarchy in page components
Provide alt text for images
Use 'class:' instead of the ternary operator in class tags whenever possible
Implement accessibility features on interactive elements (e.g., tabindex='0', aria-label, onClick, onKeyDown)
Always follow the design system defined in apps/web/src/lib/design-tokens.ts and apps/web/tailwind.config.ts

Files:

  • apps/web/src/components/payment/PaymentFlow.tsx
apps/web/src/components/**/*.{tsx,ts}

📄 CodeRabbit inference engine (apps/web/.cursor/rules/frontend_rules.mdc)

apps/web/src/components/**/*.{tsx,ts}: Use proper TypeScript types and avoid using any type
Use descriptive prop names and define prop types using TypeScript interfaces or types
Name components using PascalCase (e.g., UserProfile.tsx)

Files:

  • apps/web/src/components/payment/PaymentFlow.tsx
🧬 Code graph analysis (1)
apps/web/src/hooks/useSubscription.ts (2)
apps/web/src/lib/trpc.ts (1)
  • trpc (4-4)
apps/web/src/lib/auth/config.ts (1)
  • session (43-49)
🔇 Additional comments (1)
apps/web/src/hooks/useSubscription.ts (1)

22-37: subscription query config and utils usage look solid

using the utils helper with the subscriptionStatus query plus enabling refetch on window focus and shortening staleTime to 2 minutes should make subscription updates visible more quickly after payment; nothing here looks functionally risky for the instant‑verification flow.

@vercel
Copy link

vercel bot commented Nov 29, 2025

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

Project Deployment Preview Comments Updated (UTC)
opensox-website Ready Ready Preview Comment Nov 29, 2025 10:06am

@apsinghdev
Copy link
Owner

@huamanraj when i am trying to click on Invest, it is redirecting me to /login and after login, when im clicking on invest, it's redirecting me to /login again.

ref

Screen.Recording.2025-11-29.at.5.49.40.PM.mov

Copy link
Contributor

@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: 0

🧹 Nitpick comments (2)
apps/web/src/components/payment/PaymentFlow.tsx (2)

54-55: background subscription refresh is correctly decoupled; tighten promise handling and typing

this iife nicely makes subscription invalidation/refetch best-effort and no longer blocks a successful verification or redirect. one edge case: if subscriptionStatus.fetch rejects after the 3s timeout resolves, that rejection may be unhandled because nothing is awaiting/catching that promise anymore.

you can keep the current behavior while avoiding late unhandled rejections by attaching a .catch directly to the fetch promise and racing that instead:

-        (async () => {
-          try {
-            await (utils.user as any).subscriptionStatus.invalidate();
-            await Promise.race([
-              (utils.user as any).subscriptionStatus.fetch(undefined),
-              new Promise((resolve) => setTimeout(resolve, 3000)), // 3s timeout
-            ]);
-          } catch (refreshError) {
-            // log refresh errors separately without affecting payment flow
-            console.warn(
-              "subscription cache refresh failed (non-fatal):",
-              refreshError
-            );
-          }
-        })();
+        (async () => {
+          try {
+            await (utils.user as any).subscriptionStatus.invalidate();
+
+            const refreshPromise = (utils.user as any)
+              .subscriptionStatus
+              .fetch(undefined)
+              .catch((refreshError) => {
+                console.warn(
+                  "subscription cache refresh failed (non-fatal):",
+                  refreshError
+                );
+              });
+
+            await Promise.race([
+              refreshPromise,
+              new Promise((resolve) => setTimeout(resolve, 3000)), // 3s timeout
+            ]);
+          } catch (refreshError) {
+            console.warn(
+              "subscription cache invalidate failed (non-fatal):",
+              refreshError
+            );
+          }
+        })();

also, when you next touch this area, consider tightening the type for utils.user.subscriptionStatus so you don’t need as any here, in line with the “avoid any” guideline.

Also applies to: 76-96


9-9: dynamic callbackurl via usepathname should fix the login loop; verify whether query params matter

capturing pathname and using it in the login callbackUrl is a good improvement over the previous hard-coded path and should address the “invest → login → invest → login” loop when the user returns to the same page.

one thing to double-check: usePathname() does not include query parameters. if any pages hosting PaymentFlow rely on search params (for example ?plan=pro or other context) being preserved across login, consider augmenting this with useSearchParams() and building the callback url as \${pathname}?${searchParams.toString()}`beforeencodeURIComponent`. if not, the current approach is fine.

Also applies to: 47-47, 126-126, 177-177

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 685638b and 8ac6eb8.

📒 Files selected for processing (1)
  • apps/web/src/components/payment/PaymentFlow.tsx (5 hunks)
🧰 Additional context used
📓 Path-based instructions (11)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx,js,jsx}: Always use lowercase when writing comments
Avoid unnecessary comments; code should be self-documenting when possible
Use comments to explain 'why', not 'what'
Remove unused imports
Use UPPER_SNAKE_CASE for constants
Use camelCase for functions and variables

Files:

  • apps/web/src/components/payment/PaymentFlow.tsx
apps/web/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

apps/web/src/**/*.{ts,tsx}: Always follow the design system defined in apps/web/src/lib/design-tokens.ts and apps/web/tailwind.config.ts
NEVER use hardcoded hex values (e.g., #5519f7) directly in components; ALWAYS reference colors from the design token system using Tailwind classes
Use semantic color names that describe purpose, not appearance
Use font-sans for standard UI text (Geist Sans) and font-mono for code, technical content, or monospace needs (DM Mono)
Follow Tailwind's spacing scale (0.25rem increments); for section padding use mobile p-4 (1rem) and desktop p-[60px]
Use appropriate border radius: small elements rounded-lg, medium rounded-xl, large rounded-2xl, buttons rounded-[16px]
Use animation durations: fast duration-100 (0.1s), normal duration-300 (0.3s), slow duration-600 (0.6s)

Files:

  • apps/web/src/components/payment/PaymentFlow.tsx
**/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{tsx,ts}: Prefer functional components with TypeScript and use proper TypeScript types, avoid any
Extract reusable logic into custom hooks
Use descriptive prop names and define prop types using TypeScript interfaces or types
Prefer controlled components over uncontrolled
Use zustand for global state (located in src/store/)
Use absolute imports from @/ prefix when available
Include proper aria labels for accessibility
Ensure keyboard navigation works
Maintain proper heading hierarchy
Provide alt text for images
Avoid unnecessary re-renders

Files:

  • apps/web/src/components/payment/PaymentFlow.tsx
**/*.{tsx,ts,jsx,js}

📄 CodeRabbit inference engine (.cursorrules)

Organize imports: react → third-party → local components → utils → types

Files:

  • apps/web/src/components/payment/PaymentFlow.tsx
**/*[A-Z]*.{tsx,ts}

📄 CodeRabbit inference engine (.cursorrules)

Use PascalCase for component file names (e.g., UserProfile.tsx)

Files:

  • apps/web/src/components/payment/PaymentFlow.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx}: Use PascalCase for types and interfaces with descriptive names
Use dynamic imports for code splitting when appropriate
Memoize expensive computations

Files:

  • apps/web/src/components/payment/PaymentFlow.tsx
apps/web/src/**/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursorrules)

Optimize images using next/image

apps/web/src/**/*.{tsx,ts}: Use Zustand for global state, located in src/store/
Use PascalCase for types and interfaces with descriptive names
Use dynamic imports for code splitting when appropriate
Optimize images using next/image
Memoize expensive computations
Define a type when defining const functions

Files:

  • apps/web/src/components/payment/PaymentFlow.tsx
**/*.{js,jsx,ts,tsx,py,java,go,rb,php}

📄 CodeRabbit inference engine (.cursor/rules/general_rules.mdc)

**/*.{js,jsx,ts,tsx,py,java,go,rb,php}: Always use lowercase when writing comments
Avoid unnecessary comments; code should be self-documenting when possible
Use comments to explain 'why', not 'what'

Files:

  • apps/web/src/components/payment/PaymentFlow.tsx
apps/web/src/components/**/*.{tsx,ts,jsx,js}

📄 CodeRabbit inference engine (apps/web/.cursor/rules/frontend_rules.mdc)

apps/web/src/components/**/*.{tsx,ts,jsx,js}: Never use hardcoded hex values directly in components; always reference colors from the design token system using Tailwind classes
Use semantic color names from the design token system that describe purpose, not appearance (e.g., bg-brand-purple, bg-surface-primary, text-text-primary)
Use font-sans for standard UI text (Geist Sans) and font-mono for code, technical content, or monospace needs (DM Mono)
Follow Tailwind's spacing scale for section padding: p-4 (1rem) on mobile, p-[60px] on desktop
Use rounded-lg (0.5rem) for small elements, rounded-xl (1rem) for medium elements, rounded-2xl (1.5rem) for large elements, and rounded-[16px] for buttons
Use duration-100 (0.1s) for fast transitions, duration-300 (0.3s) for normal transitions, and duration-600 (0.6s) for slow transitions
Use available custom animations: animate-accordion-down, animate-accordion-up, animate-scrollRight, animate-scrollLeft, animate-customspin, animate-spin-slow, animate-spin-slow-reverse, animate-marquee, animate-marquee-vertical, animate-shine
Prefer functional components with TypeScript
Extract reusable logic into custom hooks
Prefer controlled components over uncontrolled
Include proper aria labels for accessibility
Ensure keyboard navigation works in interactive components
Maintain proper heading hierarchy in page components
Provide alt text for images
Use 'class:' instead of the ternary operator in class tags whenever possible
Implement accessibility features on interactive elements (e.g., tabindex='0', aria-label, onClick, onKeyDown)
Always follow the design system defined in apps/web/src/lib/design-tokens.ts and apps/web/tailwind.config.ts

Files:

  • apps/web/src/components/payment/PaymentFlow.tsx
apps/web/src/components/**/*.{tsx,ts}

📄 CodeRabbit inference engine (apps/web/.cursor/rules/frontend_rules.mdc)

apps/web/src/components/**/*.{tsx,ts}: Use proper TypeScript types and avoid using any type
Use descriptive prop names and define prop types using TypeScript interfaces or types
Name components using PascalCase (e.g., UserProfile.tsx)

Files:

  • apps/web/src/components/payment/PaymentFlow.tsx
apps/web/src/**/*.{tsx,ts,jsx,js}

📄 CodeRabbit inference engine (apps/web/.cursor/rules/frontend_rules.mdc)

apps/web/src/**/*.{tsx,ts,jsx,js}: Organize imports in order: React → third-party → local components → utils → types
Use absolute imports from @/ prefix when available
Remove unused imports
Use UPPER_SNAKE_CASE for constants
Use camelCase for functions and variables
Always use Tailwind classes for styling HTML elements; avoid using CSS or style tags
Use descriptive variable and function names; name event functions with a 'handle' prefix (e.g., handleClick, handleKeyDown)
Use const with arrow functions instead of function declarations (e.g., 'const toggle = () =>')

Files:

  • apps/web/src/components/payment/PaymentFlow.tsx
🧬 Code graph analysis (1)
apps/web/src/components/payment/PaymentFlow.tsx (2)
apps/web/src/lib/trpc.ts (1)
  • trpc (4-4)
apps/api/src/trpc.ts (1)
  • router (38-38)

@apsinghdev
Copy link
Owner

@huamanraj can you pls send a screen recording of the working flow?

Copy link
Contributor

@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: 0

🧹 Nitpick comments (2)
apps/web/src/providers/trpc-provider.tsx (1)

25-28: ensure backend actually listens on port 8080 and consider centralizing base url logic

switching the fallback to http://localhost:8080 is fine, but it will break local dev if the api server still listens on 4000; please double‑check your dev/staging configs so trpc calls don’t silently start failing when NEXT_PUBLIC_API_URL is unset. also, this base url construction now exists here and in trpc-server.ts; consider extracting a small shared helper (e.g. getApiBaseUrl()) to keep them in sync and avoid future drift.

apps/web/src/lib/trpc-server.ts (1)

9-41: port change looks consistent; verify env config and deduplicate url construction

updating both serverTrpc and createAuthenticatedClient to default to http://localhost:8080/trpc keeps them aligned with the client provider, which is good. just make sure your api server is actually bound to 8080 in all local/dev environments where NEXT_PUBLIC_API_URL is unset, otherwise server‑side callbacks will start failing. since the same url logic now lives in at least three places (client provider + these two), it’d be cleaner to centralize the base url computation in a shared util and reuse it here and in the provider to avoid subtle mismatches later.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ac6eb8 and f1d82cf.

📒 Files selected for processing (3)
  • apps/web/src/components/payment/PaymentFlow.tsx (5 hunks)
  • apps/web/src/lib/trpc-server.ts (2 hunks)
  • apps/web/src/providers/trpc-provider.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/components/payment/PaymentFlow.tsx
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx,js,jsx}: Always use lowercase when writing comments
Avoid unnecessary comments; code should be self-documenting when possible
Use comments to explain 'why', not 'what'
Remove unused imports
Use UPPER_SNAKE_CASE for constants
Use camelCase for functions and variables

Files:

  • apps/web/src/lib/trpc-server.ts
  • apps/web/src/providers/trpc-provider.tsx
apps/web/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

apps/web/src/**/*.{ts,tsx}: Always follow the design system defined in apps/web/src/lib/design-tokens.ts and apps/web/tailwind.config.ts
NEVER use hardcoded hex values (e.g., #5519f7) directly in components; ALWAYS reference colors from the design token system using Tailwind classes
Use semantic color names that describe purpose, not appearance
Use font-sans for standard UI text (Geist Sans) and font-mono for code, technical content, or monospace needs (DM Mono)
Follow Tailwind's spacing scale (0.25rem increments); for section padding use mobile p-4 (1rem) and desktop p-[60px]
Use appropriate border radius: small elements rounded-lg, medium rounded-xl, large rounded-2xl, buttons rounded-[16px]
Use animation durations: fast duration-100 (0.1s), normal duration-300 (0.3s), slow duration-600 (0.6s)

Files:

  • apps/web/src/lib/trpc-server.ts
  • apps/web/src/providers/trpc-provider.tsx
**/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{tsx,ts}: Prefer functional components with TypeScript and use proper TypeScript types, avoid any
Extract reusable logic into custom hooks
Use descriptive prop names and define prop types using TypeScript interfaces or types
Prefer controlled components over uncontrolled
Use zustand for global state (located in src/store/)
Use absolute imports from @/ prefix when available
Include proper aria labels for accessibility
Ensure keyboard navigation works
Maintain proper heading hierarchy
Provide alt text for images
Avoid unnecessary re-renders

Files:

  • apps/web/src/lib/trpc-server.ts
  • apps/web/src/providers/trpc-provider.tsx
**/*.{tsx,ts,jsx,js}

📄 CodeRabbit inference engine (.cursorrules)

Organize imports: react → third-party → local components → utils → types

Files:

  • apps/web/src/lib/trpc-server.ts
  • apps/web/src/providers/trpc-provider.tsx
**/src/{lib,utils}/**

📄 CodeRabbit inference engine (.cursorrules)

Use kebab-case or camelCase for utility file names

Files:

  • apps/web/src/lib/trpc-server.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx}: Use PascalCase for types and interfaces with descriptive names
Use dynamic imports for code splitting when appropriate
Memoize expensive computations

Files:

  • apps/web/src/lib/trpc-server.ts
  • apps/web/src/providers/trpc-provider.tsx
apps/web/src/**/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursorrules)

Optimize images using next/image

apps/web/src/**/*.{tsx,ts}: Use Zustand for global state, located in src/store/
Use PascalCase for types and interfaces with descriptive names
Use dynamic imports for code splitting when appropriate
Optimize images using next/image
Memoize expensive computations
Define a type when defining const functions

Files:

  • apps/web/src/lib/trpc-server.ts
  • apps/web/src/providers/trpc-provider.tsx
**/*.{js,jsx,ts,tsx,py,java,go,rb,php}

📄 CodeRabbit inference engine (.cursor/rules/general_rules.mdc)

**/*.{js,jsx,ts,tsx,py,java,go,rb,php}: Always use lowercase when writing comments
Avoid unnecessary comments; code should be self-documenting when possible
Use comments to explain 'why', not 'what'

Files:

  • apps/web/src/lib/trpc-server.ts
  • apps/web/src/providers/trpc-provider.tsx
apps/web/src/**/*.{tsx,ts,jsx,js}

📄 CodeRabbit inference engine (apps/web/.cursor/rules/frontend_rules.mdc)

apps/web/src/**/*.{tsx,ts,jsx,js}: Organize imports in order: React → third-party → local components → utils → types
Use absolute imports from @/ prefix when available
Remove unused imports
Use UPPER_SNAKE_CASE for constants
Use camelCase for functions and variables
Always use Tailwind classes for styling HTML elements; avoid using CSS or style tags
Use descriptive variable and function names; name event functions with a 'handle' prefix (e.g., handleClick, handleKeyDown)
Use const with arrow functions instead of function declarations (e.g., 'const toggle = () =>')

Files:

  • apps/web/src/lib/trpc-server.ts
  • apps/web/src/providers/trpc-provider.tsx
apps/web/src/{lib,utils}/**/*.{tsx,ts,jsx,js}

📄 CodeRabbit inference engine (apps/web/.cursor/rules/frontend_rules.mdc)

Name files and folders using kebab-case or camelCase for utilities

Files:

  • apps/web/src/lib/trpc-server.ts

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.

[BUG] pro users aren't varified

2 participants