-
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
Add pages and more #95
base: master
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,178 @@ | |||
export default class DoubleSlider { | |||
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.
нужно что-то сделать с форматированием кода, для JavaScript обычно принято использовать 1 таб в размере 2х пробелов
@@ -0,0 +1,66 @@ | |||
export default class NotificationMessage { | |||
static activeNotification; |
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
duration = 2000, | ||
type = 'success' | ||
} = {}) { | ||
this.string = string; |
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.
лучше назвать это поле message
this.element = wrapper.firstElementChild; | ||
} | ||
|
||
show(target = 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
this.remove(); | ||
} | ||
element; | ||
draggingElem; |
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.
нельзя в проекте смешивать отступы табуляций и пробелов!
либо то либо то!
} | ||
|
||
moveDraggingAt(clientX, clientY) { | ||
// this.draggingElem.style.left = `${clientX - this.pointerShift.x}px`; |
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.
не оставляйте закоменченый код
@@ -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
лайк за использование переменных окружения
</div>` | ||
).join(''); | ||
return data.map(item => { | ||
if (window.location.pathname === '/sales') { |
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
так делать категорически нельзя! нельзя просто так взять и обратится из компонента к window.location
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.
подумайте, может стоит передать какой-то параметр для определения что использовать div
или a
тег
|
||
const toggleSidebar = document.querySelector('.sidebar__toggler'); | ||
|
||
toggleSidebar.addEventListener('click', () => { |
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
|
||
for (const page of pages) { | ||
if (pageName.includes(page.dataset.page)) { | ||
page.parentElement.classList.add('active'); |
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
так делать нельзя! нельзя обращаться к parentElement
найдите данный эл-т с помощью селектора
export default class Page { | ||
element; | ||
components = {}; | ||
url = 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.
👍 good
} | ||
|
||
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
@@ -41,7 +43,8 @@ export default class Page { | |||
|
|||
async initComponents () { | |||
const to = new Date(); | |||
const from = new Date(to.getTime() - (30 * 24 * 60 * 60 * 1000)); | |||
const from = new Date(to.getTime() - (30 * 30 * 60 * 60 * 1000)); |
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
так делать нельзя! подумайте как взять временной диапазон в 1 месяц (в месяце бывает 30 дней, 31, 28 и даже 29)
@@ -73,45 +76,40 @@ export default class Page { | |||
value: customersData.reduce((accum, item) => accum + item), | |||
}); | |||
|
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(productId = '') { | ||
this.productId = productId; |
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
} | ||
|
||
async initComponents(productId = '') { | ||
const productData = await new ProductForm(productId); |
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
так работать не будет await new ProductForm(productId)
, так делать не стоит
не бывает асинхронных конструкторов
} | ||
|
||
renderComponents() { | ||
const topPanel = this.element.querySelector('.content__top-panel'); |
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 page = new Page(); | ||
let page; | ||
|
||
if (path === 'products/edit') { |
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
так делать не следует
передавайте 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
нужно поправить форматирование кода! отступы
Не смог разобраться с notification