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

Capstone Frontend - Add course #4

Merged
merged 5 commits into from
Jun 17, 2022
Merged

Capstone Frontend - Add course #4

merged 5 commits into from
Jun 17, 2022

Conversation

BenjaminSemah
Copy link
Owner

What does this PR do?

This PR is raised for the addCourse page

Capture

Description of tasks completed

  • Add page for add course form
  • Implement addCourse method using redux toolkit (Thunk)
  • Implement add-course route to addCourse form page
  • Fix all linter errors.

How should it be tested

Clone the repository

git clone https://github.com/BenjaminSemah/capstone-front-end.git

Navigate to the folder

cd capstone-front-end

Checkout the branch

git checkout add-course

Thanks for reviewing my PR 😊

Copy link
Collaborator

@omarsalem7 omarsalem7 left a comment

Choose a reason for hiding this comment

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

Hi @BenjaminSemah 😊,

Good job so far! 👏
You have done well reaching this point of the milestone, but there are some issues that you still need to work on to go to the next milestone but you are almost there!

you-are-near

Highlights

  • Descriptive pull request ✔️
  • No linter errors ✔️
  • Add course work in a good way ✔️

Required Changes ♻️

Check the comments under the review.

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.

Comment on lines 1 to 32
import React, { useState } from 'react';
import { useDispatch } from 'react-redux';
import { addCourse } from '../redux/coursesSlice';

export default function AddCourseForm() {
const dispatch = useDispatch();

const [courseData, setCourseData] = useState(
{
name: '',
description: '',
location: '',
size: '',
price: '',
image: '',
},
);

const handleFormChange = (event) => {
setCourseData((prevData) => {
const { name, value } = event.target;
return {
...prevData,
[name]: value,
};
});
};

const handleFormSubmit = (event) => {
event.preventDefault();
dispatch(addCourse(courseData));
};
Copy link
Collaborator

@omarsalem7 omarsalem7 Jun 16, 2022

Choose a reason for hiding this comment

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

  • It will be better to navigate to home page after add course to could be see the added course.
  • It will be done like this by using useNavigate hook
    Inside AddCourseForm.js file
import { useNavigate } from 'react-router-dom';
export default function AddCourseForm() {
  const dispatch = useDispatch();
  const navigate = useNavigate();
  const [courseData, setCourseData] = useState({
    name: '',
    description: '',
    location: '',
    size: '',
    price: '',
    image: '',
  });

  const handleFormSubmit = (event) => {
    event.preventDefault();
    dispatch(addCourse(courseData));
    navigate('/');
  };

Copy link
Owner Author

Choose a reason for hiding this comment

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

RESOLVED

  • Navigation has been included in the handleFormSubmit function.
  • App now navigates to homepage after new course has been created.

Comment on lines 1 to 3
body {
background-color: #97bf0f;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • Please remove style from background and add style for your page because this affect in other pages style.
    For example, it affect in home page style and it should be the same style as behance design.
    image

Copy link
Owner Author

Choose a reason for hiding this comment

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

RESOLVED

  • Background color has been removed from body.
  • Background color now applies to only the add-course page.

Copy link
Collaborator

@omarsalem7 omarsalem7 left a comment

Choose a reason for hiding this comment

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

Hi @BenjaminSemah 😊,

STATUS: APPROVED! 🥇 💯

giphy

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

Highlights

✅ No linter errors.
✅ Descriptive pull request
✅ Project has met all the technical aspects you needed for this project. Keep rocking!

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.

Code Review by @omarsalem7

@BenjaminSemah BenjaminSemah merged commit ec4a18c into development Jun 17, 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

2 participants