mirror of
https://github.com/sergeyyarkov/digital-store.git
synced 2026-10-11 18:29:11 +03:00
renameing
This commit is contained in:
parent
ec8ed92e0f
commit
5d8a8bcf46
20
dist/public/js/bundle.js
vendored
20
dist/public/js/bundle.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
|||||||
import { Component } from "../core/component";
|
import { Component } from "../core/component";
|
||||||
import { apiService } from "../services/api.service";
|
import { apiService } from "../services/api.service";
|
||||||
import { renderItemsRefactor } from "../templates/itemsRefactor.template";
|
import { renderItems } from "../templates/items.template";
|
||||||
|
|
||||||
export class CategoryComponent extends Component {
|
export class CategoryComponent extends Component {
|
||||||
constructor(id, {items}, {filter}) {
|
constructor(id, {items}, {filter}) {
|
||||||
@ -27,8 +27,8 @@ export class CategoryComponent extends Component {
|
|||||||
|
|
||||||
async function showItems(category) {
|
async function showItems(category) {
|
||||||
const targetCategory = await apiService.getCategory(category);
|
const targetCategory = await apiService.getCategory(category);
|
||||||
const fData = await apiService.getItemsOneRefactor(category),
|
const fData = await apiService.getItemsOne(category),
|
||||||
html = renderItemsRefactor(targetCategory, fData);
|
html = renderItems(targetCategory, fData);
|
||||||
|
|
||||||
this.items.onHide();
|
this.items.onHide();
|
||||||
this.items.insertItems(html);
|
this.items.insertItems(html);
|
||||||
@ -44,8 +44,8 @@ async function buttonHandler(e) {
|
|||||||
btnActiveLink(e);
|
btnActiveLink(e);
|
||||||
|
|
||||||
const category = await apiService.getCategory(e.target.dataset.category),
|
const category = await apiService.getCategory(e.target.dataset.category),
|
||||||
fData = await apiService.getItemsOneRefactor(e.target.dataset.category),
|
fData = await apiService.getItemsOne(e.target.dataset.category),
|
||||||
html = renderItemsRefactor(category, fData);
|
html = renderItems(category, fData);
|
||||||
|
|
||||||
this.items.onHide();
|
this.items.onHide();
|
||||||
this.items.insertItems(html);
|
this.items.insertItems(html);
|
||||||
@ -56,9 +56,9 @@ async function buttonHandler(e) {
|
|||||||
this.items.onShow();
|
this.items.onShow();
|
||||||
btnActiveLink(e);
|
btnActiveLink(e);
|
||||||
|
|
||||||
const fData = await apiService.getItemsRefactor();
|
const fData = await apiService.getItems();
|
||||||
const categories = await apiService.getCategories();
|
const categories = await apiService.getCategories();
|
||||||
const html = renderItemsRefactor(categories, fData);
|
const html = renderItems(categories, fData);
|
||||||
|
|
||||||
this.items.onHide();
|
this.items.onHide();
|
||||||
this.items.insertItems(html);
|
this.items.insertItems(html);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { Component } from "../core/component";
|
import { Component } from "../core/component";
|
||||||
import { apiService } from "../services/api.service";
|
import { apiService } from "../services/api.service";
|
||||||
import { renderItemsRefactor } from "../templates/itemsRefactor.template";
|
import { renderItems } from "../templates/items.template";
|
||||||
|
|
||||||
export class FilterComponent extends Component {
|
export class FilterComponent extends Component {
|
||||||
constructor(id, {items}) {
|
constructor(id, {items}) {
|
||||||
@ -29,9 +29,9 @@ async function sortByAllHandler(e) {
|
|||||||
const sorting = e.target.id;
|
const sorting = e.target.id;
|
||||||
|
|
||||||
this.items.onShow();
|
this.items.onShow();
|
||||||
const fData = await apiService.getItemsRefactor(sorting);
|
const fData = await apiService.getItems(sorting);
|
||||||
const categories = await apiService.getCategories();
|
const categories = await apiService.getCategories();
|
||||||
const html = renderItemsRefactor(categories, fData);
|
const html = renderItems(categories, fData);
|
||||||
|
|
||||||
this.items.onHide();
|
this.items.onHide();
|
||||||
this.items.insertItems(html);
|
this.items.insertItems(html);
|
||||||
@ -46,8 +46,8 @@ async function sortByOneHandler(e) {
|
|||||||
this.items.onShow();
|
this.items.onShow();
|
||||||
|
|
||||||
const category = await apiService.getCategory(localStorage.getItem('currentCategory')),
|
const category = await apiService.getCategory(localStorage.getItem('currentCategory')),
|
||||||
fData = await apiService.getItemsOneRefactor(localStorage.getItem('currentCategory'), sorting),
|
fData = await apiService.getItemsOne(localStorage.getItem('currentCategory'), sorting),
|
||||||
html = renderItemsRefactor(category, fData);
|
html = renderItems(category, fData);
|
||||||
|
|
||||||
this.items.onHide();
|
this.items.onHide();
|
||||||
this.items.insertItems(html);
|
this.items.insertItems(html);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Component } from "../core/component";
|
import { Component } from "../core/component";
|
||||||
import { apiService } from "../services/api.service";
|
import { apiService } from "../services/api.service";
|
||||||
import { insertCount } from "../other/counter";
|
import { insertCount } from "../other/counter";
|
||||||
import { renderItemsRefactor } from "../templates/itemsRefactor.template";
|
import { renderItems } from "../templates/items.template";
|
||||||
|
|
||||||
export class ItemsComponent extends Component {
|
export class ItemsComponent extends Component {
|
||||||
constructor(id, {loader}) {
|
constructor(id, {loader}) {
|
||||||
@ -20,9 +20,9 @@ export class ItemsComponent extends Component {
|
|||||||
localStorage.setItem('sortByAll', 'true'); // установка значения для компонента Filter
|
localStorage.setItem('sortByAll', 'true'); // установка значения для компонента Filter
|
||||||
this.$el.addEventListener('click', addItem.bind(this));
|
this.$el.addEventListener('click', addItem.bind(this));
|
||||||
if (!localStorage.getItem('category')) { // Получаем все товары и выводим их если нету ключа category в ls
|
if (!localStorage.getItem('category')) { // Получаем все товары и выводим их если нету ключа category в ls
|
||||||
const fData = await apiService.getItemsRefactor();
|
const fData = await apiService.getItems();
|
||||||
const categories = await apiService.getCategories();
|
const categories = await apiService.getCategories();
|
||||||
const html = renderItemsRefactor(categories, fData);
|
const html = renderItems(categories, fData);
|
||||||
this.insertItems(html);
|
this.insertItems(html);
|
||||||
this.btnColor();
|
this.btnColor();
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getItemsRefactor(sorting) {
|
async getItems(sorting) {
|
||||||
try {
|
try {
|
||||||
if (sorting) {
|
if (sorting) {
|
||||||
const request = `${this.url}api?token=${API_TOKEN}&items=all&sorting=${sorting}`;
|
const request = `${this.url}api?token=${API_TOKEN}&items=all&sorting=${sorting}`;
|
||||||
@ -39,7 +39,7 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getItemsOneRefactor(category, sorting) {
|
async getItemsOne(category, sorting) {
|
||||||
try {
|
try {
|
||||||
if (sorting) {
|
if (sorting) {
|
||||||
const request = `${this.url}api?token=${API_TOKEN}&items=all&category=${encodeURIComponent(category.toLowerCase())}&sorting=${sorting}`;
|
const request = `${this.url}api?token=${API_TOKEN}&items=all&category=${encodeURIComponent(category.toLowerCase())}&sorting=${sorting}`;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
export function renderItemsRefactor(categories, items) {
|
export function renderItems(categories, items) {
|
||||||
const arrayCategories = categories;
|
const arrayCategories = categories;
|
||||||
const arrayItems = items;
|
const arrayItems = items;
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user