Skip to content

fix: contact update mutation (#265) #271

Closed
lakshaymeghlan wants to merge 1 commit intousesend:mainfrom
lakshaymeghlan:bug-fix--270
Closed

fix: contact update mutation (#265) #271
lakshaymeghlan wants to merge 1 commit intousesend:mainfrom
lakshaymeghlan:bug-fix--270

Conversation

@lakshaymeghlan
Copy link
Copy Markdown

@lakshaymeghlan lakshaymeghlan commented Oct 7, 2025

fix #265

Next.js (apps/web) doesn’t see the root .env. Put the same vars into apps/web/.env.local

If this fixes it, problem solved. (Keep .env.local out of git — it’s for local secrets.)


Summary by cubic

Fixes the contact update mutation by ensuring Next.js loads required environment variables from apps/web/.env.local. This unblocks local development and prevents missing secret errors.

  • Migration
    • Copy needed env vars from the root .env to apps/web/.env.local.
    • Ensure .env.local stays out of git.

@vercel
Copy link
Copy Markdown

vercel bot commented Oct 7, 2025

@lakshayMeghlan123 is attempting to deploy a commit to the kmkoushik's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 7, 2025

Walkthrough

Added a new exported React component, PlanDetails, in apps/web/src/components/payments/PlanDetails.tsx. It queries subscription details via api.billing.getSubscriptionDetails.useQuery and reads currentTeam from useTeam. If loading or no currentTeam, it returns null. It derives planKey from currentTeam.plan, maps it to PERKS via PLAN_PERKS, and defaults to an empty list if missing. It renders the current plan name (active planKey lowercase, otherwise “free”). If cancelAtPeriodEnd is set, it displays a secondary badge with the formatted “MMM dd” cancellation date. It lists plan perks with a CheckCircle2 icon.

Suggested labels

hacktoberfest-accepted

Suggested reviewers

  • KMKoushik

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The pull request title indicates a fix for the contact update mutation but the changeset actually adds a new PlanDetails component unrelated to contact mutation logic, so the title does not correctly reflect the main change in the code. Update the title to accurately summarize the addition of the PlanDetails component or adjust the changeset to implement the contact update mutation fix referenced in the title.
Linked Issues Check ⚠️ Warning The linked issue #265 requires extracting contactBookId from the update input so only valid fields reach Prisma’s update method, but the diff shows no changes to contact mutation logic and instead introduces a subscription plan component, so the PR does not meet the issue’s requirements. Implement the contact update mutation fix by destructuring out contactBookId and sending only permitted fields to Prisma, or separate the PlanDetails component into its own PR.
Out of Scope Changes Check ⚠️ Warning The PR introduces a completely new PlanDetails component in the payments UI, which is unrelated to the objectives of fixing the contact update mutation outlined in the linked issue, indicating out-of-scope changes. Move the PlanDetails component additions into a dedicated feature branch or PR and limit this PR to the changes required for the contact update mutation fix.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ 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
Copy Markdown
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

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/components/payments/PlanDetails.tsx (1)

1-47: CRITICAL: PR objectives do not match the actual code changes.

The PR title and objectives claim to fix a "contact update mutation" issue related to contactBookId Prisma errors and environment variable duplication. However, this file introduces an entirely new PlanDetails component for displaying subscription plans, which has no relation to contacts, mutations, or environment variables.

This is a severe mismatch that suggests:

  1. The wrong files were committed to this PR, or
  2. The PR description/objectives are incorrect

Please verify that:

  • The correct files are included in this PR
  • The PR description accurately reflects the changes
  • If this is a separate feature, it should be in its own PR with appropriate objectives
🧹 Nitpick comments (5)
apps/web/src/components/payments/PlanDetails.tsx (5)

1-1: Remove unused import.

The Plan type is imported but never used in this component.

-import { Plan } from "@prisma/client";

5-5: Remove unused import.

The Spinner component is imported but never used. If you intend to show a loading spinner during subscriptionQuery.isLoading, consider using it; otherwise, remove this import.

-import Spinner from "@usesend/ui/src/spinner";

15-17: Consider showing a loading indicator.

Returning null during loading provides no visual feedback to users. Since you've imported Spinner, consider displaying it during the loading state for better UX.

  if (subscriptionQuery.isLoading || !currentTeam) {
-   return null;
+   return (
+     <div className="flex items-center justify-center p-4">
+       <Spinner />
+     </div>
+   );
  }

12-17: Add error handling for subscription query.

The component doesn't handle the error state of subscriptionQuery. If the query fails, users see nothing without any indication of what went wrong.

  const subscriptionQuery = api.billing.getSubscriptionDetails.useQuery();
  const { currentTeam } = useTeam();

- if (subscriptionQuery.isLoading || !currentTeam) {
+ if (subscriptionQuery.isLoading) {
+   return (
+     <div className="flex items-center justify-center p-4">
+       <Spinner />
+     </div>
+   );
+ }
+
+ if (subscriptionQuery.isError) {
+   return (
+     <div className="text-destructive text-sm">
+       Failed to load subscription details
+     </div>
+   );
+ }
+
+ if (!currentTeam) {
    return null;
  }

38-43: Consider using perk content as key.

Using array index as the key works for static lists, but using the perk text itself would be more robust and follows React best practices.

-       {perks.map((perk, index) => (
-         <li key={index} className="flex items-center gap-2">
+       {perks.map((perk) => (
+         <li key={perk} className="flex items-center gap-2">
            <CheckCircle2 className="h-4 w-4 text-green flex-shrink-0" />
            <span className="text-sm">{perk}</span>
          </li>
        ))}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1216b80 and da1622e.

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

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

Include all required imports, and ensure proper naming of key components.

Files:

  • apps/web/src/components/payments/PlanDetails.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • apps/web/src/components/payments/PlanDetails.tsx
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • apps/web/src/components/payments/PlanDetails.tsx
**/*.tsx

📄 CodeRabbit inference engine (AGENTS.md)

Name React component files in PascalCase (e.g., AppSideBar.tsx)

Files:

  • apps/web/src/components/payments/PlanDetails.tsx
apps/web/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

apps/web/**/*.{ts,tsx}: In apps/web, use the "/" alias for src imports (e.g., import { x } from "/utils/x")
Prefer using tRPC for API calls unless explicitly instructed otherwise

Files:

  • apps/web/src/components/payments/PlanDetails.tsx
🔇 Additional comments (3)
apps/web/src/components/payments/PlanDetails.tsx (3)

40-40: No changes needed – text-green is valid
The shared Tailwind config extends green with a DEFAULT value, which generates the text-green utility.


19-20: Verify Prisma Plan enum matches PLAN_PERKS keys
The as keyof typeof PLAN_PERKS assertion bypasses TS checks—confirm that the Prisma Plan enum only includes the keys defined in PLAN_PERKS (FREE, BASIC). If you introduce new plans, update PLAN_PERKS or add a runtime guard/log for unexpected values.


33-33: cancelAtPeriodEnd is already a Date—no conversion needed.
Prisma returns it as a JS Date and tRPC’s superjson preserves it, so you can pass it directly to format().

Likely an incorrect or invalid review comment.

Copy link
Copy Markdown
Contributor

@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 1 file

@KMKoushik KMKoushik closed this Oct 10, 2025
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