-
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 v1.0 #87
base: master
Are you sure you want to change the base?
Conversation
chartHeight = 50; | ||
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.chartHeight = 50; | ||
|
||
this.range = range; | ||
this.url = new URL(url, 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
src/components/column-chart/index.js
Outdated
elementLink.href = this.link; | ||
elementLink.classList.add('column-chart__link'); | ||
elementLink.textContent = 'View all'; | ||
this.element.querySelector('.column-chart__title').append(elementLink); |
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.
было бы неплохо получить ссылку на этот эл-т заранее и не искать его в этом методе
@@ -0,0 +1,198 @@ | |||
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
src/components/notification/index.js
Outdated
this.render(); | ||
} | ||
|
||
static currentElement; |
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.
лучше располагать данное св-во до констурктора
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 = element.firstElementChild; | ||
} | ||
|
||
show(element = 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
@@ -2,9 +2,10 @@ import SortableList from '../sortable-list/index.js'; | |||
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
|
||
fileInput.onchange = async () => { | ||
const [file] = fileInput.files; | ||
elementInputFile.onchange = async () => { |
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.
здесь не критично, так как мы уверены что будет только один обработчик события, но на практике лучше всегда использовать метод addEventListener
template() { | ||
return ` | ||
<div class="product-form"> | ||
this.urlCategory = new URL('api/rest/categories', 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.
может следует вынести данную логику инициализации url в отдельный метод с целью разгрузить конструктор?
} | ||
async loadData() { | ||
const resultCategoryPromise = fetchJson(this.urlCategory); | ||
const resultProductPromise = this.isNewProduct |
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
? parseInt(productForm[field].value) | ||
: productForm[field].value; | ||
} | ||
const [resultCategory, resultProduct] = await Promise.all([resultCategoryPromise, resultProductPromise]); |
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
лайк за параллельную загрузку независимых данных
if (this.categories) { | ||
for (const category of this.categories) { | ||
for (const subCategory of category.subcategories) { | ||
let newOption = new Option(`${category.title} > ${subCategory.title}`, subCategory.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
лайк за использование new Option
const element = productForm.querySelector(`#${item}`); | ||
wrapper.innerHTML = ` | ||
<li class="products-edit__imagelist-item sortable-list__item" style=""> | ||
<input type="hidden" name="url" value="${escapeHtml(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 👍
лайк за использование escapeHTML
|
||
async loadCategoriesList() { | ||
return await fetchJson(`${process.env.BACKEND_URL}api/rest/categories?_sort=weight&_refs=subcategory`); | ||
const sortableListImages = new SortableList({ items }); |
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 👍
@@ -1,50 +1,48 @@ | |||
export default class SortableList { |
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 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 👍
this.step = step; | ||
this.start = start; | ||
this.end = end; | ||
this.url = new URL(url, 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 👍
sortLocally(id, order) { | ||
const sortedData = this.sortData(id, order); | ||
initEventListener() { | ||
window.addEventListener('scroll', async (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.
good 👍
if (this.params.id) this.url.searchParams.set('_sort', this.params.id); | ||
if (this.params.order) this.url.searchParams.set('_order', this.params.order); | ||
|
||
await fetchJson(this.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.
не смешивайте await
с then
this.renderData(); | ||
this.isLoading = false; | ||
}) | ||
.catch(error => console.error('Something went wrong: ' + 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.
здесь обработку ошибки следует делать через try...catch
|
||
await fetchJson(this.url) | ||
.then(data => { | ||
this.data = this.data.concat(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.
this.data = [...this.data, ...data];
} | ||
|
||
destroy() { | ||
this.remove(); | ||
this.element = null; | ||
document.removeEventListener('pointerover', this.onMouseOver); |
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 = {}; | ||
categories; | ||
|
||
constructor() { |
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 👍
src/pages/categories/index.js
Outdated
} | ||
|
||
onSortableListReordered = async (event) => { | ||
console.log('got it', event.target); |
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.notificationCategoryOrderedSaved(); | ||
} catch (error) { | ||
console.error('something went wrong', 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.
👍 good
destroy () { | ||
destroy() { | ||
this.remove(); | ||
this.element = null; | ||
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 👍
лайк за destroy компонент
destroy() { | ||
this.remove(); | ||
this.element = null; | ||
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 👍
const rangePicker = new RangePicker(this.range); | ||
|
||
this.sales = { | ||
url: `api/rest/orders?createdAt_gte=${rangePicker.selected.from.toISOString()}&createdAt_lte=${rangePicker.selected.to.toISOString()}`, |
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 URL
No description provided.