In this task, we worked with the real live data from the SpaceX API. Our task was to build a web application for a company that provides commercial and scientific space travel services. The application allows users to book rockets,dragons and join selected space missions.
Create routes and view components: rockets, missions, my profile.
Use <NavLink /> for the page navigation links and style active class to indicate which section/page user is currently on (underline active navigation link).
Create directories for all Redux state slice files:rockets, missions.
Upon first render fetch data from the SpaceX API endpoints:
Rockets: https://api.spacexdata.com/v4/rockets
Missions: https://api.spacexdata.com/v3/missions
Once the data are fetched, dispatch an action to store the selected data in Redux store:
Rockets:
id
rocket_name
description
flickr_images
Missions:
mission_id
mission_name
description
Render UI:lists
Use useSelector() Redux Hook to select the state slices and render lists of rockets and missions in corresponding routes. i.e.:
You can style the whole application "by hand" or you could use React Bootstrap, a UI library that could speed up the process. This is a popular library and working with its components would be good practice.
Render a list of rockets (as per design). For the image of a rocket use the first image in the array of flickr_images.
Render a table with the missions' data (as per design).
Render a list of dragons (as per design). For the image of a dragon use the first image in the array of flickr_images_[only if your team has 3 members].
Redux: Write actions and reducers for booking rockets/dragons and joining missions
When a user clicks the "Reserve rocket" button or "Reserve dragon" button [only if your team has 3 members], action needs to be dispatched to update the store. You need to get the ID of the reserved rocket and update the state. Remember you mustn't mutate the state. Instead, you need to return a new state object with all rockets, but the selected rocket will have an extra key reserved with its value set to true. You could use a JS filter() or map() to set the value of the new state.
Regardless of which method you choose, make sure you place all your logic in the reducer. In the React view file, you should only dispatch the action with the correct rocket ID as an argument.
Create a reducer and action dispatcher for the "Join Mission" button. The logic here is practically the same as with rockets - you need to pass the mission's ID to the corresponding action and update the missions' state with the selected mission having a new key/value - reserved: true.
Redux: Write actions and reducers for canceling rockets/dragons and leaving missions
Here you need to follow the same logic as with the "Reserve rocket"/"Reserve dragon" and "Join mission" - but you need to set the reserved key to false.
Dispatch these actions upon click on the corresponding buttons.
Render UI: conditional components rendering
Rockets that have already been reserved should show a "Reserved" badge and "Cancel reservation" button instead of the default "Reserve rocket" (as per design) .
Missions that the user has joined already should show a badge "Active Member" instead of the default "NOT A MEMBER" and a button "Leave Mission" instead of the "Join Mission" button (as per design).
Render UI: My Profile section
Compose two/three column layout and list ONLY the rockets/dragons reserved and missions joined by the user (as per design):
Render a list of all joined missions (use filter()).
Render a list of all reserved rockets (use filter()).
We are a team of 2 participants working on this project @Nuga0909 and @Uzair-Manzoor.
This pull request has been created against the implementations that has been made into the project as per below mentioned requirements:
Create React App.
Install React Redux, Redux Logger and React Router.
Download the free image for the app logo.
Create routes and view components:
rockets
,missions
,my profile
.<NavLink />
for the page navigation links and style active class to indicate which section/page user is currently on (underline active navigation link).Create directories for all Redux state slice files:
rockets
,missions
.Upon first render fetch data from the SpaceX API endpoints:
https://api.spacexdata.com/v4/rockets
https://api.spacexdata.com/v3/missions
Once the data are fetched, dispatch an action to store the selected data in Redux store:
Render UI:lists
useSelector()
Redux Hook to select the state slices and render lists of rockets and missions in corresponding routes. i.e.:flickr_images
.flickr_images
_[only if your team has 3 members].Redux: Write actions and reducers for booking rockets/dragons and joining missions
reserved
with its value set totrue
. You could use a JSfilter()
ormap()
to set the value of the new state.reserved: true
.Redux: Write actions and reducers for canceling rockets/dragons and leaving missions
reserved
key tofalse
.Render UI: conditional components rendering
Render UI: My Profile section
filter()
).filter()
).