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

Checkout and Stripe setup #11

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Checkout and Stripe setup #11

wants to merge 9 commits into from

Conversation

Zaid-maker
Copy link
Owner

@Zaid-maker Zaid-maker commented Jul 26, 2024

Summary by Sourcery

This pull request adds a new checkout feature for event ticket purchases, integrating Stripe for payment processing. It introduces two new components: Checkout and CheckoutButton, which handle the checkout process and user authentication status, respectively. Additionally, the README.md file has been updated with a command for setting up an ngrok tunnel.

  • New Features:
    • Introduced a new Checkout component to handle event ticket purchases, integrating with Stripe for payment processing.
    • Added a CheckoutButton component that conditionally renders a sign-in link or the Checkout component based on user authentication status.
  • Documentation:
    • Updated README.md to include a command for setting up an ngrok tunnel for local development.

Copy link

semanticdiff-com bot commented Jul 26, 2024

Review changes with SemanticDiff.

Analyzed 3 of 4 files.

Filename Status
README.md Unsupported file format
✔️ components/shared/Checkout.tsx Analyzed
✔️ components/shared/CheckoutButton.tsx Analyzed
✔️ app/(root)/events/[id]/page.tsx Analyzed

Copy link

trunk-io bot commented Jul 26, 2024

⏱️ 6m total CI duration on this PR

Job Cumulative Duration Recent Runs
build-only 6m 🟩🟩🟩🟩🟩 (+1 more)

settingsfeedbackdocs ⋅ learn more about trunk.io

Copy link

vercel bot commented Jul 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
evently ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 2, 2024 3:07pm

Copy link

sourcery-ai bot commented Jul 26, 2024

Reviewer's Guide by Sourcery

This pull request introduces a new CheckoutButton component and integrates it into the EventDetails page to facilitate the checkout process. The CheckoutButton component handles user authentication states and uses the newly created Checkout component to process orders. Additionally, a command for setting up an ngrok tunnel was added to the README.md file.

File-Level Changes

Files Changes
components/shared/Checkout.tsx
components/shared/CheckoutButton.tsx
Introduced new components for handling the checkout process, including user authentication and order processing.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

@sourcery-ai sourcery-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.

Hey @Zaid-maker - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The PR title mentions 'Checkout and Stripe setup', but the current changes don't include any Stripe integration. Consider either updating the PR title to reflect the current scope or including the Stripe setup in this PR.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

Comment on lines 3 to 4
const CheckoutButton = () => {
return <div>CheckoutButton</div>;
Copy link

Choose a reason for hiding this comment

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

suggestion: Enhance CheckoutButton component with button structure and styling

Consider adding basic button structure and styling to make it look and function like an actual checkout button.

Suggested change
const CheckoutButton = () => {
return <div>CheckoutButton</div>;
const CheckoutButton = () => {
return <button style={{ padding: "10px 20px", backgroundColor: "#4CAF50", color: "white", border: "none", borderRadius: "5px", cursor: "pointer" }}>Checkout</button>;
};

import React from "react";

const CheckoutButton = () => {
return <div>CheckoutButton</div>;
Copy link

Choose a reason for hiding this comment

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

suggestion: Use semantic button element instead of div

For better accessibility and semantics, use a element instead of a

for the CheckoutButton component.

Suggested change
return <div>CheckoutButton</div>;
return <button>CheckoutButton</button>;

@Zaid-maker
Copy link
Owner Author

@sourcery-ai review

Copy link

@sourcery-ai sourcery-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.

Hey @Zaid-maker - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider moving the ngrok command from the README to a separate development guide or documentation file, as it's specific to local development and may not be relevant to all users of the project.
Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟡 Documentation: 1 issue found

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

}
}, []);

const onCheckout = async () => {
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider adding error handling to the onCheckout function

Asynchronous operations, especially in checkout processes, should have proper error handling. Consider wrapping the checkoutOrder call in a try-catch block to handle potential errors gracefully.

const Checkout = ({ event, userId }: { event: IEvent; userId: string }) => {
useEffect(() => {
const query = new URLSearchParams(window.location.search);
if (query.get("success")) {
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider using a more robust method for order confirmation

Using console.log for order confirmation and cancellation may not be ideal in a production environment. Consider implementing a more user-friendly way of communicating the order status, such as displaying a message in the UI.

Suggested change
if (query.get("success")) {
if (query.get("success")) {
alert("Order placed! You will receive an email confirmation.");


const CheckoutButton = ({ event }: { event: IEvent }) => {
const { user } = useUser();
const userId = user?.publicMetadata.userId as string;
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider adding a comment explaining the use of publicMetadata

While using publicMetadata to get the userId is likely intentional, it might be helpful to add a brief comment explaining why this approach is used, for the benefit of other developers who might work on this code in the future.

Suggested change
const userId = user?.publicMetadata.userId as string;
// Using publicMetadata to retrieve userId for specific business logic
const userId = user?.publicMetadata.userId as string;

@@ -1,3 +1,5 @@
# <img src="public/assets/images/logo.svg" alt="logo" />

Build an event organization web app like Eventbrite or Meetup with authentication, event management, search, filtering, categories, checkout, and payments using Next JS 14, Tailwind CSS, Shadcn, React Hook Form, Zod, Uploadthing, React-Datepicker, Mongoose, Clerk, and Stripe.

`ngrok tunnel --label edge=edghts_2jQbAk4QzC90ArEGm4eYkVIhI1v http://localhost:3000`
Copy link

Choose a reason for hiding this comment

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

question (documentation): Check if the ngrok label is sensitive.

Please verify if the label edge=edghts_2jQbAk4QzC90ArEGm4eYkVIhI1v is sensitive information. If it is, consider removing it or replacing it with a placeholder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant