-
Notifications
You must be signed in to change notification settings - Fork 217
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
Final project #81
base: master
Are you sure you want to change the base?
Final project #81
Conversation
@@ -1,74 +1,113 @@ | |||
import fetchJson from '../../utils/fetch-json.js'; | |||
|
|||
const BACKEND_URL = process.env.BACKEND_URL; |
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.
good 👍 лайк за использование переменных окружения
this.label = label; | ||
this.link = link; | ||
this.value = value; | ||
this.formatHeading = formatHeading; |
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.
👍 good
@@ -0,0 +1,123 @@ | |||
export default class DoubleSlider { |
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.
👍 good лайк за DubleSlider
} | ||
|
||
get leftPercents() { | ||
return (((this.selected.from - this.min) / this.width) * 100).toFixed(1); |
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.
good 👍
} | ||
|
||
get rightPercents() { | ||
return (((this.max - this.selected.to) / this.width) * 100).toFixed(1); |
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.
good 👍
to.textContent = this.formatValue(this.selected.to); | ||
} | ||
|
||
unsubscribe() { |
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.
good 👍
this.updateView(); | ||
}; | ||
|
||
destroy() { |
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.
good 👍
@@ -0,0 +1,50 @@ | |||
export default class NotificationMessage { | |||
static NotificationObj; |
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.
с маленькой буквы должно быть имя
this.element = wrapper.firstElementChild; | ||
} | ||
|
||
show(targetElement = document.body) { |
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.
👍 good
import escapeHtml from '../../utils/escape-html.js'; | ||
import fetchJson from '../../utils/fetch-json.js'; | ||
|
||
const IMGUR_CLIENT_ID = process.env.IMGUR_CLIENT_ID; |
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.
👍 good лайк за использование переменных окружения
} | ||
const escTitle = escapeHtml(catTitle.join(' > ')); | ||
catTitle.pop(); | ||
return `<option value="${value.id}">${escTitle}</option>`; |
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.
обратите внимание на использование конструктора new Option
catTitle.push(value.title); | ||
if (value.subcategories) { | ||
const subCatOptionsText = this.getCategoryOptionsTemplate(value.subcategories, catTitle); | ||
catTitle.pop(); |
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.
очень аккуратно с методом pop
можете смутировать catTitle
и нанести вред другим частям программы
}, | ||
body: JSON.stringify(product) | ||
this.subElements.productForm.addEventListener('submit', this.submitForm); | ||
this.subElements.productForm.elements['uploadImage'].addEventListener('click', event => { |
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.
а почему обращение через квадратные скобки?
this.getImgItemText(newImgItem) | ||
); | ||
} catch (error) { | ||
new NotificationMessage(`${error}`, { |
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.
лучше использовать error.message
createImagesList() { | ||
const {imageListContainer} = this.subElements; | ||
const {images} = this.formData; | ||
fillFormData(data) { |
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.
задайте значение по умолчанию, это упростит проверку
remove() { | ||
this.element.remove(); | ||
async render() { | ||
let categories, data; |
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.
🔴 please don't do this
пожалуйста, на каждую переменную свое ключевое слово
let categories, data; | ||
if (this.productId) { | ||
this.urlProd.searchParams.set('id', this.productId); | ||
[categories, data] = await Promise.all([fetchJson(this.urlCat), fetchJson(this.urlProd)]); |
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.
👍 good
itemElem.remove(); | ||
getIndexOfList(node) { | ||
let index = 0; | ||
for (const iterator of node.parentElement.children) { |
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.
пожалуйста не привязывайтесь к children
@@ -1,14 +1,14 @@ | |||
import fetchJson from "../../utils/fetch-json.js"; | |||
|
|||
const BACKEND_URL = 'https://course-js.javascript.ru'; | |||
const BACKEND_URL = process.env.BACKEND_URL; |
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.
good 👍
|
||
sortListChange = event => { | ||
|
||
const subcategoryList = [...event.target.children]; |
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.
не привязывайтесь к children
лучше сделайте явный поиск по какому-то селектору
this.subElements.categoriesContainer.append(this.getCategoryElement(item)); | ||
}); | ||
} catch (error) { | ||
|
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.
а как же обработка ошибки?
throw
тогда в некуда отработает
|
||
return this.element; | ||
destroy() { | ||
for (const component of Object.values(this.components)) { |
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.
👍 good
subElements = {}; | ||
usedComponents = {}; | ||
|
||
get template() { |
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.
👍 good
range: {createdAt_gte: createdAt_gte, createdAt_lte: createdAt_lte} | ||
}); | ||
|
||
this.subElements['rangePickerContainer'].append(this.usedComponents.rangePicker.element); |
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.
почему обращение через квадратные скобки, а не через точку?
@@ -4,7 +4,7 @@ export default async function(path, match) { | |||
main.classList.add('is-loading'); | |||
|
|||
const { default: Page } = await import(/* webpackChunkName: "[request]" */`../pages/${path}/index.js`); | |||
const page = new Page(); | |||
const page = new Page(match); |
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.
👍 good
components = {}; | ||
|
||
constructor([,match] = []) { | ||
this.productId = match; |
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.
good 👍
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.
good 👍
неплохая работа, посмотрите пожалуйста комменты
No description provided.