Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow purchasing additional seats in workspace #169

Merged
merged 3 commits into from
Nov 7, 2024

Conversation

dinmukhamedm
Copy link
Member

@dinmukhamedm dinmukhamedm commented Nov 7, 2024

Important

Add functionality to purchase additional workspace seats, integrating Stripe for payments and updating backend and frontend components.

  • Backend:
    • Add seats_included_in_tier to WorkspaceStats in stats.rs.
    • Rename add_seats to set_seats in subscriptions.rs and update logic to set seats directly.
    • Update update_subscription in subscriptions.rs to handle subscription_id.
    • Remove unused get_user_from_stripe_customer_id route.
  • Frontend:
    • Add update-seats API route in route.ts to handle seat purchases via Stripe.
    • Implement PurchaseSeatsDialog in purchase-seats-dialog.tsx for UI interaction.
    • Update workspace-usage.tsx to include seat purchase functionality.
    • Modify email notifications in subscription-updated-email.tsx and utils.ts to include item descriptions.
  • Misc:
    • Update LOOKUP_KEY_TO_TIER_NAME in utils.ts to include additional seat pricing.
    • Adjust webhook handling in webhook/route.ts to process subscription changes.

This description was created by Ellipsis for 4d4d4b9. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 6d16274 in 1 minute and 5 seconds

More details
  • Looked at 872 lines of code in 14 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. frontend/app/webhook/route.ts:10
  • Draft comment:
    The stripe import should be corrected to import Stripe from 'stripe'; and instantiated as const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);.
  • Reason this comment was not posted:
    Marked as duplicate.
2. frontend/app/webhook/route.ts:1
  • Draft comment:
    The stripe import should be corrected to import Stripe from 'stripe'; and instantiated as const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_PNLmUXehmoCKHtJ7


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

req: NextRequest,
{ params }: { params: { workspaceId: string } }
): Promise<Response> {
if (!isCurrentUserMemberOfWorkspace(params.workspaceId)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The function isCurrentUserMemberOfWorkspace should be awaited if it returns a promise. This ensures proper authorization checks.

Suggested change
if (!isCurrentUserMemberOfWorkspace(params.workspaceId)) {
if (!(await isCurrentUserMemberOfWorkspace(params.workspaceId))) {

import { isCurrentUserMemberOfWorkspace } from '@/lib/db/utils';
import { eq } from 'drizzle-orm';
import { NextRequest } from 'next/server';
import stripe from 'stripe';
Copy link
Contributor

Choose a reason for hiding this comment

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

The stripe import should be corrected to import Stripe from 'stripe'; and instantiated as const s = new Stripe(process.env.STRIPE_SECRET_KEY!);.

Suggested change
import stripe from 'stripe';
import Stripe from 'stripe';

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 4d4d4b9 in 30 seconds

More details
  • Looked at 73 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. frontend/app/api/workspaces/[workspaceId]/update-seats/route.ts:18
  • Draft comment:
    Consider adding a check to ensure process.env.STRIPE_SECRET_KEY is defined before using it. This will prevent potential runtime errors if the environment variable is not set.
  • Reason this comment was not posted:
    Comment was on unchanged code.
2. frontend/app/checkout/page.tsx:37
  • Draft comment:
    Consider adding a check to ensure process.env.STRIPE_SECRET_KEY is defined before using it. This will prevent potential runtime errors if the environment variable is not set.
  • Reason this comment was not posted:
    Marked as duplicate.
3. frontend/app/checkout/portal/page.tsx:17
  • Draft comment:
    Consider adding a check to ensure process.env.STRIPE_SECRET_KEY is defined before using it. This will prevent potential runtime errors if the environment variable is not set.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_TnyOznOcxwyWZ4eu


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@dinmukhamedm dinmukhamedm merged commit b8b0d09 into dev Nov 7, 2024
1 check passed
@dinmukhamedm dinmukhamedm deleted the feat/additional-seats branch November 7, 2024 05:52
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