sam2if / Space_Travelers

MIT License
1 stars 0 forks source link

Implement Rocket Reservation Functionality #31

Closed leloufadel closed 1 year ago

leloufadel commented 1 year ago

This pull request introduces the functionality to fetch rocket data from the SpaceX Rockets API (https://api.spacexdata.com/v4/rockets) when the application starts, as Rockets is the default view. The fetched data includes the fields id, rocket_name, description, flickr_images, and reserved. The data is then stored in the Redux store using the rocketsSlice reducer.

Additionally, this pull request adds the ability to reserve rockets. When a user clicks the "Reserve Rocket" button, an action is dispatched to update the state. The state is not mutated directly; instead, a new state object is returned with all rockets, but the selected rocket will have an additional key reserved with its value set to true. The reducer in rocketsSlice handles the logic for setting the reservation status of rockets.

Rockets that have already been reserved will display a "Reserved" badge and a "Cancel Reservation" button, while rockets that are not reserved will show the default "Reserve Rocket" button.