Skip to content

Book Shop#2

Open
birbwatcher wants to merge 55 commits intomainfrom
work
Open

Book Shop#2
birbwatcher wants to merge 55 commits intomainfrom
work

Conversation

@birbwatcher
Copy link
Owner

  1. Task:
    https://github.com/rolling-scopes-school/js-fe-course-en/blob/main/tasks/books-shop/books-shop.md

image
3. Deploy: https://birbwatcher.github.io/Book-Shop/
4. Done 13.09.2022
5. Score: 100 / 100

  • The content of catalog page created thru the JavaScript is implemented
  • After user clicks on Show more button the popup with description and close button are shown is implemented
  • The HTML elements should be added to page by one step (it's a hint to read about document fragment) is implemented
  • When the user adds the book to the bag (either by click on Add to bag button or by drag-and-drop), the book appears in the bag with shorten data (title, author, price) and remove (cross) button. Also, the total sum is updated. Is implemented
  • When user click on Confirm order he appears in the Order form page. Is implemented
  • The order form contains fields with own validation rules and Complete button. Is implemented
  • The Complete button is disabled until the user full form with valid information. Is implemented
  • If user left the field empty or full of invalid data, this field became red (means red border) and the validation message (The field is invalid) is appeared. After user fix data and left the field again, the validation red border and message should disappear. Is implemented
  • After user full all mandatory field with valid information, the Complete button become active. Is implemented
  • After user click on Complete button, he will see the summarized information: for instance, The order created. The delivery address is Amazing street house 3 flat 10. Customer John Gald. Is implemented

@github-pages github-pages bot temporarily deployed to github-pages September 13, 2022 20:13 Inactive
@github-pages github-pages bot temporarily deployed to github-pages September 13, 2022 20:45 Inactive
@github-pages github-pages bot temporarily deployed to github-pages September 13, 2022 20:57 Inactive
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Book Shop</title>
<link rel="stylesheet" href="./dist/style.css">
<link rel="stylesheet" href="./dist/normalize.css">
Copy link

Choose a reason for hiding this comment

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

I'm pretty sure "normalize.css" should come first (before style.css)

async function getBooks() {
let result = await fetch("./books.json");
let array = await result.json();
books = await array;
Copy link

Choose a reason for hiding this comment

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

redundant "await"

async function shopInit() {
createHeader();
createMain();
await getBooks();
Copy link

Choose a reason for hiding this comment

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

await expects a Promise, I don't see you return Promise from 'getBooks' function

import ddInit from "./scripts/dragndrop.js";

async function getBooks() {
let result = await fetch("./books.json");
Copy link

Choose a reason for hiding this comment

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

const here and below

createFooter();
createPopUp();
loadedPage.append(wrapper);
loadedPage.append(createFooter());
Copy link

Choose a reason for hiding this comment

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

do you need to execute "createFooter()" function twice?

label.innerHTML = labelName;
input.type = "radio";
input.name = "Payment";
if (checked) {
Copy link

Choose a reason for hiding this comment

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

Suggested change
if (checked) {
input.checked = checked

fastView.innerHTML = "Fast View";
card.append(fastView);

fastView.onclick = function () {
Copy link

Choose a reason for hiding this comment

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

I would recommend you to use event delegation

let fieldFlatNumber = document.getElementById('flat-number');
let fieldDeliveryDate = document.getElementById('delivery-date');

fieldFlatNumber.onblur = function() {
Copy link

Choose a reason for hiding this comment

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

the best practice is to use addEventListener instead of inline handlers

import createElement from "./createElement.js";
import {cart} from "./cart.js";

export default function checkForms() {
Copy link

Choose a reason for hiding this comment

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

the function looks to long, it's better to split it by logical pieces to improve readability

let fieldFlatNumber = document.getElementById('flat-number');
let fieldDeliveryDate = document.getElementById('delivery-date');

fieldFlatNumber.onblur = function() {
Copy link

Choose a reason for hiding this comment

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

I would recommend you to use "focusout" event + event delegation. It will help you to avoid boilerplate
https://learn.javascript.ru/focus-blur#sobytiya-focusin-focusout

@Xelsoid
Copy link

Xelsoid commented Sep 14, 2022

Things to improve:

  1. function and variable naming
  2. let/const
  3. do not use "long" functions, split code into small logic chunks
  4. improve code readability by splitting operations into variables
  5. use event delegation
  6. use modern features like arrow function and forEach

@Xelsoid
Copy link

Xelsoid commented Sep 14, 2022

image
missed "for" attributes

@github-pages github-pages bot temporarily deployed to github-pages September 15, 2022 10:57 Inactive
@github-pages github-pages bot temporarily deployed to github-pages September 15, 2022 11:34 Inactive
@github-pages github-pages bot temporarily deployed to github-pages September 15, 2022 11:35 Inactive
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.

2 participants