mirror of
https://github.com/sergeyyarkov/digital-store.git
synced 2026-10-11 10:19:15 +03:00
admin templates refactor
This commit is contained in:
parent
1ad0e1c2e3
commit
20954ef318
2
dist/public/js/admin.js
vendored
2
dist/public/js/admin.js
vendored
File diff suppressed because one or more lines are too long
@ -1,7 +1,3 @@
|
||||
export function renderBuyers(buyers) {
|
||||
let html = '';
|
||||
buyers.forEach(buyer => {
|
||||
html += `<tr data-info='{"bill_id": "${buyer.bill_id}", "email": "${buyer.email}", "method": "${buyer.method[0].toUpperCase() + buyer.method.slice(1)}", "date": "${new Date(buyer.date).toLocaleDateString()}", "amount": "${buyer.amount}", "data": "${buyer.data}"}'><td>${buyer.email}</td><td>${buyer.method[0].toUpperCase() + buyer.method.slice(1)}</td><td>${new Date(buyer.date).toLocaleDateString()}</td><td>${buyer.amount} ₽</td><td><button id="billDataOpen" class="btn orange">Данные аккаунтов</button></td></tr>`;
|
||||
});
|
||||
return html;
|
||||
return buyers.map(buyer => `<tr data-info='{"bill_id": "${buyer.bill_id}", "email": "${buyer.email}", "method": "${buyer.method[0].toUpperCase() + buyer.method.slice(1)}", "date": "${new Date(buyer.date).toLocaleDateString()}", "amount": "${buyer.amount}", "data": "${buyer.data}"}'><td>${buyer.email}</td><td>${buyer.method[0].toUpperCase() + buyer.method.slice(1)}</td><td>${new Date(buyer.date).toLocaleDateString()}</td><td>${buyer.amount} ₽</td><td><button id="billDataOpen" class="btn orange">Данные аккаунтов</button></td></tr>`).join('');
|
||||
}
|
||||
@ -1,7 +1,3 @@
|
||||
export function renderCategories(categories) {
|
||||
let html = '';
|
||||
categories.forEach(category => {
|
||||
html += `<option value='{"id": "${category._id}", "title": "${category.title}", "img": "${category.img}", "type": "${category.type}", "format": "${category.format}"}' data-icon="../img/service-icons/${category.img}">${category.title[0].toUpperCase() + category.title.slice(1)}</option>`;
|
||||
});
|
||||
return html;
|
||||
return categories.map(category => `<option value='{"id": "${category._id}", "title": "${category.title}", "img": "${category.img}", "type": "${category.type}", "format": "${category.format}"}' data-icon="../img/service-icons/${category.img}">${category.title[0].toUpperCase() + category.title.slice(1)}</option>`).join('');
|
||||
}
|
||||
@ -1,7 +1,3 @@
|
||||
export function renderIcons(icons) {
|
||||
let html = '';
|
||||
icons.forEach(icon => {
|
||||
html += `<option value='${icon}' data-icon="../img/service-icons/${icon}">${icon}</option>`;
|
||||
});
|
||||
return html;
|
||||
return icons.map(icon => `<option value='${icon}' data-icon="../img/service-icons/${icon}">${icon}</option>`).join('');
|
||||
}
|
||||
@ -1,13 +1,13 @@
|
||||
export function renderItems(items, categories, info) {
|
||||
let html = '';
|
||||
|
||||
if (!items.error) {
|
||||
categories.forEach(category => {
|
||||
items.forEach((item, i) => {
|
||||
if (item.category.toLowerCase() === category.title.toLowerCase()) html += `<tr data-info='{"id": "${item._id}", "title": "${item.title}", "category": "${item.category}", "price": "${item.price}", "description": "${item.description}", "data": "${info[i].data}"}'><td><img src="../img/service-icons/${category.img}" alt="alt"></td><td>${item.title}</td><td>${item.category[0].toUpperCase() + item.category.slice(1)}</td><td>${new Date(item.date).toLocaleDateString()}</td><td>${item.count}</td><td>${item.price} ₽</td><td><button id="deleteItem" class="btn red">Удалить</button><button id="editItem" class="btn orange">Изменить</button></td></tr>`
|
||||
});
|
||||
});
|
||||
} else html += 'Данных нету.';
|
||||
|
||||
return html;
|
||||
return categories.map(category => {
|
||||
return items.map((item, i) => {
|
||||
if (item.category.toLowerCase() === category.title.toLowerCase()) {
|
||||
return `<tr data-info='{"id": "${item._id}", "title": "${item.title}", "category": "${item.category}", "price": "${item.price}", "description": "${item.description}", "data": "${info[i].data}"}'><td><img src="../img/service-icons/${category.img}" alt="alt"></td><td>${item.title}</td><td>${item.category[0].toUpperCase() + item.category.slice(1)}</td><td>${new Date(item.date).toLocaleDateString()}</td><td>${item.count}</td><td>${item.price} ₽</td><td><button id="deleteItem" class="btn red">Удалить</button><button id="editItem" class="btn orange">Изменить</button></td></tr>`;
|
||||
}
|
||||
}).join('');
|
||||
}).join('');
|
||||
} else {
|
||||
return 'Данных нету.';
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user