Skip to content

Conversation

pwnage101
Copy link
Member

@pwnage101 pwnage101 commented Oct 2, 2025

@Copilot Copilot AI review requested due to automatic review settings October 2, 2025 01:07
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a stateful button component for the PlanDetails page and integrates checkout intent creation functionality. The changes enable the form to create a CheckoutIntent via API call when submitted by authenticated users, while maintaining existing logistration flows for unauthenticated users.

  • Adds a new PlanDetailsSubmitButton component that uses StatefulButton with different states (inactive, default, pending, complete, errored)
  • Integrates checkout intent creation API service and mutation hook for authenticated users
  • Updates the PlanDetailsPage to use the new button and handle checkout intent creation workflow

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
PlanDetailsSubmitButton.tsx New stateful button component with visual feedback for different submission states
PlanDetailsPage.tsx Updated to use new button component and integrate checkout intent creation logic
checkout-intent.ts New service for creating checkout intents via API
useCreateCheckoutIntentMutation.tsx New mutation hook for checkout intent creation
hooks/index.ts Export new mutation hook and another existing hook

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 63 to 64
inactive: buttonMessage!,
default: buttonMessage!,
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

Using non-null assertion operator (!) is risky here. The buttonMessage from useCurrentPageDetails() could potentially be undefined, which would cause runtime errors. Consider adding a fallback value or proper null checking.

Copilot uses AI. Check for mistakes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@pwnage101 I would follow up with this AI comment

};

const onSubmit = (data: PlanDetailsData) => onSubmitCallbacks[currentPage!](data);
const onSubmit = (data: any) => onSubmitCallbacks[currentPage!](data);
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

Using any type removes type safety. The original type PlanDetailsData should be maintained, or a union type should be used to handle the different form data types (PlanDetailsData | PlanDetailsLoginPageData | PlanDetailsRegisterPageData).

Suggested change
const onSubmit = (data: any) => onSubmitCallbacks[currentPage!](data);
const onSubmit = (data: PlanDetailsData | PlanDetailsLoginPageData | PlanDetailsRegisterPageData) => onSubmitCallbacks[currentPage!](data);

Copilot uses AI. Check for mistakes.

Comment on lines +66 to +69
// @ts-ignore(TS2339)
transformResponse: axios.defaults.transformResponse!.concat(camelCaseResponse),
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

Using @ts-ignore suppresses TypeScript errors and should be avoided. Consider properly typing the transformResponse property or using a type assertion with proper typing instead.

Suggested change
// @ts-ignore(TS2339)
transformResponse: axios.defaults.transformResponse!.concat(camelCaseResponse),
transformResponse: axios.defaults.transformResponse!.concat(camelCaseResponse) as import('axios').AxiosRequestConfig['transformResponse'],

Copilot uses AI. Check for mistakes.

@pwnage101 pwnage101 marked this pull request as draft October 2, 2025 01:08
Copy link
Collaborator

@brobro10000 brobro10000 left a comment

Choose a reason for hiding this comment

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

Great job so far! Please address minor feedback.

}
}, [formIsValid, submissionIsPending, submissionIsSuccess, submissionIsError]);

const allButtonMessages: Record<ButtonState, MessageDescriptor> = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] This extra constant may not be necessary. The consuming StatefulButton can reference the defineMessages object directly or buttonMessage from useCurrentPageDetails

Comment on lines +82 to +75
inactive: undefined,
default: undefined,
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] These can be removed.

Comment on lines 63 to 64
inactive: buttonMessage!,
default: buttonMessage!,
Copy link
Collaborator

Choose a reason for hiding this comment

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

@pwnage101 I would follow up with this AI comment

}

// If we already have an intent or the mutation succeeded earlier, just proceed.
if (existingCheckoutIntent || createCheckoutIntentMutation.isSuccess) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] is the check for createCheckoutIntentMutation.isSuccess necessary for redirect if the onSuccess logic redirects to the account details?

Copy link
Collaborator

@brobro10000 brobro10000 left a comment

Choose a reason for hiding this comment

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

Approved to unblock

@pwnage101 pwnage101 force-pushed the pwnage101/ENT-10756 branch 2 times, most recently from 459e177 to b69daca Compare October 6, 2025 22:23
@pwnage101 pwnage101 marked this pull request as ready for review October 6, 2025 22:26
@Copilot Copilot AI review requested due to automatic review settings October 6, 2025 22:26
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@pwnage101 pwnage101 force-pushed the pwnage101/ENT-10756 branch 2 times, most recently from 1b4b5d4 to 0ba7f5e Compare October 7, 2025 04:52
@Copilot Copilot AI review requested due to automatic review settings October 7, 2025 04:52
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@pwnage101 pwnage101 force-pushed the pwnage101/ENT-10756 branch 2 times, most recently from 86e14e1 to eda0085 Compare October 7, 2025 16:39
@Copilot Copilot AI review requested due to automatic review settings October 7, 2025 16:39
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@pwnage101 pwnage101 force-pushed the pwnage101/ENT-10756 branch from eda0085 to 5bd6fe0 Compare October 7, 2025 16:40
@pwnage101 pwnage101 enabled auto-merge (squash) October 7, 2025 16:41
@pwnage101 pwnage101 merged commit 925d081 into main Oct 7, 2025
5 checks passed
@pwnage101 pwnage101 deleted the pwnage101/ENT-10756 branch October 7, 2025 16:42
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.

2 participants