Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THIS IS FOR REACT The first of our two major view components is the Sales Component. For this component to function properly, it needs to

THIS IS FOR REACT

The first of our two major "view" components is the "Sales" Component. For this component to function properly, it needs to adhere to the following specification:

  • We must add the following "import" statement: import { withRouter } from 'react-router-dom' (this will help to give us access to a "history" object on this.props so that we can programmatically change routes).

  • We must change our "export" statement to: export default withRouter(Sales);

  • Next, we must add the following components from "react-bootstrap": { Table, Pagination }

  • The "state" of this component must be initialized with the following values:

o sales: [] o currentPage:1

A utility method called getData(page) must be implemented according to the following specification:

o This function must return a promise that only resolves once the following ajax request is complete

o Makes an AJAX request to your "sales" API (From Assignment 1 on Heroku) route: /api/sales using the value of "page" as the "page" query parameter and "10" as the value of the "perPage" query parameter

The "componentDidMount()" method must be implemented to: o Call our "getData(page)" method (defined above) with the value of "currentPage" (in the state) and when it

is complete, update the sales value in the state with the data, causing the component to render. A "previousPage()" method must be implemented such that:

o Its "this" value is correctly bound in the constructor of the "Sales" class

o Any operations done in this method must only be completed if currentPage in the state is greater than 1

o If the above is the case, invoke the "getData()" method with the value of (currentPage in the state - 1)

o Once the data returns, update the sales value in the state with the data as well as the currentPage value in the state with the value of currentPage - 1, causing the component to render.

A "NextPage()" method must be implemented such that:

o Its "this" value is correctly bound in the constructor of the "Sales" class

o invoke the "getData()" method with the value of (currentPage in the state + 1)

o Once the data returns, update the sales value in the state with the data as well as the currentPage value in the state with the value of currentPage + 1, causing the component to render.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 12c SQL

Authors: Joan Casteel

3rd edition

1305251032, 978-1305251038

More Books

Students also viewed these Databases questions