imperfectandcompany / Imperfect-Gamers-Site-Store

Our robust community site integrating Steam for enhanced user interactions and data management, powered by Remix with Tailwind CSS for optimistic, responsive UI. Features CI/CD with GitHub Actions and Docker for seamless deployment and maintenance.
https://store.imperfectgamers.org/
Other
0 stars 0 forks source link

Resolve and Enhance Checkout Process, Session Management, and Logging #74

Closed cheesea3 closed 1 month ago

cheesea3 commented 1 month ago

This pull request addresses the issues outlined in the original GitHub issue, including unauthorized errors during the checkout process, and enhances various components to improve the overall user experience.

Original Issue Summary:

Users were experiencing interruptions in the checkout process, particularly getting stuck at "loading or creating your basket..." with unauthorized errors when the system attempted to create a basket or add packages to the basket. The system sometimes incorrectly indicated that a package had already been added, leading to a failure in advancing the checkout process.

Key Changes:

  1. AuthorizeForm Component:

    • Refactored to include revalidation using useRevalidator from Remix.
    • Added event listeners to handle successful Steam authentication.
    • Managed popup state and fallback URL for better user experience.
  2. CheckoutProcess Component:

    • Ensured single execution of the checkout flow using useRef to track if the checkout process has already been initiated, preventing multiple calls.
    • Added setTimeout to delay the execution of handleStoreInteractions, ensuring the state is fully updated.
    • Implemented state and ref cleanup to reset conditions when necessary.
    • Enhanced logging for better debugging and tracking of the flow.
  3. BasketManager Functionality:

    • Consolidated the logic for basket creation and package addition.
    • Ensured proper error handling and return of expected values from asynchronous functions.
  4. Modal Management and State Control:

    • Enhanced modal management and state control in ModalWrapper and related components.
    • Improved user experience by providing clear feedback during the checkout process.
  5. TSdoc Comments and Logging:

    • Added TSdoc comments for better documentation.
    • Streamlined console logs with sequential numbering and categorization.
    • Applied best practices for consistent formatting, proper hook usage, and state management.
  6. Package ID Update:

    • Changed the package ID being used to 6288193 as the original package was deleted during the investigation.
  7. Session and Cookie Management:

    • Modified storage.server.ts to change the cookie path from /store to / to reflect the new routing structure:
      export const storeCookie = createTypedCookie({
      cookie: createCookie('user-store', {
       path: '/',
       secrets: ['n3wsecr3t', 'olds3cret'],
       sameSite: 'strict',
       httpOnly: true,
       secure: process.env.NODE_ENV === 'production',
      }),
      schema: storeCookieSchema,
      });

Impact:

Testing:

These improvements address the critical issues impacting user experience and revenue streams, providing a more robust and user-friendly checkout process.