NSS-Day-Cohort-53 / kennels-siennas

kennels-siennas created by GitHub Classroom
0 stars 0 forks source link

Employees Can Fire Employees #47

Closed cjgochanour closed 2 years ago

cjgochanour commented 2 years ago

Changes Made

  1. Modified file Employee.js to include removeEmployeeWithReload(). This function deletes the given employee and sets the state of emps in Employee.js with the fresh list of employees.

  2. Modified file Employee.js to include removeEmployeeWithRedirect(). This function deletes the given employee when in employee's detailed view and redirects the user back to the list of all employees.

  3. Modified file Employee.js to include a ternary statement that determines whether to run removeEmployeeWithReload() or removeEmployeeWithRedirect() depending on which view the user is observing.

  4. Modified file Employee.js to include a ternary statement that determines whether to show the fire button depending on whether the currentUser is an employee or a customer.

  5. Modified file EmployeeList.js to pass setEmps prop to <Employee> function for setting the emps array after database change. ​

    Steps to Review

  6. Checkout this branch locally.

    git fetch --all
    git checkout cg-empFireEmp
  7. Open a new Terminal tab (⌘T or Ctrl+Shift+T) and navigate to the server directory. Host the file locally with npm start and use json-server to host your version of the API.

  8. Test app functionality.

    Navigate to employee list using the nav bar or adding "/employees" to the URL. If the authenticated user is a customer, the fire button should not appear on any employee in the list view or in the employee's detailed view. If the authenticated user is an employee, the fire button will appear in both the employee list and employee's detailed view. Solves issue #4 . The authenticated employee will be able to click the fire button to remove an employee from the users database. Solves issue #23 When firing an employee from list view, the employee will immediately be removed from the list. Solves issue #32 and solves issue #10 . When firing an employee from detailed view, the user will be redirected to the employee list.

  9. View code file.

    Confirm file modifications are present as indicated above. Confirm no unused code or extraneous comments exist.

JacobF94 commented 2 years ago

Tested functionality, it works on both the list page and the individual employee page. It all checks out for me!

siprachanh commented 2 years ago

Your modified features in file work as designed. Wherein when employee fire button is clicked, employee card is removed and page is reloaded with new updated employee list.

Nice work!!!