CheckoutButton Component.
Acts as the context for the State pattern, changing its UI based on CheckoutStatus.
Manages the pseudo-asynchronous delay and handles clearing the cart upon success.
Internal Behavior (handleCheckout):
Handles the state transitions for the checkout process.
Simulates an async network request: IDLE -> LOADING -> SUCCESS -> IDLE.
Resolves when the fake checkout delay is complete.
Description
CheckoutButton Component. Acts as the context for the State pattern, changing its UI based on
CheckoutStatus. Manages the pseudo-asynchronous delay and handles clearing the cart upon success.handleCheckout): Handles the state transitions for the checkout process. Simulates an async network request:IDLE->LOADING->SUCCESS->IDLE. Resolves when the fake checkout delay is complete.