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

🪟 🎉 Free connector program enrollment modal #21396

Merged
merged 15 commits into from
Jan 17, 2023

Conversation

josephkmh
Copy link
Contributor

@josephkmh josephkmh commented Jan 13, 2023

What

Closes #21224

Adds components for the enrollment modal for the free connector program:

image

Figma designs: https://www.figma.com/file/wihAJg5mkp61I7lLHs0IpV/FREE-CONNECTOR-PROGRAM?node-id=1106%3A23359&t=sv3jVkm9Yn7QlwMU-0

How

  • Adds FreeConnectorProgramEnrollmentButton, which contains all the logic required to render the modal.
  • Adjusts the createCheckout() method in our StripeService to accept the new "setup" mode
  • Does not yet display this button anywhere

The idea is that this button can be used in various other components where an "Enroll now!" CTA is required.

Recommended reading order

Top to bottom

Considerations

FreeConnectorProgramEnrollmentButton is a very long name 😄 Maybe we should use a FCP* prefix for these components? Long names don't bother me too much, so I don't feel super strongly.

@octavia-squidington-iv octavia-squidington-iv added the area/frontend Related to the Airbyte webapp label Jan 13, 2023
}

const EnrollmentModalContent: React.FC<EnrollmentModalContentProps> = ({ closeModal, createCheckout, workspaceId }) => {
const [isLoading, setIsLoading] = useState(false);
Copy link
Contributor Author

@josephkmh josephkmh Jan 13, 2023

Choose a reason for hiding this comment

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

We have to manage the loading state manually here. Although createCheckout() is a react-query mutation, and returns an isLoading property, we can't use it. The way our ModalService works, it's content slot doesn't receive prop updates. We also cannot use useStripeCheckout() here, because it's rendered in ModalServiceProvider, which is outside of the ServiceProvider context.

Comment on lines 32 to 46
const startStripeCheckout = async () => {
setIsLoading(true);
// Use the current URL as a success URL but attach the STRIPE_SUCCESS_QUERY to it
const successUrl = new URL(window.location.href);
successUrl.searchParams.set(STRIPE_SUCCESS_QUERY, "true");
const { stripeUrl } = await createCheckout({
workspaceId,
successUrl: successUrl.href,
cancelUrl: window.location.href,
stripeMode: "setup",
});

// Forward to stripe as soon as we created a checkout session successfully
window.location.assign(stripeUrl);
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Largely copied from our credit purchasing flow here.

After successfully entering a card, users will be redirected back to the URL they came from with an extra query param: ?stripeCheckoutSuccess=true

Comment on lines 54 to 55
<div className={styles.pill}>Pill #1</div>
<div className={styles.pill}>Pill #2</div>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This depends on #21228

@@ -3,6 +3,7 @@ export interface StripeCheckoutSessionCreate {
successUrl: string;
cancelUrl: string;
quantity?: number;
stripeMode: "payment" | "setup";
Copy link
Contributor Author

@josephkmh josephkmh Jan 13, 2023

Choose a reason for hiding this comment

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

This is a new required param for createCheckout

@josephkmh josephkmh marked this pull request as ready for review January 13, 2023 15:49
Copy link
Contributor

@teallarson teallarson left a comment

Choose a reason for hiding this comment

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

  • have not tried it locally yet
  • The only comment that I feel pretty strongly about is the one in the button component... we may want to utilize the ModalService like our other modals do, though you said you have something with a hook that may work.

Copy link
Contributor

@ambirdsall ambirdsall left a comment

Choose a reason for hiding this comment

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

Two fairly trivial edits I'd like to see before merging, but overall looks good.

Copy link
Contributor

@ambirdsall ambirdsall left a comment

Choose a reason for hiding this comment

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

Approving now: this PR is pretty safe (it adds no user-facing changes, no apparent correctness issues, and all requested edits are small), and so I'd rather not hold up Joey's next work morning waiting for North American time zones to catch up.

@josephkmh josephkmh requested a review from teallarson January 16, 2023 12:00
Copy link
Contributor

@teallarson teallarson left a comment

Choose a reason for hiding this comment

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

It looks like the .svg images still have the .tsx counterparts as well. Other than that, looks good to me!

@josephkmh
Copy link
Contributor Author

Oh weird, I was certain I had deleted them locally... should be gone now 🙂

@josephkmh josephkmh enabled auto-merge (squash) January 17, 2023 14:57
@josephkmh josephkmh merged commit b58a951 into master Jan 17, 2023
@josephkmh josephkmh deleted the joey/free-connectors-program-enrollment-modal branch January 17, 2023 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Related to the Airbyte webapp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Free connectors] create enrollment modal
4 participants