-
Notifications
You must be signed in to change notification settings - Fork 0
JRMP2-1 Show product card #5
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
base: main
Are you sure you want to change the base?
Conversation
…received items from a backend endpoint done. Co-authored-by: Dmytro Khyzhniak <exORYON@users.noreply.github.com>
…Changed files from .js to .ts. Minor improvements in many places.
…-2_Add_product_list. Added check for next page. Minor improvements.
… and "Close" inside.
…essing "Close" button.
…ding of the image in the modal window.
…ixing second half of comments.
…mmand. Use 'npm run lint' to lint your code.
…iew, controller, interface
| const defaultPort:number = parseInt(process.env.PORT || ''); | ||
| const port:number = defaultPort || 5500; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const port:number = process.env.PORT || 5500;
| maxPage: number; | ||
| itemsPerPage: number; | ||
|
|
||
| constructor() { | ||
| this.itemsPerPage = 5; | ||
| this.maxPage = 0; | ||
| this.setMaxPage(); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not controller responsibility
| result: [], | ||
| }; | ||
|
|
||
| let list: object[] = (await this.getAllItems()).result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
object - bad type for interface. need right type
| return response; | ||
| } | ||
|
|
||
| async getItems(req: string):Promise<ResponseObj> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(req: string) - it's not full request
| }; | ||
|
|
||
| let list: object[] = (await this.getAllItems()).result; | ||
| const page: number = parseInt(req); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as a option -> + req
| if (this.pageIsNotValid(page)) { | ||
| return false; | ||
| } else { | ||
| return true; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as an option
return !this.pageIsNotValid(page);
| view.showSpinner(); | ||
| model.currentList = await model.getDataFromBE(model.currentPage); | ||
|
|
||
| if (model.currentList.length === 0 || model.currentList.length > model.itemsPerPage) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( !model.currentList.length || model.currentList.length > model.itemsPerPage) {
| } | ||
| } | ||
| nextPage(): void { | ||
| if (model.currentList.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model.currentList.length
| if (list.length === 0) { | ||
| throw new Error('Error. Stock is empty'); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we have length === 0), it's not error
| "@typescript-eslint/parser": "4.22.1", | ||
| "eslint": "7.2.0", | ||
| "eslint-plugin-import": "2.22.1", | ||
| "eslint-plugin-node": "^11.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to fix
We can see the product detail page
When you click on a product in the list of products, a modal window opens with detailed information about the product.
complete information includes:
"add product to cart" - while locked
"close" - closes the model window