Skip to content
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 #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Final project #91

wants to merge 1 commit into from

Conversation

sta88
Copy link

@sta88 sta88 commented Dec 27, 2022

Часть функционала еще не доделана. Не прикручена форма добавления/редактирования товара.

@@ -0,0 +1,96 @@
import SortableList from '../../components/sortable-list/index.js';

export default class Category {
Copy link
Contributor

Choose a reason for hiding this comment

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

good 👍
лайк за выделение данного функционала в отдельный компонент


initComponents() {
const sortableList = new SortableList({
items: this.category.subcategories.map(item => {
Copy link
Contributor

Choose a reason for hiding this comment

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

может вынести данную логику в отдельный метод?
чтобы не загромождать инициализацию SortableList?

components;

constructor(category = {}) {
this.category = category;
Copy link
Contributor

Choose a reason for hiding this comment

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

category or categories?
категоря одна или их много?

this.remove();
this.element = null;

for (const component of Object.values(this.components)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 good
лайк за дестрой внутренних компонент

data;

constructor({url = '', range = {from: new Date(), to: new Date()}, label = '', link = '', formatHeading = (str => `${str}`)} = {}) {
this.url = new URL(url, vars.BACKEND_URL);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 good

@@ -1,89 +1,107 @@
import fetchJson from '../../utils/fetch-json.js';
import vars from '../../utils/vars.js';
Copy link
Contributor

Choose a reason for hiding this comment

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

очень странное имя vars
может лучше назвать данный файл "config.js"?

}

getTemplate() {
const linkA = this.link ? `<a href=${this.link} class="column-chart__link">View all</a>` : '';
Copy link
Contributor

Choose a reason for hiding this comment

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

что такое linkA?
почему А?

return date.toLocaleString('ru', {dateStyle: 'short'})
months = [
'январь',
'февраль',
Copy link
Contributor

Choose a reason for hiding this comment

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

подумайте как сгенерировать данный список динамично


static formatDate(date) {
const year = date.getFullYear();
const month = (date.getMonth() + 1) < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

что такое 10

{url = '', isSortLocally = false,
sorted = {id: headerConfig.find(item => item.sortable).id, order: 'asc'}} = {}) {
this.headerConfig = headerConfig;
this.url = new URL(url, vars.BACKEND_URL);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 good

</span>`
: '';
getRows() {
const bodyRows = Array.from(this.subElements.body.querySelectorAll('.sortable-table__row'));
Copy link
Contributor

Choose a reason for hiding this comment

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

почему используется Array.from a не spread syntax?

destroy() {
this.remove();
this.subElements = {};
document.addEventListener('scroll', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

good 👍

this.element.classList.add('sortable-table_empty');
}
destroy() {
this.remove();
Copy link
Contributor

Choose a reason for hiding this comment

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

а где удаление обработчика скрола?

destroy() {
this.remove();
this.subElements = {};
document.addEventListener('scroll', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

а где удаление обработчика скрола?


}

initEventListeners() {
Copy link
Contributor

Choose a reason for hiding this comment

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

почему пустой метод?

this.element = null;

for (const component of Object.values(this.components)) {
component.destroy();
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 good


this.element = element.firstElementChild;
const promiseCategory = fetchJson(this.urlCategory);
const promiseProduct = id ? fetchJson(this.urlProduct) : Promise.resolve(this.defaultData);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 good


this.dispatchEvent(result.id);
} catch (error) {
console.error('error', error);
Copy link
Contributor

Choose a reason for hiding this comment

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

можно также показать нотификейшен в случае ошибки

fileInput.click();
};

onSubmit = event => {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 good

import SortableTable from '../../../components/sortable-table/index.js';
import DoubleSlider from "../../../components/double-slider/index.js"

const header = [
Copy link
Contributor

Choose a reason for hiding this comment

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

может стоит вынести конфиг хедера в отдельный файл?

isSortLocally: false,
sorted: {id: 'title', order: 'asc'}
});
// const productId = '101-planset-lenovo-yt3-x90l-64-gb-3g-lte-cernyj';
Copy link
Contributor

Choose a reason for hiding this comment

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

не оставляйте закомментированный код

sortable: true,
sortType: 'date',
template: date => {
const data = new Date(Date.parse(date));
Copy link
Contributor

Choose a reason for hiding this comment

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

шаблон должен содержать логику отображения, а не бизнес-логику

@@ -0,0 +1,13 @@
const vars = {
BACKEND_URL: 'https://course-js.javascript.ru',
Copy link
Contributor

Choose a reason for hiding this comment

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

часть из этих значений следует взять из переменных окружения,
они доступны через process.env

Copy link
Contributor

@dosandk dosandk left a comment

Choose a reason for hiding this comment

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

посмотрите пожалуйста комментарии

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