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

React & Redux group project - Space Travelers' Hub #40

Merged
merged 92 commits into from Aug 25, 2022
Merged

Conversation

for-ashraf
Copy link
Collaborator

In this PR, We have incorporated the following requirements:
Config & basic setup
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, Dragons [only if your team has 3 members]). Use 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, dragons [only if your team has 3 members]).
Redux: Fetch data and update Redux store
Upon first render fetch data from the SpaceX API endpoints:

Rockets: https://api.spacexdata.com/v3/rockets
Missions: https://api.spacexdata.com/v3/missions
Dragons: https://api.spacexdata.com/v3/dragons [only if your team has 3 members]
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
Dragons [only if your team has 3 members]:
id
name
type
flickr_images
NOTE: Make sure you only dispatch those actions once and do not add data to store on every re-render (i.e. when changing views / using navigation).

NOTE: Rockets is the default view, so you must fetch rockets data when the application starts. However, the missions data should only be fetched (once) when a user navigates to the Missions section.

Render UI:lists
Use useSelector() Redux Hook to select the state slices and render lists of rockets and missions in corresponding routes. i.e.:
// get rockets data from the store
const rockets = useSelector(state => state.rockets);
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 - i.e.:
const newState = state.map(rocket => {
if(rocket.id !== id)
return rocket;
return { ...rocket, reserved: true };
});
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) .
Dragons that have already been reserved should show a "Reserved" badge and "Cancel reservation" button instead of the default "Reserve dragon" (as per design) [only if your team has 3 members].
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).
Rockets/Dragons and Missions should use the React conditional rendering syntax:
{rocket.reserved && (
// render Cancel Rocket button
)}
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()).
Render a list of all reserved dragons (use filter()) [only if your team has 3 members]_.

diegoyon and others added 30 commits August 23, 2022 09:57
Create react app and install redux logger and router
fetched id, name and description
for-ashraf and others added 20 commits August 25, 2022 01:59
…nder

15 4pt display missions lists render
…-actions

[3pt] Implement mission joining - Actions #10
…-conditional-components

6 1pt switch badges for missions conditional components
…-my-profile-filters

[2pt] Display joined missions in My profile - Filters #2
Copy link

@MeqdamAlqudah MeqdamAlqudah left a comment

Choose a reason for hiding this comment

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

Hi @for-ashraf @diegoyon

Great work on making the changes requested by a previous reviewer 👏
You've done well implementing some of the requested changes, but there are still some which aren't addressed yet.

Highlights

👍 Readme file

Required Changes ♻️

Check the comments under the review.

Optional suggestions

Every comment with the [OPTIONAL] prefix won't stop the approval of this PR. However, I strongly recommend you to take them into account as they can make your code better. Some of them were simply missed by the previous reviewer and addressing them will really improve your application.

Cheers and Happy coding!👏👏👏

Feel free to leave any questions or comments in the PR thread if something is not 100% clear.
Please, remember to tag me in your question so I can receive the notification.

Please, do not open a new Pull Request for re-reviews. You should use the same Pull Request submitted for the first review, either valid or invalid unless it is requested otherwise.


As described in the Code reviews limits policy you have a limited number of reviews per project (check the exact number in your Dashboard). If you think that the code review was not fair, you can request a second opinion using this form.

Comment on lines +1 to +4
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import Header from './components/header';
import Profile from './pages/Profile';
import Rockets from './pages/Rockets';

Choose a reason for hiding this comment

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

  • Please add some tests to the application.

Comment on lines +5 to +7
import Missions from './pages/Missions';
import './App.css';

Choose a reason for hiding this comment

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

  • Please add Redux logger to redux and make sure it is working
    image

Comment on lines +8 to +9
function App() {
return (

Choose a reason for hiding this comment

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

  • [Optional] Please make sure to save all the data (Reserved missions, Rockest....etc) in the localStorage

Copy link

@ShoiraTa ShoiraTa left a comment

Choose a reason for hiding this comment

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

**STATUS: APPROVED 🟢 **


Hi @for-ashraf ,

Great work on making the changes requested by a previous reviewer 👏🏻

Let me point out:

  • App works as expected 👍🏻
  • Tests are passing successfully 👍🏻
  • Professional documentation

Your project is complete! . There is nothing else to say other than... it's time to merge it 🍾🚢 :shipit: . Congratulations! 🎉💯🌟

5SW

Cheers and Happy coding! 👏 👏 👏

Feel free to leave any questions or comments in the PR thread by mentioning my Github username if something is not 100% clear.


As described in the Code reviews limits policy you have limited number of reviews per this project. If you think that the code review was not fair, you can request a second opinion using this form.

@diegoyon diegoyon merged commit 0c4bafd into dev Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants