Update app.py
Browse files
app.py
CHANGED
|
@@ -26,10 +26,6 @@ REPO_ID = "Kgshop/esmiratkani"
|
|
| 26 |
HF_TOKEN_WRITE = os.getenv("HF_TOKEN")
|
| 27 |
HF_TOKEN_READ = os.getenv("HF_TOKEN_READ")
|
| 28 |
|
| 29 |
-
STORE_ADDRESSES = [
|
| 30 |
-
"Город Алматы , Алатау 1 , блок 4 , бутик 112",
|
| 31 |
-
]
|
| 32 |
-
|
| 33 |
|
| 34 |
CURRENCY_CODE = 'KZT'
|
| 35 |
CURRENCY_NAME = 'Казахстанский тенге'
|
|
@@ -54,8 +50,8 @@ STATUS_MAPS = {
|
|
| 54 |
|
| 55 |
translations = {
|
| 56 |
'ru': {
|
| 57 |
-
'page_title': "
|
| 58 |
-
'header_title': "
|
| 59 |
'our_addresses': "Наши адреса в г. Алматы",
|
| 60 |
'search_placeholder': "Поиск по названию или описанию...",
|
| 61 |
'all_filter': "Все",
|
|
@@ -68,7 +64,6 @@ translations = {
|
|
| 68 |
'variant_label': "Вариант:",
|
| 69 |
'size_label': "Размер:",
|
| 70 |
'quantity_label': "Количество:",
|
| 71 |
-
'quantity_label_meter': "Количество (метры):",
|
| 72 |
'confirm_add_to_cart': "Добавить в корзину",
|
| 73 |
'your_cart': "Ваша корзина",
|
| 74 |
'cart_is_empty': "Ваша корзина пуста.",
|
|
@@ -100,18 +95,16 @@ translations = {
|
|
| 100 |
'return_to_catalog': "Вернуться в каталог",
|
| 101 |
'order_not_found_error': "Ошибка",
|
| 102 |
'order_not_found_message': "Заказ с таким ID не найден.",
|
| 103 |
-
'whatsapp_confirm_message_1': "Здравствуйте! Хочу подтвердить свой заказ в
|
| 104 |
'whatsapp_confirm_message_2': "Номер заказа:",
|
| 105 |
'whatsapp_confirm_message_3': "Ссылка на заказ:",
|
| 106 |
'whatsapp_confirm_message_4': "Пожалуйста, свяжитесь со мной для уточнения деталей.",
|
| 107 |
'product_type': "Тип товара",
|
| 108 |
-
'tkaniny': "Ткани",
|
| 109 |
'odezhda': "Одежда",
|
| 110 |
-
'price_per_meter': "Цена за метр",
|
| 111 |
},
|
| 112 |
'kz': {
|
| 113 |
-
'page_title': "
|
| 114 |
-
'header_title': "
|
| 115 |
'our_addresses': "Алматы қаласындағы мекенжайларымыз",
|
| 116 |
'search_placeholder': "Аты немесе сипаттамасы бойынша іздеу...",
|
| 117 |
'all_filter': "Барлығы",
|
|
@@ -124,7 +117,6 @@ translations = {
|
|
| 124 |
'variant_label': "Нұсқа:",
|
| 125 |
'size_label': "Өлшем:",
|
| 126 |
'quantity_label': "Саны:",
|
| 127 |
-
'quantity_label_meter': "Саны (метр):",
|
| 128 |
'confirm_add_to_cart': "Себетке қосу",
|
| 129 |
'your_cart': "Сіздің себетіңіз",
|
| 130 |
'cart_is_empty': "Сіздің себетіңіз бос.",
|
|
@@ -156,14 +148,12 @@ translations = {
|
|
| 156 |
'return_to_catalog': "Каталогқа оралу",
|
| 157 |
'order_not_found_error': "Қате",
|
| 158 |
'order_not_found_message': "Мұндай ID-мен тапсырыс табылмады.",
|
| 159 |
-
'whatsapp_confirm_message_1': "Сәлеметсіз бе!
|
| 160 |
'whatsapp_confirm_message_2': "Тапсырыс нөмірі:",
|
| 161 |
'whatsapp_confirm_message_3': "Тапсырысқа сілтеме:",
|
| 162 |
'whatsapp_confirm_message_4': "Мәліметтерді нақтылау үшін менімен хабарласуыңызды сұраймын.",
|
| 163 |
'product_type': "Тауар түрі",
|
| 164 |
-
'tkaniny': "Маталар",
|
| 165 |
'odezhda': "Киімдер",
|
| 166 |
-
'price_per_meter': "Метр бағасы",
|
| 167 |
}
|
| 168 |
}
|
| 169 |
|
|
@@ -210,7 +200,7 @@ def download_db_from_hf(specific_file=None, retries=DOWNLOAD_RETRIES, delay=DOWN
|
|
| 210 |
try:
|
| 211 |
if file_name == DATA_FILE:
|
| 212 |
with open(file_name, 'w', encoding='utf-8') as f:
|
| 213 |
-
json.dump({'products': [], 'categories': [], 'orders': {}, 'settings': {'whatsapp_number': '+77073363943'}}, f)
|
| 214 |
logging.info(f"Created empty local file {file_name} because it was not found on HF.")
|
| 215 |
except Exception as create_e:
|
| 216 |
logging.error(f"Failed to create empty local file {file_name}: {create_e}")
|
|
@@ -274,7 +264,7 @@ def periodic_backup():
|
|
| 274 |
|
| 275 |
|
| 276 |
def load_data():
|
| 277 |
-
default_data = {'products': [], 'categories': [], 'orders': {}, 'settings': {'whatsapp_number': '+77073363943'}}
|
| 278 |
try:
|
| 279 |
with open(DATA_FILE, 'r', encoding='utf-8') as file:
|
| 280 |
data = json.load(file)
|
|
@@ -285,7 +275,8 @@ def load_data():
|
|
| 285 |
if 'products' not in data: data['products'] = []
|
| 286 |
if 'categories' not in data: data['categories'] = []
|
| 287 |
if 'orders' not in data: data['orders'] = {}
|
| 288 |
-
if 'settings' not in data: data['settings'] = {'whatsapp_number': '+77073363943'}
|
|
|
|
| 289 |
return data
|
| 290 |
except FileNotFoundError:
|
| 291 |
logging.warning(f"Local file {DATA_FILE} not found. Attempting download from HF.")
|
|
@@ -303,7 +294,8 @@ def load_data():
|
|
| 303 |
if 'products' not in data: data['products'] = []
|
| 304 |
if 'categories' not in data: data['categories'] = []
|
| 305 |
if 'orders' not in data: data['orders'] = {}
|
| 306 |
-
if 'settings' not in data: data['settings'] = {'whatsapp_number': '+77073363943'}
|
|
|
|
| 307 |
return data
|
| 308 |
except FileNotFoundError:
|
| 309 |
logging.error(f"File {DATA_FILE} still not found even after download reported success. Using default.")
|
|
@@ -333,7 +325,8 @@ def save_data(data):
|
|
| 333 |
if 'products' not in data: data['products'] = []
|
| 334 |
if 'categories' not in data: data['categories'] = []
|
| 335 |
if 'orders' not in data: data['orders'] = {}
|
| 336 |
-
if 'settings' not in data: data['settings'] = {'whatsapp_number': '+77073363943'}
|
|
|
|
| 337 |
|
| 338 |
|
| 339 |
with open(DATA_FILE, 'w', encoding='utf-8') as file:
|
|
@@ -355,22 +348,22 @@ CATALOG_TEMPLATE = '''
|
|
| 355 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
| 356 |
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 357 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 358 |
-
<link href="https://fonts.googleapis.com/css2?family=
|
| 359 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/10.2.0/swiper-bundle.min.css">
|
| 360 |
<style>
|
| 361 |
:root {
|
| 362 |
-
--primary-color: #
|
| 363 |
-
--primary-dark: #
|
| 364 |
-
--surface-color: #
|
| 365 |
-
--background-color: #
|
| 366 |
-
--text-color: #
|
| 367 |
-
--text-color-muted: #
|
| 368 |
-
--border-color: #
|
| 369 |
-
--accent-color: #
|
| 370 |
}
|
| 371 |
* { margin: 0; padding: 0; box-sizing: border-box; }
|
| 372 |
body {
|
| 373 |
-
font-family: '
|
| 374 |
background: var(--background-color);
|
| 375 |
color: var(--text-color);
|
| 376 |
line-height: 1.6;
|
|
@@ -379,67 +372,67 @@ CATALOG_TEMPLATE = '''
|
|
| 379 |
.container { max-width: 100%; margin: 0 auto; padding: 0; }
|
| 380 |
.content-area { padding: 20px; }
|
| 381 |
|
| 382 |
-
.header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; background: rgba(
|
| 383 |
.logo-title-container { display: flex; align-items: center; gap: 15px; }
|
| 384 |
-
.logo-title-container img { height:
|
| 385 |
-
.header h1 { font-family: '
|
| 386 |
|
| 387 |
.lang-switcher { display: flex; gap: 5px; background-color: var(--surface-color); padding: 5px; border-radius: 50px; }
|
| 388 |
.lang-switcher a { color: var(--text-color-muted); text-decoration: none; font-size: 0.9rem; padding: 5px 10px; border-radius: 50px; transition: all 0.3s; }
|
| 389 |
.lang-switcher a.active { background-color: var(--primary-color); color: white; font-weight: bold; }
|
| 390 |
|
| 391 |
-
.store-addresses { padding: 20px; text-align: center; background-color: var(--surface-color); border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.
|
| 392 |
-
.store-addresses h3 { font-family: '
|
| 393 |
.store-addresses p { margin: 5px 0; }
|
| 394 |
|
| 395 |
.search-container { padding: 0 20px 20px; }
|
| 396 |
-
#search-input { width: 100%; padding: 12px 20px; font-size: 1rem; border: 1px solid var(--border-color); border-radius: 50px; outline: none; transition: all 0.3s; background-color:
|
| 397 |
-
#search-input:focus { border-color: var(--primary-color); box-shadow: 0 0 0 4px rgba(
|
| 398 |
|
| 399 |
.filters-wrapper { margin: 0 20px 20px; display: flex; flex-direction: column; gap: 15px; }
|
| 400 |
.filters-container { display: flex; overflow-x: auto; gap: 10px; padding-bottom: 10px; scrollbar-width: none; -ms-overflow-style: none; }
|
| 401 |
.filters-container::-webkit-scrollbar { display: none; }
|
| 402 |
.filter-label { font-size: 0.9rem; color: var(--text-color-muted); margin-left: 5px; }
|
| 403 |
-
.filter-btn { padding: 8px 18px; border: 1px solid var(--border-color); border-radius: 50px; background-color: transparent; cursor: pointer; transition: all 0.3s ease; font-size: 0.9rem; font-weight: 400; color: var(--text-color
|
| 404 |
-
.filter-btn.active, .filter-btn:hover { background-color: var(--primary-color); color: #fff; border-color: var(--primary-color); font-weight: 500; box-shadow: 0 2px 8px rgba(
|
| 405 |
|
| 406 |
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 15px; padding: 0 20px 120px; }
|
| 407 |
@media (min-width: 600px) { .products-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 20px; } }
|
| 408 |
|
| 409 |
-
.product { background:
|
| 410 |
-
.product:hover { transform: translateY(-5px); box-shadow: 0 8px 25px rgba(
|
| 411 |
|
| 412 |
.product-image { width: 100%; aspect-ratio: 1 / 1; background-color: #fff; display: flex; justify-content: center; align-items: center; padding: 10px; }
|
| 413 |
.product-image img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform 0.3s ease; }
|
| 414 |
.product:hover .product-image img { transform: scale(1.05); }
|
| 415 |
.product-info { padding: 15px; flex-grow: 1; display: flex; flex-direction: column; text-align: center; }
|
| 416 |
-
.product h2 { font-family: '
|
| 417 |
.product-price { font-size: 1.2rem; color: var(--primary-color); font-weight: 700; margin: 5px 0; }
|
| 418 |
.product-price .from-text { font-size: 0.8rem; color: var(--text-color-muted); font-weight: 400; }
|
| 419 |
.product-description { display: none; }
|
| 420 |
.product-actions { padding: 0 15px 15px; }
|
| 421 |
|
| 422 |
.product-button { display: inline-flex; align-items: center; justify-content: center; width: 100%; padding: 10px; border: none; border-radius: 50px; background-color: var(--primary-color); color: #fff; font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: all 0.3s ease; text-decoration: none; text-transform: uppercase; letter-spacing: 0.5px; }
|
| 423 |
-
.product-button:hover { background-color: var(--primary-dark); box-shadow: 0 4px 10px rgba(
|
| 424 |
.product-button i { margin-right: 8px; }
|
| 425 |
|
| 426 |
-
.fab { position: fixed; background-color: var(--primary-color); color: #fff; border: none; border-radius: 50%; width: 55px; height: 55px; font-size: 1.5rem; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 15px rgba(
|
| 427 |
.fab:hover { transform: scale(1.1); }
|
| 428 |
#cart-button { bottom: 20px; right: 20px; display: none; }
|
| 429 |
#cart-button span { position: absolute; top: -2px; right: -2px; background-color: #dc3545; color: white; border-radius: 50%; padding: 3px 7px; font-size: 0.75rem; font-weight: bold; min-width: 22px; text-align: center; }
|
| 430 |
|
| 431 |
-
.modal { display: none; position: fixed; z-index: 1001; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.
|
| 432 |
-
.modal-content { background: var(--
|
| 433 |
@keyframes slideIn { from { transform: translateY(-40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
|
| 434 |
|
| 435 |
.close { position: absolute; top: 15px; right: 20px; font-size: 2rem; color: var(--text-color-muted); cursor: pointer; transition: color 0.3s, transform 0.3s; line-height: 1; }
|
| 436 |
.close:hover { color: var(--primary-color); transform: rotate(90deg); }
|
| 437 |
|
| 438 |
-
.modal-content h2 { font-family: '
|
| 439 |
|
| 440 |
.cart-item { display: grid; grid-template-columns: 65px 1fr auto 25px; gap: 15px; align-items: center; padding: 15px 0; border-bottom: 1px solid var(--border-color); }
|
| 441 |
.cart-item:last-child { border-bottom: none; }
|
| 442 |
-
.cart-item img { width: 65px; height: 65px; object-fit: contain; border-radius: 8px; background-color: #fff; padding: 5px; }
|
| 443 |
.cart-item-details strong { display: block; margin-bottom: 4px; font-size: 1.05rem; }
|
| 444 |
.cart-item-price { font-size: 0.9rem; color: var(--text-color-muted); }
|
| 445 |
.cart-item-total { font-weight: bold; text-align: right; font-size: 1rem; color: var(--primary-color); }
|
|
@@ -452,10 +445,10 @@ CATALOG_TEMPLATE = '''
|
|
| 452 |
.cart-summary strong { font-size: 1.4rem; color: var(--primary-color); }
|
| 453 |
.cart-actions { margin-top: 25px; display: flex; justify-content: space-between; gap: 12px; }
|
| 454 |
.cart-actions .product-button { flex-grow: 1; }
|
| 455 |
-
.clear-cart { background: #
|
| 456 |
-
.clear-cart:hover { background: #
|
| 457 |
|
| 458 |
-
.notification { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background-color: var(--primary-color); color: #fff; padding: 12px 25px; border-radius: 50px; box-shadow: 0 4px 15px rgba(0,0,0,0.
|
| 459 |
.notification.show { opacity: 1; bottom: 90px; }
|
| 460 |
.no-results-message { grid-column: 1 / -1; text-align: center; padding: 50px; font-size: 1.2rem; color: var(--text-color-muted); }
|
| 461 |
|
|
@@ -466,7 +459,7 @@ CATALOG_TEMPLATE = '''
|
|
| 466 |
<div class="container">
|
| 467 |
<header class="header">
|
| 468 |
<div class="logo-title-container">
|
| 469 |
-
<img src="https://huggingface.co/spaces/esmira-tkani/admin/resolve/main/
|
| 470 |
<h1>{{ _['header_title'] }}</h1>
|
| 471 |
</div>
|
| 472 |
<div class="lang-switcher">
|
|
@@ -488,14 +481,6 @@ CATALOG_TEMPLATE = '''
|
|
| 488 |
</div>
|
| 489 |
|
| 490 |
<div class="filters-wrapper">
|
| 491 |
-
<div>
|
| 492 |
-
<span class="filter-label">{{ _['product_type'] }}:</span>
|
| 493 |
-
<div class="filters-container">
|
| 494 |
-
<button class="filter-btn type-filter active" data-type="all">{{ _['all_filter'] }}</button>
|
| 495 |
-
<button class="filter-btn type-filter" data-type="tkaniny">{{ _['tkaniny'] }}</button>
|
| 496 |
-
<button class="filter-btn type-filter" data-type="odezhda">{{ _['odezhda'] }}</button>
|
| 497 |
-
</div>
|
| 498 |
-
</div>
|
| 499 |
<div>
|
| 500 |
<span class="filter-label">{{ _['category'] }}:</span>
|
| 501 |
<div class="filters-container">
|
|
@@ -514,7 +499,7 @@ CATALOG_TEMPLATE = '''
|
|
| 514 |
data-name="{{ product['name']|lower }}"
|
| 515 |
data-description="{{ product.get('description', '')|lower }}"
|
| 516 |
data-category="{{ product.get('category', _['no_category']) }}"
|
| 517 |
-
data-type="{{ product.get('product_type', '
|
| 518 |
<div class="product-image" onclick="openModal({{ loop.index0 }})" style="cursor: pointer;">
|
| 519 |
{% if product.get('photos') and product['photos']|length > 0 %}
|
| 520 |
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ product['photos'][0] }}"
|
|
@@ -564,7 +549,7 @@ CATALOG_TEMPLATE = '''
|
|
| 564 |
<select id="variantSelect" class="variant-select"></select>
|
| 565 |
</div>
|
| 566 |
|
| 567 |
-
<div id="size-section"
|
| 568 |
<label for="sizeSelect">{{ _['size_label'] }}</label>
|
| 569 |
<select id="sizeSelect" class="size-select"></select>
|
| 570 |
</div>
|
|
@@ -681,21 +666,12 @@ CATALOG_TEMPLATE = '''
|
|
| 681 |
|
| 682 |
setupSelect('variantSelect', product.variants, v => `${v.name} - ${v.price.toFixed(2)} ${currencyCode}`);
|
| 683 |
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
quantityLabel.textContent = translations['quantity_label'];
|
| 691 |
-
} else {
|
| 692 |
-
document.getElementById('size-section').style.display = 'none';
|
| 693 |
-
quantityInput.type = "number";
|
| 694 |
-
quantityInput.step = "0.1";
|
| 695 |
-
quantityInput.min = "0.1";
|
| 696 |
-
quantityInput.value = "1.0";
|
| 697 |
-
quantityLabel.textContent = translations['quantity_label_meter'];
|
| 698 |
-
}
|
| 699 |
|
| 700 |
document.getElementById('quantityModal').style.display = 'block';
|
| 701 |
document.body.style.overflow = 'hidden';
|
|
@@ -718,14 +694,12 @@ CATALOG_TEMPLATE = '''
|
|
| 718 |
let selectedSize = null;
|
| 719 |
let cartItemId = `${product.id}-${selectedVariant.name}`;
|
| 720 |
|
| 721 |
-
if (product.
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
return;
|
| 725 |
-
}
|
| 726 |
-
selectedSize = product.sizes[sizeIndex];
|
| 727 |
-
cartItemId += `-${selectedSize.name}`;
|
| 728 |
}
|
|
|
|
|
|
|
| 729 |
|
| 730 |
if (isNaN(quantity) || quantity <= 0) {
|
| 731 |
alert("Пожалуйста, укажите корректное количество.");
|
|
@@ -857,7 +831,6 @@ CATALOG_TEMPLATE = '''
|
|
| 857 |
function filterProducts() {
|
| 858 |
const searchTerm = document.getElementById('search-input').value.toLowerCase().trim();
|
| 859 |
const activeCategory = document.querySelector('.category-filter.active').dataset.category;
|
| 860 |
-
const activeType = document.querySelector('.type-filter.active').dataset.type;
|
| 861 |
const grid = document.getElementById('products-grid');
|
| 862 |
let visibleProducts = 0;
|
| 863 |
|
|
@@ -868,13 +841,11 @@ CATALOG_TEMPLATE = '''
|
|
| 868 |
const name = productElement.dataset.name;
|
| 869 |
const description = productElement.dataset.description;
|
| 870 |
const category = productElement.dataset.category;
|
| 871 |
-
const type = productElement.dataset.type;
|
| 872 |
|
| 873 |
const matchesSearch = !searchTerm || name.includes(searchTerm) || description.includes(searchTerm);
|
| 874 |
const matchesCategory = activeCategory === 'all' || category === activeCategory;
|
| 875 |
-
const matchesType = activeType === 'all' || type === activeType;
|
| 876 |
|
| 877 |
-
if (matchesSearch && matchesCategory
|
| 878 |
productElement.style.display = 'flex';
|
| 879 |
visibleProducts++;
|
| 880 |
} else {
|
|
@@ -941,7 +912,7 @@ CATALOG_TEMPLATE = '''
|
|
| 941 |
|
| 942 |
PRODUCT_DETAIL_TEMPLATE = '''
|
| 943 |
<div style="padding: 10px;">
|
| 944 |
-
<h2 style="font-family: '
|
| 945 |
<div class="swiper-container" style="max-width: 450px; margin: 0 auto 25px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border-color);">
|
| 946 |
<div class="swiper-wrapper">
|
| 947 |
{% if product.get('photos') and product['photos']|length > 0 %}
|
|
@@ -968,13 +939,12 @@ PRODUCT_DETAIL_TEMPLATE = '''
|
|
| 968 |
</div>
|
| 969 |
|
| 970 |
<div style="font-size: 1rem; line-height: 1.7; padding: 0 10px;">
|
| 971 |
-
<p><strong>{{ _['product_type'] }}:</strong> {{ _[product.get('product_type', '
|
| 972 |
<p><strong>{{ _['category'] }}:</strong> {{ product.get('category', _['no_category']) }}</p>
|
| 973 |
|
| 974 |
{% if product.get('variants') and product.variants|length > 0 %}
|
| 975 |
<p style="font-size: 1.4rem; font-weight: bold; color: var(--primary-color); margin: 15px 0;">
|
| 976 |
{{ _['from_price'] }} {{ "%.2f"|format(product.variants|map(attribute='price')|min) }} {{ currency_code }}
|
| 977 |
-
{% if product.product_type == 'tkaniny' %} / {{ _['price_per_meter']|lower }} {% endif %}
|
| 978 |
</p>
|
| 979 |
<p><strong>{{ _['available_variants'] }}</strong></p>
|
| 980 |
<ul style="list-style: none; padding-left: 0;">
|
|
@@ -1014,37 +984,37 @@ ORDER_TEMPLATE = '''
|
|
| 1014 |
<head>
|
| 1015 |
<meta charset="UTF-8">
|
| 1016 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 1017 |
-
<title>{{ _['order_page_title'] }}{{ order.id }} -
|
| 1018 |
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 1019 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 1020 |
-
<link href="https://fonts.googleapis.com/css2?family=
|
| 1021 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
| 1022 |
<style>
|
| 1023 |
:root {
|
| 1024 |
-
--primary-color: #
|
| 1025 |
-
--primary-dark: #
|
| 1026 |
-
--surface-color: #
|
| 1027 |
-
--background-color: #
|
| 1028 |
-
--text-color: #
|
| 1029 |
-
--text-color-muted: #
|
| 1030 |
-
--border-color: #
|
| 1031 |
}
|
| 1032 |
-
body { font-family: '
|
| 1033 |
-
.container { max-width: 800px; margin: 20px auto; padding: 30px; background: var(--surface-color); border-radius: 16px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.
|
| 1034 |
-
h1, h2 { font-family: '
|
| 1035 |
h1 { text-align: center; margin-bottom: 25px; font-size: 2.2rem; font-weight: 700; }
|
| 1036 |
h2 { margin-top: 30px; margin-bottom: 15px; font-size: 1.6rem; border-bottom: 1px solid var(--border-color); padding-bottom: 8px; display: flex; align-items: center; gap: 10px; }
|
| 1037 |
.order-meta { font-size: 0.9rem; color: var(--text-color-muted); margin-bottom: 20px; text-align: center; }
|
| 1038 |
.order-item { display: grid; grid-template-columns: 60px 1fr auto; gap: 15px; align-items: center; padding: 15px 0; border-bottom: 1px solid var(--border-color); }
|
| 1039 |
.order-item:last-child { border-bottom: none; }
|
| 1040 |
-
.order-item img { width: 60px; height: 60px; object-fit: contain; border-radius: 8px; background-color: #fff; padding: 5px; border: 1px solid
|
| 1041 |
.item-details strong { display: block; margin-bottom: 4px; font-size: 1.05rem; color: var(--text-color);}
|
| 1042 |
.item-details span { font-size: 0.9rem; color: var(--text-color-muted); display: block;}
|
| 1043 |
.item-total { font-weight: bold; text-align: right; font-size: 1.1rem; color: var(--primary-color);}
|
| 1044 |
.order-summary { margin-top: 30px; padding-top: 20px; border-top: 2px solid var(--primary-color); text-align: right; }
|
| 1045 |
.order-summary p { margin-bottom: 10px; font-size: 1.1rem; }
|
| 1046 |
.order-summary strong { font-size: 1.5rem; color: var(--primary-color); }
|
| 1047 |
-
.customer-info { margin-top: 30px; background-color:
|
| 1048 |
.customer-info p { margin-bottom: 8px; font-size: 1rem; }
|
| 1049 |
.customer-info strong { color: var(--text-color); }
|
| 1050 |
.actions { margin-top: 30px; text-align: center; }
|
|
@@ -1129,50 +1099,50 @@ ADMIN_TEMPLATE = '''
|
|
| 1129 |
<head>
|
| 1130 |
<meta charset="UTF-8">
|
| 1131 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 1132 |
-
<title>Админ-панель -
|
| 1133 |
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 1134 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 1135 |
-
<link href="https://fonts.googleapis.com/css2?family=
|
| 1136 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
| 1137 |
<style>
|
| 1138 |
:root {
|
| 1139 |
-
--primary-color: #
|
| 1140 |
-
--primary-dark: #
|
| 1141 |
-
--surface-color: #
|
| 1142 |
-
--background-color: #
|
| 1143 |
-
--text-color: #
|
| 1144 |
-
--text-color-muted: #
|
| 1145 |
-
--border-color: #
|
| 1146 |
-
--success-bg: #
|
| 1147 |
-
--success-text: #
|
| 1148 |
-
--error-bg: #
|
| 1149 |
-
--error-text: #
|
| 1150 |
-
--warning-bg: #
|
| 1151 |
-
--warning-text: #
|
| 1152 |
}
|
| 1153 |
-
body { font-family: '
|
| 1154 |
-
.container { max-width: 1200px; margin: 0 auto; background-color: var(--surface-color); padding: 25px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.
|
| 1155 |
.header { padding-bottom: 20px; margin-bottom: 25px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px;}
|
| 1156 |
-
h1, h2, h3, h4 { font-family: '
|
| 1157 |
h1 { font-size: 2rem; }
|
| 1158 |
h2 { font-size: 1.6rem; margin-top: 30px; display: flex; align-items: center; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border-color);}
|
| 1159 |
h3 { font-size: 1.2rem; color: var(--text-color); margin-top: 20px;}
|
| 1160 |
-
.section { margin-bottom: 30px; padding: 20px; background-color: #
|
| 1161 |
|
| 1162 |
label { font-weight: 500; margin-top: 12px; display: block; color: var(--text-color); font-size: 0.9rem;}
|
| 1163 |
-
input[type="text"], input[type="number"], input[type="password"], input[type="tel"], textarea, select { width: 100%; padding: 10px 12px; margin-top: 6px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 0.95rem; box-sizing: border-box; transition: border-color 0.3s ease; background-color:
|
| 1164 |
-
input:focus, textarea:focus, select:focus { border-color: var(--primary-color); outline: none; box-shadow: 0 0 0 3px rgba(
|
| 1165 |
textarea { min-height: 90px; resize: vertical; }
|
| 1166 |
-
input[type="file"] { padding: 8px; background-color: #
|
| 1167 |
input[type="checkbox"] { transform: scale(1.2); margin-right: 8px; vertical-align: middle; accent-color: var(--primary-color); }
|
| 1168 |
|
| 1169 |
button, .button { padding: 9px 18px; border: none; border-radius: 50px; background-color: var(--primary-color); color: #fff; font-weight: 500; cursor: pointer; transition: all 0.2s ease; margin-top: 15px; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; line-height: 1.2; text-transform: uppercase; letter-spacing: 0.5px; }
|
| 1170 |
button:hover, .button:hover { background-color: var(--primary-dark); transform: translateY(-1px); }
|
| 1171 |
-
.delete-button { background-color: #
|
| 1172 |
-
.delete-button:hover { background-color: #
|
| 1173 |
|
| 1174 |
.item-list { display: grid; gap: 15px; }
|
| 1175 |
-
.item { background:
|
| 1176 |
.item-actions { margin-top: 15px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
|
| 1177 |
.photo-preview img, .photo-edit-item img { width: 60px; height: 60px; border-radius: 6px; margin: 5px 5px 0 0; border: 1px solid var(--border-color); object-fit: cover; background-color: #fff;}
|
| 1178 |
.photo-preview-edit { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 5px; }
|
|
@@ -1181,21 +1151,21 @@ ADMIN_TEMPLATE = '''
|
|
| 1181 |
|
| 1182 |
.input-group { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
|
| 1183 |
.input-group input { flex-grow: 1; margin: 0; }
|
| 1184 |
-
.remove-btn { background-color: #
|
| 1185 |
-
.add-btn { background-color: #
|
| 1186 |
-
.add-btn:hover { background-color: #
|
| 1187 |
|
| 1188 |
.message { padding: 12px 18px; border-radius: 8px; margin-bottom: 20px; font-size: 0.95rem; border: 1px solid;}
|
| 1189 |
.message.success { background-color: var(--success-bg); color: var(--success-text); border-color: var(--success-text);}
|
| 1190 |
.message.error { background-color: var(--error-bg); color: var(--error-text); border-color: var(--error-text);}
|
| 1191 |
.message.warning { background-color: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-text); }
|
| 1192 |
-
.status-indicator { display: inline-block; padding: 3px 9px; border-radius: 50px; font-size: 0.75rem; font-weight: 500; margin-left: 5px; vertical-align: middle; }
|
| 1193 |
-
.status-indicator.new { background-color: #
|
| 1194 |
-
.status-indicator.accepted { background-color: #
|
| 1195 |
-
.status-indicator.prepared { background-color: #
|
| 1196 |
-
.status-indicator.shipped { background-color: #
|
| 1197 |
|
| 1198 |
-
details { background-color: #
|
| 1199 |
details > summary { cursor: pointer; font-weight: 500; color: var(--text-color); display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; list-style: none; position: relative; }
|
| 1200 |
details[open] > summary { border-bottom: 1px solid var(--border-color); }
|
| 1201 |
.order-details-content { padding: 15px 20px; }
|
|
@@ -1210,7 +1180,7 @@ ADMIN_TEMPLATE = '''
|
|
| 1210 |
<div class="container">
|
| 1211 |
<div class="header">
|
| 1212 |
<div class="logo-title-container" style="display: flex; align-items: center; gap: 15px;">
|
| 1213 |
-
<img src="https://huggingface.co/spaces/esmira-tkani/admin/resolve/main/
|
| 1214 |
<h1><i class="fas fa-tools"></i> Админ-панель</h1>
|
| 1215 |
</div>
|
| 1216 |
<a href="{{ url_for('catalog', lang_code='ru') }}" class="button"><i class="fas fa-store"></i> Перейти в каталог</a>
|
|
@@ -1253,7 +1223,7 @@ ADMIN_TEMPLATE = '''
|
|
| 1253 |
{% endfor %}
|
| 1254 |
</select>
|
| 1255 |
<button type="submit" class="button" style="margin-top:0;"><i class="fas fa-check"></i> Сохранить</button>
|
| 1256 |
-
<a href="{{ url_for('view_order', lang_code='ru', order_id=order.id) }}" target="_blank" class="button" style="background-color: #
|
| 1257 |
</form>
|
| 1258 |
</div>
|
| 1259 |
</div>
|
|
@@ -1270,14 +1240,12 @@ ADMIN_TEMPLATE = '''
|
|
| 1270 |
<input type="hidden" name="action" value="update_settings">
|
| 1271 |
<label for="whatsapp_number">Номер WhatsApp для заказов:</label>
|
| 1272 |
<input type="tel" id="whatsapp_number" name="whatsapp_number" value="{{ settings.get('whatsapp_number', '') }}" required>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1273 |
<button type="submit"><i class="fas fa-save"></i> Сохранить настройки</button>
|
| 1274 |
</form>
|
| 1275 |
-
<p style="margin-top: 20px;"><strong>Текущие адреса в г. Алматы:</strong></p>
|
| 1276 |
-
<ul style="padding-left: 20px;">
|
| 1277 |
-
{% for address in store_addresses %}
|
| 1278 |
-
<li>{{ address }}</li>
|
| 1279 |
-
{% endfor %}
|
| 1280 |
-
</ul>
|
| 1281 |
<p style="margin-top: 10px;"><strong>Валюта:</strong> {{ currency_name }} ({{ currency_code }})</p>
|
| 1282 |
</div>
|
| 1283 |
|
|
@@ -1324,12 +1292,6 @@ ADMIN_TEMPLATE = '''
|
|
| 1324 |
<input type="text" id="add_name" name="name" required>
|
| 1325 |
<label for="add_description">Описание:</label>
|
| 1326 |
<textarea id="add_description" name="description" rows="4"></textarea>
|
| 1327 |
-
|
| 1328 |
-
<label for="add_product_type">Тип товара *:</label>
|
| 1329 |
-
<select id="add_product_type" name="product_type" onchange="toggleProductFields('add')" required>
|
| 1330 |
-
<option value="tkaniny">Ткани</option>
|
| 1331 |
-
<option value="odezhda">Одежда</option>
|
| 1332 |
-
</select>
|
| 1333 |
|
| 1334 |
<label for="add_category">Категория:</label>
|
| 1335 |
<select id="add_category" name="category">
|
|
@@ -1352,11 +1314,11 @@ ADMIN_TEMPLATE = '''
|
|
| 1352 |
</div>
|
| 1353 |
<button type="button" class="button add-btn" onclick="addInputGroup('add-variants-container', 'variant')"><i class="fas fa-plus"></i> Добавить вариант</button>
|
| 1354 |
|
| 1355 |
-
<div id="add-sizes-section" style="
|
| 1356 |
<h4>Размеры *:</h4>
|
| 1357 |
<div id="add-sizes-container">
|
| 1358 |
<div class="input-group">
|
| 1359 |
-
<input type="text" name="size_names" placeholder="Название размера (напр. S, 42-44)">
|
| 1360 |
<button type="button" class="remove-btn" onclick="removeInputGroup(this)"><i class="fas fa-times"></i></button>
|
| 1361 |
</div>
|
| 1362 |
</div>
|
|
@@ -1386,7 +1348,7 @@ ADMIN_TEMPLATE = '''
|
|
| 1386 |
</div>
|
| 1387 |
<div style="flex-grow: 1;">
|
| 1388 |
<h3 style="margin-top: 0; margin-bottom: 5px;">{{ product['name'] }}</h3>
|
| 1389 |
-
<p style="font-size: 0.9rem; color: var(--text-color-muted);"><strong>Тип:</strong> {{ '
|
| 1390 |
<p style="font-size: 0.9rem; color: var(--text-color-muted);"><strong>Категория:</strong> {{ product.get('category', 'Без категории') }}</p>
|
| 1391 |
</div>
|
| 1392 |
</div>
|
|
@@ -1409,12 +1371,6 @@ ADMIN_TEMPLATE = '''
|
|
| 1409 |
<input type="text" name="name" value="{{ product['name'] }}" required>
|
| 1410 |
<label>Описание:</label>
|
| 1411 |
<textarea name="description" rows="4">{{ product.get('description', '') }}</textarea>
|
| 1412 |
-
|
| 1413 |
-
<label>Тип товара *:</label>
|
| 1414 |
-
<select name="product_type" onchange="toggleProductFields('edit-{{ product.id }}')" required>
|
| 1415 |
-
<option value="tkaniny" {% if product.get('product_type') == 'tkaniny' %}selected{% endif %}>Ткани</option>
|
| 1416 |
-
<option value="odezhda" {% if product.get('product_type') == 'odezhda' %}selected{% endif %}>Одежда</option>
|
| 1417 |
-
</select>
|
| 1418 |
|
| 1419 |
<label>Категория:</label>
|
| 1420 |
<select name="category">
|
|
@@ -1453,12 +1409,12 @@ ADMIN_TEMPLATE = '''
|
|
| 1453 |
</div>
|
| 1454 |
<button type="button" class="button add-btn" onclick="addInputGroup('edit-variants-container-{{ product.id }}', 'variant')"><i class="fas fa-plus"></i> Добавить вариант</button>
|
| 1455 |
|
| 1456 |
-
<div id="edit-{{ product.id }}-sizes-section" style="margin-top:20px;
|
| 1457 |
<h4>Размеры *:</h4>
|
| 1458 |
<div id="edit-sizes-container-{{ product.id }}">
|
| 1459 |
{% for size in product.get('sizes', []) %}
|
| 1460 |
<div class="input-group">
|
| 1461 |
-
<input type="text" name="size_names" value="{{ size.name }}" >
|
| 1462 |
<button type="button" class="remove-btn" onclick="removeInputGroup(this)"><i class="fas fa-times"></i></button>
|
| 1463 |
</div>
|
| 1464 |
{% endfor %}
|
|
@@ -1497,7 +1453,7 @@ ADMIN_TEMPLATE = '''
|
|
| 1497 |
`;
|
| 1498 |
} else { // size
|
| 1499 |
newInputGroup.innerHTML = `
|
| 1500 |
-
<input type="text" name="size_names" placeholder="Название размера">
|
| 1501 |
<button type="button" class="remove-btn" onclick="removeInputGroup(this)"><i class="fas fa-times"></i></button>
|
| 1502 |
`;
|
| 1503 |
}
|
|
@@ -1513,41 +1469,6 @@ ADMIN_TEMPLATE = '''
|
|
| 1513 |
alert("Должен быть хотя бы один элемент.");
|
| 1514 |
}
|
| 1515 |
}
|
| 1516 |
-
|
| 1517 |
-
function toggleProductFields(prefix) {
|
| 1518 |
-
const productType = document.querySelector(`[name="product_type"]`).value;
|
| 1519 |
-
const sizesSection = document.getElementById(`${prefix}-sizes-section`);
|
| 1520 |
-
const sizeInputs = sizesSection.querySelectorAll('input[name="size_names"]');
|
| 1521 |
-
|
| 1522 |
-
if (productType === 'odezhda') {
|
| 1523 |
-
sizesSection.style.display = 'block';
|
| 1524 |
-
if (sizesSection.querySelector('.input-group') === null) {
|
| 1525 |
-
addInputGroup(`${prefix}-sizes-container`, 'size')
|
| 1526 |
-
}
|
| 1527 |
-
sizeInputs.forEach(input => input.required = true);
|
| 1528 |
-
} else {
|
| 1529 |
-
sizesSection.style.display = 'none';
|
| 1530 |
-
sizeInputs.forEach(input => input.required = false);
|
| 1531 |
-
}
|
| 1532 |
-
}
|
| 1533 |
-
document.addEventListener('DOMContentLoaded', function() {
|
| 1534 |
-
document.querySelectorAll('form[id^="edit-form-"]').forEach(form => {
|
| 1535 |
-
const id = form.id.replace('edit-form-', '');
|
| 1536 |
-
const select = form.querySelector('select[name="product_type"]');
|
| 1537 |
-
if(select) {
|
| 1538 |
-
const productType = select.value;
|
| 1539 |
-
const sizesSection = document.getElementById(`edit-${id}-sizes-section`);
|
| 1540 |
-
const sizeInputs = sizesSection.querySelectorAll('input[name="size_names"]');
|
| 1541 |
-
if (productType === 'odezhda') {
|
| 1542 |
-
sizesSection.style.display = 'block';
|
| 1543 |
-
sizeInputs.forEach(input => input.required = true);
|
| 1544 |
-
} else {
|
| 1545 |
-
sizesSection.style.display = 'none';
|
| 1546 |
-
sizeInputs.forEach(input => input.required = false);
|
| 1547 |
-
}
|
| 1548 |
-
}
|
| 1549 |
-
});
|
| 1550 |
-
});
|
| 1551 |
</script>
|
| 1552 |
</body>
|
| 1553 |
</html>
|
|
@@ -1574,6 +1495,7 @@ def catalog(lang_code):
|
|
| 1574 |
categories = sorted(data.get('categories', []))
|
| 1575 |
settings = data.get('settings', {})
|
| 1576 |
whatsapp_number = settings.get('whatsapp_number', '+77073363943').replace(' ', '').replace('+', '')
|
|
|
|
| 1577 |
|
| 1578 |
|
| 1579 |
products_in_stock = [p for p in all_products if p.get('variants')]
|
|
@@ -1588,7 +1510,7 @@ def catalog(lang_code):
|
|
| 1588 |
products=products_sorted,
|
| 1589 |
categories=categories,
|
| 1590 |
repo_id=REPO_ID,
|
| 1591 |
-
store_addresses=
|
| 1592 |
currency_code=CURRENCY_CODE,
|
| 1593 |
lang_code=g.lang_code,
|
| 1594 |
_=g.translations,
|
|
@@ -1695,7 +1617,7 @@ def view_order(lang_code, order_id):
|
|
| 1695 |
def admin():
|
| 1696 |
data = load_data()
|
| 1697 |
if 'orders' not in data: data['orders'] = {}
|
| 1698 |
-
if 'settings' not in data: data['settings'] = {'whatsapp_number': '+77073363943'}
|
| 1699 |
|
| 1700 |
|
| 1701 |
needs_save = False
|
|
@@ -1713,10 +1635,16 @@ def admin():
|
|
| 1713 |
new_whatsapp = request.form.get('whatsapp_number', '').strip()
|
| 1714 |
if new_whatsapp:
|
| 1715 |
data['settings']['whatsapp_number'] = new_whatsapp
|
| 1716 |
-
save_data(data)
|
| 1717 |
-
flash('Настройки успешно обновлены.', 'success')
|
| 1718 |
else:
|
| 1719 |
flash('Номер WhatsApp не может быть пустым.', 'error')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1720 |
|
| 1721 |
elif action == 'update_order_status':
|
| 1722 |
order_id = request.form.get('order_id')
|
|
@@ -1772,21 +1700,18 @@ def admin():
|
|
| 1772 |
flash("Неверный формат цены в вариантах.", 'error')
|
| 1773 |
return redirect(url_for('admin'))
|
| 1774 |
|
| 1775 |
-
|
| 1776 |
-
|
| 1777 |
-
|
| 1778 |
-
|
| 1779 |
-
|
| 1780 |
-
flash("Для одежды необходимо указать хотя бы один размер.", 'error')
|
| 1781 |
-
return redirect(url_for('admin'))
|
| 1782 |
-
sizes = [{'name': s_name} for s_name in size_names]
|
| 1783 |
|
| 1784 |
|
| 1785 |
product_data = {
|
| 1786 |
'name': name,
|
| 1787 |
'description': request.form.get('description', '').strip(),
|
| 1788 |
'category': request.form.get('category'),
|
| 1789 |
-
'product_type':
|
| 1790 |
'variants': variants,
|
| 1791 |
'sizes': sizes
|
| 1792 |
}
|
|
@@ -1890,7 +1815,6 @@ def admin():
|
|
| 1890 |
settings=current_data.get('settings', {}),
|
| 1891 |
status_map_ru=STATUS_MAPS['ru'],
|
| 1892 |
repo_id=REPO_ID,
|
| 1893 |
-
store_addresses=STORE_ADDRESSES,
|
| 1894 |
currency_code=CURRENCY_CODE,
|
| 1895 |
currency_name=CURRENCY_NAME
|
| 1896 |
)
|
|
@@ -1903,3 +1827,4 @@ if __name__ == '__main__':
|
|
| 1903 |
threading.Thread(target=periodic_backup, daemon=True).start()
|
| 1904 |
port = int(os.environ.get('PORT', 7860))
|
| 1905 |
app.run(debug=False, host='0.0.0.0', port=port)
|
|
|
|
|
|
| 26 |
HF_TOKEN_WRITE = os.getenv("HF_TOKEN")
|
| 27 |
HF_TOKEN_READ = os.getenv("HF_TOKEN_READ")
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
CURRENCY_CODE = 'KZT'
|
| 31 |
CURRENCY_NAME = 'Казахстанский тенге'
|
|
|
|
| 50 |
|
| 51 |
translations = {
|
| 52 |
'ru': {
|
| 53 |
+
'page_title': "s.amir.kz - одежда оптом и в розницу",
|
| 54 |
+
'header_title': "s.amir.kz",
|
| 55 |
'our_addresses': "Наши адреса в г. Алматы",
|
| 56 |
'search_placeholder': "Поиск по названию или описанию...",
|
| 57 |
'all_filter': "Все",
|
|
|
|
| 64 |
'variant_label': "Вариант:",
|
| 65 |
'size_label': "Размер:",
|
| 66 |
'quantity_label': "Количество:",
|
|
|
|
| 67 |
'confirm_add_to_cart': "Добавить в корзину",
|
| 68 |
'your_cart': "Ваша корзина",
|
| 69 |
'cart_is_empty': "Ваша корзина пуста.",
|
|
|
|
| 95 |
'return_to_catalog': "Вернуться в каталог",
|
| 96 |
'order_not_found_error': "Ошибка",
|
| 97 |
'order_not_found_message': "Заказ с таким ID не найден.",
|
| 98 |
+
'whatsapp_confirm_message_1': "Здравствуйте! Хочу подтвердить свой заказ в s.amir.kz:",
|
| 99 |
'whatsapp_confirm_message_2': "Номер заказа:",
|
| 100 |
'whatsapp_confirm_message_3': "Ссылка на заказ:",
|
| 101 |
'whatsapp_confirm_message_4': "Пожалуйста, свяжитесь со мной для уточнения деталей.",
|
| 102 |
'product_type': "Тип товара",
|
|
|
|
| 103 |
'odezhda': "Одежда",
|
|
|
|
| 104 |
},
|
| 105 |
'kz': {
|
| 106 |
+
'page_title': "s.amir.kz - киімдер көтерме және бөлшек саудада",
|
| 107 |
+
'header_title': "s.amir.kz",
|
| 108 |
'our_addresses': "Алматы қаласындағы мекенжайларымыз",
|
| 109 |
'search_placeholder': "Аты немесе сипаттамасы бойынша іздеу...",
|
| 110 |
'all_filter': "Барлығы",
|
|
|
|
| 117 |
'variant_label': "Нұсқа:",
|
| 118 |
'size_label': "Өлшем:",
|
| 119 |
'quantity_label': "Саны:",
|
|
|
|
| 120 |
'confirm_add_to_cart': "Себетке қосу",
|
| 121 |
'your_cart': "Сіздің себетіңіз",
|
| 122 |
'cart_is_empty': "Сіздің себетіңіз бос.",
|
|
|
|
| 148 |
'return_to_catalog': "Каталогқа оралу",
|
| 149 |
'order_not_found_error': "Қате",
|
| 150 |
'order_not_found_message': "Мұндай ID-мен тапсырыс табылмады.",
|
| 151 |
+
'whatsapp_confirm_message_1': "Сәлеметсіз бе! s.amir.kz-дағы тапсырысымды растағым келеді:",
|
| 152 |
'whatsapp_confirm_message_2': "Тапсырыс нөмірі:",
|
| 153 |
'whatsapp_confirm_message_3': "Тапсырысқа сілтеме:",
|
| 154 |
'whatsapp_confirm_message_4': "Мәліметтерді нақтылау үшін менімен хабарласуыңызды сұраймын.",
|
| 155 |
'product_type': "Тауар түрі",
|
|
|
|
| 156 |
'odezhda': "Киімдер",
|
|
|
|
| 157 |
}
|
| 158 |
}
|
| 159 |
|
|
|
|
| 200 |
try:
|
| 201 |
if file_name == DATA_FILE:
|
| 202 |
with open(file_name, 'w', encoding='utf-8') as f:
|
| 203 |
+
json.dump({'products': [], 'categories': [], 'orders': {}, 'settings': {'whatsapp_number': '+77073363943', 'store_addresses': ['Город Алматы, Алатау 1, блок 4, бутик 112']}}, f)
|
| 204 |
logging.info(f"Created empty local file {file_name} because it was not found on HF.")
|
| 205 |
except Exception as create_e:
|
| 206 |
logging.error(f"Failed to create empty local file {file_name}: {create_e}")
|
|
|
|
| 264 |
|
| 265 |
|
| 266 |
def load_data():
|
| 267 |
+
default_data = {'products': [], 'categories': [], 'orders': {}, 'settings': {'whatsapp_number': '+77073363943', 'store_addresses': ['Город Алматы, Алатау 1, блок 4, бутик 112']}}
|
| 268 |
try:
|
| 269 |
with open(DATA_FILE, 'r', encoding='utf-8') as file:
|
| 270 |
data = json.load(file)
|
|
|
|
| 275 |
if 'products' not in data: data['products'] = []
|
| 276 |
if 'categories' not in data: data['categories'] = []
|
| 277 |
if 'orders' not in data: data['orders'] = {}
|
| 278 |
+
if 'settings' not in data: data['settings'] = {'whatsapp_number': '+77073363943', 'store_addresses': ['Город Алматы, Алатау 1, блок 4, бутик 112']}
|
| 279 |
+
if 'store_addresses' not in data['settings']: data['settings']['store_addresses'] = ['Город Алматы, Алатау 1, блок 4, бутик 112']
|
| 280 |
return data
|
| 281 |
except FileNotFoundError:
|
| 282 |
logging.warning(f"Local file {DATA_FILE} not found. Attempting download from HF.")
|
|
|
|
| 294 |
if 'products' not in data: data['products'] = []
|
| 295 |
if 'categories' not in data: data['categories'] = []
|
| 296 |
if 'orders' not in data: data['orders'] = {}
|
| 297 |
+
if 'settings' not in data: data['settings'] = {'whatsapp_number': '+77073363943', 'store_addresses': ['Город Алматы, Алатау 1, блок 4, бутик 112']}
|
| 298 |
+
if 'store_addresses' not in data['settings']: data['settings']['store_addresses'] = ['Город Алматы, Алатау 1, блок 4, бутик 112']
|
| 299 |
return data
|
| 300 |
except FileNotFoundError:
|
| 301 |
logging.error(f"File {DATA_FILE} still not found even after download reported success. Using default.")
|
|
|
|
| 325 |
if 'products' not in data: data['products'] = []
|
| 326 |
if 'categories' not in data: data['categories'] = []
|
| 327 |
if 'orders' not in data: data['orders'] = {}
|
| 328 |
+
if 'settings' not in data: data['settings'] = {'whatsapp_number': '+77073363943', 'store_addresses': []}
|
| 329 |
+
if 'store_addresses' not in data['settings']: data['settings']['store_addresses'] = []
|
| 330 |
|
| 331 |
|
| 332 |
with open(DATA_FILE, 'w', encoding='utf-8') as file:
|
|
|
|
| 348 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
| 349 |
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 350 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 351 |
+
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&family=Montserrat:wght@600;700&display=swap" rel="stylesheet">
|
| 352 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/10.2.0/swiper-bundle.min.css">
|
| 353 |
<style>
|
| 354 |
:root {
|
| 355 |
+
--primary-color: #000000;
|
| 356 |
+
--primary-dark: #333333;
|
| 357 |
+
--surface-color: #f8f9fa;
|
| 358 |
+
--background-color: #ffffff;
|
| 359 |
+
--text-color: #212529;
|
| 360 |
+
--text-color-muted: #6c757d;
|
| 361 |
+
--border-color: #dee2e6;
|
| 362 |
+
--accent-color: #000000;
|
| 363 |
}
|
| 364 |
* { margin: 0; padding: 0; box-sizing: border-box; }
|
| 365 |
body {
|
| 366 |
+
font-family: 'Roboto', sans-serif;
|
| 367 |
background: var(--background-color);
|
| 368 |
color: var(--text-color);
|
| 369 |
line-height: 1.6;
|
|
|
|
| 372 |
.container { max-width: 100%; margin: 0 auto; padding: 0; }
|
| 373 |
.content-area { padding: 20px; }
|
| 374 |
|
| 375 |
+
.header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; background: rgba(255, 255, 255, 0.8); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border-color); position: sticky; top: 0; z-index: 1000; }
|
| 376 |
.logo-title-container { display: flex; align-items: center; gap: 15px; }
|
| 377 |
+
.logo-title-container img { height: 50px; width: 50px; object-fit: cover; border-radius: 50%; }
|
| 378 |
+
.header h1 { font-family: 'Montserrat', sans-serif; font-size: 1.8rem; font-weight: 700; color: var(--accent-color); }
|
| 379 |
|
| 380 |
.lang-switcher { display: flex; gap: 5px; background-color: var(--surface-color); padding: 5px; border-radius: 50px; }
|
| 381 |
.lang-switcher a { color: var(--text-color-muted); text-decoration: none; font-size: 0.9rem; padding: 5px 10px; border-radius: 50px; transition: all 0.3s; }
|
| 382 |
.lang-switcher a.active { background-color: var(--primary-color); color: white; font-weight: bold; }
|
| 383 |
|
| 384 |
+
.store-addresses { padding: 20px; text-align: center; background-color: var(--surface-color); border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); font-size: 0.95rem; color: var(--text-color-muted); margin: 20px; }
|
| 385 |
+
.store-addresses h3 { font-family: 'Montserrat', sans-serif; color: var(--primary-color); font-size: 1.3rem; margin-bottom: 10px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; }
|
| 386 |
.store-addresses p { margin: 5px 0; }
|
| 387 |
|
| 388 |
.search-container { padding: 0 20px 20px; }
|
| 389 |
+
#search-input { width: 100%; padding: 12px 20px; font-size: 1rem; border: 1px solid var(--border-color); border-radius: 50px; outline: none; transition: all 0.3s; background-color: #fff; color: var(--text-color); }
|
| 390 |
+
#search-input:focus { border-color: var(--primary-color); box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.1); }
|
| 391 |
|
| 392 |
.filters-wrapper { margin: 0 20px 20px; display: flex; flex-direction: column; gap: 15px; }
|
| 393 |
.filters-container { display: flex; overflow-x: auto; gap: 10px; padding-bottom: 10px; scrollbar-width: none; -ms-overflow-style: none; }
|
| 394 |
.filters-container::-webkit-scrollbar { display: none; }
|
| 395 |
.filter-label { font-size: 0.9rem; color: var(--text-color-muted); margin-left: 5px; }
|
| 396 |
+
.filter-btn { padding: 8px 18px; border: 1px solid var(--border-color); border-radius: 50px; background-color: transparent; cursor: pointer; transition: all 0.3s ease; font-size: 0.9rem; font-weight: 400; color: var(--text-color); white-space: nowrap; }
|
| 397 |
+
.filter-btn.active, .filter-btn:hover { background-color: var(--primary-color); color: #fff; border-color: var(--primary-color); font-weight: 500; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); transform: translateY(-2px); }
|
| 398 |
|
| 399 |
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 15px; padding: 0 20px 120px; }
|
| 400 |
@media (min-width: 600px) { .products-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 20px; } }
|
| 401 |
|
| 402 |
+
.product { background: #fff; border-radius: 16px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08); transition: all 0.3s ease; overflow: hidden; display: flex; flex-direction: column; height: 100%; position: relative; border: 1px solid var(--border-color); }
|
| 403 |
+
.product:hover { transform: translateY(-5px); box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12); border-color: var(--primary-color); }
|
| 404 |
|
| 405 |
.product-image { width: 100%; aspect-ratio: 1 / 1; background-color: #fff; display: flex; justify-content: center; align-items: center; padding: 10px; }
|
| 406 |
.product-image img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform 0.3s ease; }
|
| 407 |
.product:hover .product-image img { transform: scale(1.05); }
|
| 408 |
.product-info { padding: 15px; flex-grow: 1; display: flex; flex-direction: column; text-align: center; }
|
| 409 |
+
.product h2 { font-family: 'Montserrat', sans-serif; font-size: 1.1rem; font-weight: 600; margin: 0 0 8px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-color); }
|
| 410 |
.product-price { font-size: 1.2rem; color: var(--primary-color); font-weight: 700; margin: 5px 0; }
|
| 411 |
.product-price .from-text { font-size: 0.8rem; color: var(--text-color-muted); font-weight: 400; }
|
| 412 |
.product-description { display: none; }
|
| 413 |
.product-actions { padding: 0 15px 15px; }
|
| 414 |
|
| 415 |
.product-button { display: inline-flex; align-items: center; justify-content: center; width: 100%; padding: 10px; border: none; border-radius: 50px; background-color: var(--primary-color); color: #fff; font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: all 0.3s ease; text-decoration: none; text-transform: uppercase; letter-spacing: 0.5px; }
|
| 416 |
+
.product-button:hover { background-color: var(--primary-dark); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); }
|
| 417 |
.product-button i { margin-right: 8px; }
|
| 418 |
|
| 419 |
+
.fab { position: fixed; background-color: var(--primary-color); color: #fff; border: none; border-radius: 50%; width: 55px; height: 55px; font-size: 1.5rem; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); z-index: 1000; transition: transform 0.2s ease; }
|
| 420 |
.fab:hover { transform: scale(1.1); }
|
| 421 |
#cart-button { bottom: 20px; right: 20px; display: none; }
|
| 422 |
#cart-button span { position: absolute; top: -2px; right: -2px; background-color: #dc3545; color: white; border-radius: 50%; padding: 3px 7px; font-size: 0.75rem; font-weight: bold; min-width: 22px; text-align: center; }
|
| 423 |
|
| 424 |
+
.modal { display: none; position: fixed; z-index: 1001; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.6); backdrop-filter: blur(8px); overflow-y: auto; }
|
| 425 |
+
.modal-content { background: var(--background-color); margin: 5% auto; padding: 25px; border-radius: 16px; width: 95%; max-width: 600px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); animation: slideIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94); position: relative; border: 1px solid var(--border-color); }
|
| 426 |
@keyframes slideIn { from { transform: translateY(-40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
|
| 427 |
|
| 428 |
.close { position: absolute; top: 15px; right: 20px; font-size: 2rem; color: var(--text-color-muted); cursor: pointer; transition: color 0.3s, transform 0.3s; line-height: 1; }
|
| 429 |
.close:hover { color: var(--primary-color); transform: rotate(90deg); }
|
| 430 |
|
| 431 |
+
.modal-content h2 { font-family: 'Montserrat', sans-serif; margin-top: 0; margin-bottom: 25px; color: var(--primary-color); font-size: 1.8rem; display: flex; align-items: center; gap: 12px;}
|
| 432 |
|
| 433 |
.cart-item { display: grid; grid-template-columns: 65px 1fr auto 25px; gap: 15px; align-items: center; padding: 15px 0; border-bottom: 1px solid var(--border-color); }
|
| 434 |
.cart-item:last-child { border-bottom: none; }
|
| 435 |
+
.cart-item img { width: 65px; height: 65px; object-fit: contain; border-radius: 8px; background-color: #fff; padding: 5px; border: 1px solid var(--border-color); }
|
| 436 |
.cart-item-details strong { display: block; margin-bottom: 4px; font-size: 1.05rem; }
|
| 437 |
.cart-item-price { font-size: 0.9rem; color: var(--text-color-muted); }
|
| 438 |
.cart-item-total { font-weight: bold; text-align: right; font-size: 1rem; color: var(--primary-color); }
|
|
|
|
| 445 |
.cart-summary strong { font-size: 1.4rem; color: var(--primary-color); }
|
| 446 |
.cart-actions { margin-top: 25px; display: flex; justify-content: space-between; gap: 12px; }
|
| 447 |
.cart-actions .product-button { flex-grow: 1; }
|
| 448 |
+
.clear-cart { background: #6c757d; color: #fff; }
|
| 449 |
+
.clear-cart:hover { background: #5a6268; }
|
| 450 |
|
| 451 |
+
.notification { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background-color: var(--primary-color); color: #fff; padding: 12px 25px; border-radius: 50px; box-shadow: 0 4px 15px rgba(0,0,0,0.2); z-index: 1002; opacity: 0; transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94); font-size: 0.95rem; font-weight: 500; }
|
| 452 |
.notification.show { opacity: 1; bottom: 90px; }
|
| 453 |
.no-results-message { grid-column: 1 / -1; text-align: center; padding: 50px; font-size: 1.2rem; color: var(--text-color-muted); }
|
| 454 |
|
|
|
|
| 459 |
<div class="container">
|
| 460 |
<header class="header">
|
| 461 |
<div class="logo-title-container">
|
| 462 |
+
<img src="https://huggingface.co/spaces/esmira-tkani/admin/resolve/main/Screenshot_20260208-120337.png" alt="s.amir.kz Logo">
|
| 463 |
<h1>{{ _['header_title'] }}</h1>
|
| 464 |
</div>
|
| 465 |
<div class="lang-switcher">
|
|
|
|
| 481 |
</div>
|
| 482 |
|
| 483 |
<div class="filters-wrapper">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 484 |
<div>
|
| 485 |
<span class="filter-label">{{ _['category'] }}:</span>
|
| 486 |
<div class="filters-container">
|
|
|
|
| 499 |
data-name="{{ product['name']|lower }}"
|
| 500 |
data-description="{{ product.get('description', '')|lower }}"
|
| 501 |
data-category="{{ product.get('category', _['no_category']) }}"
|
| 502 |
+
data-type="{{ product.get('product_type', 'odezhda') }}">
|
| 503 |
<div class="product-image" onclick="openModal({{ loop.index0 }})" style="cursor: pointer;">
|
| 504 |
{% if product.get('photos') and product['photos']|length > 0 %}
|
| 505 |
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ product['photos'][0] }}"
|
|
|
|
| 549 |
<select id="variantSelect" class="variant-select"></select>
|
| 550 |
</div>
|
| 551 |
|
| 552 |
+
<div id="size-section">
|
| 553 |
<label for="sizeSelect">{{ _['size_label'] }}</label>
|
| 554 |
<select id="sizeSelect" class="size-select"></select>
|
| 555 |
</div>
|
|
|
|
| 666 |
|
| 667 |
setupSelect('variantSelect', product.variants, v => `${v.name} - ${v.price.toFixed(2)} ${currencyCode}`);
|
| 668 |
|
| 669 |
+
setupSelect('sizeSelect', product.sizes, s => s.name);
|
| 670 |
+
quantityInput.type = "number";
|
| 671 |
+
quantityInput.step = "1";
|
| 672 |
+
quantityInput.min = "1";
|
| 673 |
+
quantityInput.value = "1";
|
| 674 |
+
quantityLabel.textContent = translations['quantity_label'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 675 |
|
| 676 |
document.getElementById('quantityModal').style.display = 'block';
|
| 677 |
document.body.style.overflow = 'hidden';
|
|
|
|
| 694 |
let selectedSize = null;
|
| 695 |
let cartItemId = `${product.id}-${selectedVariant.name}`;
|
| 696 |
|
| 697 |
+
if (!product.sizes || product.sizes.length === 0) {
|
| 698 |
+
alert("Ошибка: Размеры для этой одежды не найдены.");
|
| 699 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 700 |
}
|
| 701 |
+
selectedSize = product.sizes[sizeIndex];
|
| 702 |
+
cartItemId += `-${selectedSize.name}`;
|
| 703 |
|
| 704 |
if (isNaN(quantity) || quantity <= 0) {
|
| 705 |
alert("Пожалуйста, укажите корректное количество.");
|
|
|
|
| 831 |
function filterProducts() {
|
| 832 |
const searchTerm = document.getElementById('search-input').value.toLowerCase().trim();
|
| 833 |
const activeCategory = document.querySelector('.category-filter.active').dataset.category;
|
|
|
|
| 834 |
const grid = document.getElementById('products-grid');
|
| 835 |
let visibleProducts = 0;
|
| 836 |
|
|
|
|
| 841 |
const name = productElement.dataset.name;
|
| 842 |
const description = productElement.dataset.description;
|
| 843 |
const category = productElement.dataset.category;
|
|
|
|
| 844 |
|
| 845 |
const matchesSearch = !searchTerm || name.includes(searchTerm) || description.includes(searchTerm);
|
| 846 |
const matchesCategory = activeCategory === 'all' || category === activeCategory;
|
|
|
|
| 847 |
|
| 848 |
+
if (matchesSearch && matchesCategory) {
|
| 849 |
productElement.style.display = 'flex';
|
| 850 |
visibleProducts++;
|
| 851 |
} else {
|
|
|
|
| 912 |
|
| 913 |
PRODUCT_DETAIL_TEMPLATE = '''
|
| 914 |
<div style="padding: 10px;">
|
| 915 |
+
<h2 style="font-family: 'Montserrat', sans-serif; font-size: 2rem; font-weight: 700; margin-bottom: 20px; text-align: center; color: var(--primary-color);">{{ product['name'] }}</h2>
|
| 916 |
<div class="swiper-container" style="max-width: 450px; margin: 0 auto 25px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border-color);">
|
| 917 |
<div class="swiper-wrapper">
|
| 918 |
{% if product.get('photos') and product['photos']|length > 0 %}
|
|
|
|
| 939 |
</div>
|
| 940 |
|
| 941 |
<div style="font-size: 1rem; line-height: 1.7; padding: 0 10px;">
|
| 942 |
+
<p><strong>{{ _['product_type'] }}:</strong> {{ _[product.get('product_type', 'odezhda')] }}</p>
|
| 943 |
<p><strong>{{ _['category'] }}:</strong> {{ product.get('category', _['no_category']) }}</p>
|
| 944 |
|
| 945 |
{% if product.get('variants') and product.variants|length > 0 %}
|
| 946 |
<p style="font-size: 1.4rem; font-weight: bold; color: var(--primary-color); margin: 15px 0;">
|
| 947 |
{{ _['from_price'] }} {{ "%.2f"|format(product.variants|map(attribute='price')|min) }} {{ currency_code }}
|
|
|
|
| 948 |
</p>
|
| 949 |
<p><strong>{{ _['available_variants'] }}</strong></p>
|
| 950 |
<ul style="list-style: none; padding-left: 0;">
|
|
|
|
| 984 |
<head>
|
| 985 |
<meta charset="UTF-8">
|
| 986 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 987 |
+
<title>{{ _['order_page_title'] }}{{ order.id }} - s.amir.kz</title>
|
| 988 |
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 989 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 990 |
+
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&family=Montserrat:wght@600;700&display=swap" rel="stylesheet">
|
| 991 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
| 992 |
<style>
|
| 993 |
:root {
|
| 994 |
+
--primary-color: #000000;
|
| 995 |
+
--primary-dark: #333333;
|
| 996 |
+
--surface-color: #ffffff;
|
| 997 |
+
--background-color: #f8f9fa;
|
| 998 |
+
--text-color: #212529;
|
| 999 |
+
--text-color-muted: #6c757d;
|
| 1000 |
+
--border-color: #dee2e6;
|
| 1001 |
}
|
| 1002 |
+
body { font-family: 'Roboto', sans-serif; background: var(--background-color); color: var(--text-color); line-height: 1.6; padding: 15px; }
|
| 1003 |
+
.container { max-width: 800px; margin: 20px auto; padding: 30px; background: var(--surface-color); border-radius: 16px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1); border: 1px solid var(--border-color); }
|
| 1004 |
+
h1, h2 { font-family: 'Montserrat', sans-serif; color: var(--primary-color); }
|
| 1005 |
h1 { text-align: center; margin-bottom: 25px; font-size: 2.2rem; font-weight: 700; }
|
| 1006 |
h2 { margin-top: 30px; margin-bottom: 15px; font-size: 1.6rem; border-bottom: 1px solid var(--border-color); padding-bottom: 8px; display: flex; align-items: center; gap: 10px; }
|
| 1007 |
.order-meta { font-size: 0.9rem; color: var(--text-color-muted); margin-bottom: 20px; text-align: center; }
|
| 1008 |
.order-item { display: grid; grid-template-columns: 60px 1fr auto; gap: 15px; align-items: center; padding: 15px 0; border-bottom: 1px solid var(--border-color); }
|
| 1009 |
.order-item:last-child { border-bottom: none; }
|
| 1010 |
+
.order-item img { width: 60px; height: 60px; object-fit: contain; border-radius: 8px; background-color: #fff; padding: 5px; border: 1px solid var(--border-color);}
|
| 1011 |
.item-details strong { display: block; margin-bottom: 4px; font-size: 1.05rem; color: var(--text-color);}
|
| 1012 |
.item-details span { font-size: 0.9rem; color: var(--text-color-muted); display: block;}
|
| 1013 |
.item-total { font-weight: bold; text-align: right; font-size: 1.1rem; color: var(--primary-color);}
|
| 1014 |
.order-summary { margin-top: 30px; padding-top: 20px; border-top: 2px solid var(--primary-color); text-align: right; }
|
| 1015 |
.order-summary p { margin-bottom: 10px; font-size: 1.1rem; }
|
| 1016 |
.order-summary strong { font-size: 1.5rem; color: var(--primary-color); }
|
| 1017 |
+
.customer-info { margin-top: 30px; background-color: #f8f9fa; padding: 20px; border-radius: 12px; border: 1px solid var(--border-color);}
|
| 1018 |
.customer-info p { margin-bottom: 8px; font-size: 1rem; }
|
| 1019 |
.customer-info strong { color: var(--text-color); }
|
| 1020 |
.actions { margin-top: 30px; text-align: center; }
|
|
|
|
| 1099 |
<head>
|
| 1100 |
<meta charset="UTF-8">
|
| 1101 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 1102 |
+
<title>Админ-панель - s.amir.kz</title>
|
| 1103 |
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 1104 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 1105 |
+
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Montserrat:wght@600&display=swap" rel="stylesheet">
|
| 1106 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
| 1107 |
<style>
|
| 1108 |
:root {
|
| 1109 |
+
--primary-color: #000000;
|
| 1110 |
+
--primary-dark: #333333;
|
| 1111 |
+
--surface-color: #ffffff;
|
| 1112 |
+
--background-color: #f4f7f6;
|
| 1113 |
+
--text-color: #212529;
|
| 1114 |
+
--text-color-muted: #6c757d;
|
| 1115 |
+
--border-color: #dee2e6;
|
| 1116 |
+
--success-bg: #d4edda;
|
| 1117 |
+
--success-text: #155724;
|
| 1118 |
+
--error-bg: #f8d7da;
|
| 1119 |
+
--error-text: #721c24;
|
| 1120 |
+
--warning-bg: #fff3cd;
|
| 1121 |
+
--warning-text: #856404;
|
| 1122 |
}
|
| 1123 |
+
body { font-family: 'Roboto', sans-serif; background-color: var(--background-color); color: var(--text-color); padding: 15px; line-height: 1.5; }
|
| 1124 |
+
.container { max-width: 1200px; margin: 0 auto; background-color: var(--surface-color); padding: 25px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.08); border: 1px solid var(--border-color); }
|
| 1125 |
.header { padding-bottom: 20px; margin-bottom: 25px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px;}
|
| 1126 |
+
h1, h2, h3, h4 { font-family: 'Montserrat', sans-serif; font-weight: 600; color: var(--primary-color); margin:0 0 15px 0;}
|
| 1127 |
h1 { font-size: 2rem; }
|
| 1128 |
h2 { font-size: 1.6rem; margin-top: 30px; display: flex; align-items: center; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border-color);}
|
| 1129 |
h3 { font-size: 1.2rem; color: var(--text-color); margin-top: 20px;}
|
| 1130 |
+
.section { margin-bottom: 30px; padding: 20px; background-color: #fff; border: 1px solid var(--border-color); border-radius: 8px; }
|
| 1131 |
|
| 1132 |
label { font-weight: 500; margin-top: 12px; display: block; color: var(--text-color); font-size: 0.9rem;}
|
| 1133 |
+
input[type="text"], input[type="number"], input[type="password"], input[type="tel"], textarea, select { width: 100%; padding: 10px 12px; margin-top: 6px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 0.95rem; box-sizing: border-box; transition: border-color 0.3s ease; background-color: #fff; color: var(--text-color); }
|
| 1134 |
+
input:focus, textarea:focus, select:focus { border-color: var(--primary-color); outline: none; box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1); }
|
| 1135 |
textarea { min-height: 90px; resize: vertical; }
|
| 1136 |
+
input[type="file"] { padding: 8px; background-color: #f8f9fa; cursor: pointer; border: 1px solid var(--border-color); border-radius: 6px; }
|
| 1137 |
input[type="checkbox"] { transform: scale(1.2); margin-right: 8px; vertical-align: middle; accent-color: var(--primary-color); }
|
| 1138 |
|
| 1139 |
button, .button { padding: 9px 18px; border: none; border-radius: 50px; background-color: var(--primary-color); color: #fff; font-weight: 500; cursor: pointer; transition: all 0.2s ease; margin-top: 15px; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; line-height: 1.2; text-transform: uppercase; letter-spacing: 0.5px; }
|
| 1140 |
button:hover, .button:hover { background-color: var(--primary-dark); transform: translateY(-1px); }
|
| 1141 |
+
.delete-button { background-color: #dc3545; color: white; }
|
| 1142 |
+
.delete-button:hover { background-color: #c82333; }
|
| 1143 |
|
| 1144 |
.item-list { display: grid; gap: 15px; }
|
| 1145 |
+
.item { background: #f8f9fa; padding: 15px; border-radius: 8px; border: 1px solid var(--border-color); }
|
| 1146 |
.item-actions { margin-top: 15px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
|
| 1147 |
.photo-preview img, .photo-edit-item img { width: 60px; height: 60px; border-radius: 6px; margin: 5px 5px 0 0; border: 1px solid var(--border-color); object-fit: cover; background-color: #fff;}
|
| 1148 |
.photo-preview-edit { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 5px; }
|
|
|
|
| 1151 |
|
| 1152 |
.input-group { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
|
| 1153 |
.input-group input { flex-grow: 1; margin: 0; }
|
| 1154 |
+
.remove-btn { background-color: #dc3545; color: white; padding: 6px 10px; font-size: 0.8rem; margin: 0; border-radius: 6px; }
|
| 1155 |
+
.add-btn { background-color: #28a745; color: #fff; margin-top: 8px;}
|
| 1156 |
+
.add-btn:hover { background-color: #218838; }
|
| 1157 |
|
| 1158 |
.message { padding: 12px 18px; border-radius: 8px; margin-bottom: 20px; font-size: 0.95rem; border: 1px solid;}
|
| 1159 |
.message.success { background-color: var(--success-bg); color: var(--success-text); border-color: var(--success-text);}
|
| 1160 |
.message.error { background-color: var(--error-bg); color: var(--error-text); border-color: var(--error-text);}
|
| 1161 |
.message.warning { background-color: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-text); }
|
| 1162 |
+
.status-indicator { display: inline-block; padding: 3px 9px; border-radius: 50px; font-size: 0.75rem; font-weight: 500; margin-left: 5px; vertical-align: middle; color: #fff;}
|
| 1163 |
+
.status-indicator.new { background-color: #fd7e14; }
|
| 1164 |
+
.status-indicator.accepted { background-color: #007bff; }
|
| 1165 |
+
.status-indicator.prepared { background-color: #28a745; }
|
| 1166 |
+
.status-indicator.shipped { background-color: #17a2b8; }
|
| 1167 |
|
| 1168 |
+
details { background-color: #fff; border: 1px solid var(--border-color); border-radius: 8px; margin-bottom: 10px; }
|
| 1169 |
details > summary { cursor: pointer; font-weight: 500; color: var(--text-color); display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; list-style: none; position: relative; }
|
| 1170 |
details[open] > summary { border-bottom: 1px solid var(--border-color); }
|
| 1171 |
.order-details-content { padding: 15px 20px; }
|
|
|
|
| 1180 |
<div class="container">
|
| 1181 |
<div class="header">
|
| 1182 |
<div class="logo-title-container" style="display: flex; align-items: center; gap: 15px;">
|
| 1183 |
+
<img src="https://huggingface.co/spaces/esmira-tkani/admin/resolve/main/Screenshot_20260208-120337.png" alt="s.amir.kz Logo" style="height: 50px; width: 50px; border-radius: 50%;">
|
| 1184 |
<h1><i class="fas fa-tools"></i> Админ-панель</h1>
|
| 1185 |
</div>
|
| 1186 |
<a href="{{ url_for('catalog', lang_code='ru') }}" class="button"><i class="fas fa-store"></i> Перейти в каталог</a>
|
|
|
|
| 1223 |
{% endfor %}
|
| 1224 |
</select>
|
| 1225 |
<button type="submit" class="button" style="margin-top:0;"><i class="fas fa-check"></i> Сохранить</button>
|
| 1226 |
+
<a href="{{ url_for('view_order', lang_code='ru', order_id=order.id) }}" target="_blank" class="button" style="background-color: #6c757d; color: white; margin-top:0;"><i class="fas fa-eye"></i> Просмотр</a>
|
| 1227 |
</form>
|
| 1228 |
</div>
|
| 1229 |
</div>
|
|
|
|
| 1240 |
<input type="hidden" name="action" value="update_settings">
|
| 1241 |
<label for="whatsapp_number">Номер WhatsApp для заказов:</label>
|
| 1242 |
<input type="tel" id="whatsapp_number" name="whatsapp_number" value="{{ settings.get('whatsapp_number', '') }}" required>
|
| 1243 |
+
|
| 1244 |
+
<label for="store_addresses">Адреса магазинов (каждый с новой строки):</label>
|
| 1245 |
+
<textarea id="store_addresses" name="store_addresses" rows="4">{{ settings.get('store_addresses', [])|join('\n') }}</textarea>
|
| 1246 |
+
|
| 1247 |
<button type="submit"><i class="fas fa-save"></i> Сохранить настройки</button>
|
| 1248 |
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1249 |
<p style="margin-top: 10px;"><strong>Валюта:</strong> {{ currency_name }} ({{ currency_code }})</p>
|
| 1250 |
</div>
|
| 1251 |
|
|
|
|
| 1292 |
<input type="text" id="add_name" name="name" required>
|
| 1293 |
<label for="add_description">Описание:</label>
|
| 1294 |
<textarea id="add_description" name="description" rows="4"></textarea>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1295 |
|
| 1296 |
<label for="add_category">Категория:</label>
|
| 1297 |
<select id="add_category" name="category">
|
|
|
|
| 1314 |
</div>
|
| 1315 |
<button type="button" class="button add-btn" onclick="addInputGroup('add-variants-container', 'variant')"><i class="fas fa-plus"></i> Добавить вариант</button>
|
| 1316 |
|
| 1317 |
+
<div id="add-sizes-section" style="margin-top:20px;">
|
| 1318 |
<h4>Размеры *:</h4>
|
| 1319 |
<div id="add-sizes-container">
|
| 1320 |
<div class="input-group">
|
| 1321 |
+
<input type="text" name="size_names" placeholder="Название размера (напр. S, 42-44)" required>
|
| 1322 |
<button type="button" class="remove-btn" onclick="removeInputGroup(this)"><i class="fas fa-times"></i></button>
|
| 1323 |
</div>
|
| 1324 |
</div>
|
|
|
|
| 1348 |
</div>
|
| 1349 |
<div style="flex-grow: 1;">
|
| 1350 |
<h3 style="margin-top: 0; margin-bottom: 5px;">{{ product['name'] }}</h3>
|
| 1351 |
+
<p style="font-size: 0.9rem; color: var(--text-color-muted);"><strong>Тип:</strong> {{ _['odezhda'] }}</p>
|
| 1352 |
<p style="font-size: 0.9rem; color: var(--text-color-muted);"><strong>Категория:</strong> {{ product.get('category', 'Без категории') }}</p>
|
| 1353 |
</div>
|
| 1354 |
</div>
|
|
|
|
| 1371 |
<input type="text" name="name" value="{{ product['name'] }}" required>
|
| 1372 |
<label>Описание:</label>
|
| 1373 |
<textarea name="description" rows="4">{{ product.get('description', '') }}</textarea>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1374 |
|
| 1375 |
<label>Категория:</label>
|
| 1376 |
<select name="category">
|
|
|
|
| 1409 |
</div>
|
| 1410 |
<button type="button" class="button add-btn" onclick="addInputGroup('edit-variants-container-{{ product.id }}', 'variant')"><i class="fas fa-plus"></i> Добавить вариант</button>
|
| 1411 |
|
| 1412 |
+
<div id="edit-{{ product.id }}-sizes-section" style="margin-top:20px;">
|
| 1413 |
<h4>Размеры *:</h4>
|
| 1414 |
<div id="edit-sizes-container-{{ product.id }}">
|
| 1415 |
{% for size in product.get('sizes', []) %}
|
| 1416 |
<div class="input-group">
|
| 1417 |
+
<input type="text" name="size_names" value="{{ size.name }}" required>
|
| 1418 |
<button type="button" class="remove-btn" onclick="removeInputGroup(this)"><i class="fas fa-times"></i></button>
|
| 1419 |
</div>
|
| 1420 |
{% endfor %}
|
|
|
|
| 1453 |
`;
|
| 1454 |
} else { // size
|
| 1455 |
newInputGroup.innerHTML = `
|
| 1456 |
+
<input type="text" name="size_names" placeholder="Название размера" required>
|
| 1457 |
<button type="button" class="remove-btn" onclick="removeInputGroup(this)"><i class="fas fa-times"></i></button>
|
| 1458 |
`;
|
| 1459 |
}
|
|
|
|
| 1469 |
alert("Должен быть хотя бы один элемент.");
|
| 1470 |
}
|
| 1471 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1472 |
</script>
|
| 1473 |
</body>
|
| 1474 |
</html>
|
|
|
|
| 1495 |
categories = sorted(data.get('categories', []))
|
| 1496 |
settings = data.get('settings', {})
|
| 1497 |
whatsapp_number = settings.get('whatsapp_number', '+77073363943').replace(' ', '').replace('+', '')
|
| 1498 |
+
store_addresses = settings.get('store_addresses', [])
|
| 1499 |
|
| 1500 |
|
| 1501 |
products_in_stock = [p for p in all_products if p.get('variants')]
|
|
|
|
| 1510 |
products=products_sorted,
|
| 1511 |
categories=categories,
|
| 1512 |
repo_id=REPO_ID,
|
| 1513 |
+
store_addresses=store_addresses,
|
| 1514 |
currency_code=CURRENCY_CODE,
|
| 1515 |
lang_code=g.lang_code,
|
| 1516 |
_=g.translations,
|
|
|
|
| 1617 |
def admin():
|
| 1618 |
data = load_data()
|
| 1619 |
if 'orders' not in data: data['orders'] = {}
|
| 1620 |
+
if 'settings' not in data: data['settings'] = {'whatsapp_number': '+77073363943', 'store_addresses': []}
|
| 1621 |
|
| 1622 |
|
| 1623 |
needs_save = False
|
|
|
|
| 1635 |
new_whatsapp = request.form.get('whatsapp_number', '').strip()
|
| 1636 |
if new_whatsapp:
|
| 1637 |
data['settings']['whatsapp_number'] = new_whatsapp
|
|
|
|
|
|
|
| 1638 |
else:
|
| 1639 |
flash('Номер WhatsApp не может быть пустым.', 'error')
|
| 1640 |
+
|
| 1641 |
+
addresses_text = request.form.get('store_addresses', '')
|
| 1642 |
+
address_list = [addr.strip() for addr in addresses_text.splitlines() if addr.strip()]
|
| 1643 |
+
data['settings']['store_addresses'] = address_list
|
| 1644 |
+
|
| 1645 |
+
save_data(data)
|
| 1646 |
+
flash('Настройки успешно обновлены.', 'success')
|
| 1647 |
+
|
| 1648 |
|
| 1649 |
elif action == 'update_order_status':
|
| 1650 |
order_id = request.form.get('order_id')
|
|
|
|
| 1700 |
flash("Неверный формат цены в вариантах.", 'error')
|
| 1701 |
return redirect(url_for('admin'))
|
| 1702 |
|
| 1703 |
+
size_names = [s.strip() for s in request.form.getlist('size_names') if s.strip()]
|
| 1704 |
+
if not size_names:
|
| 1705 |
+
flash("Для одежды необходимо указать хотя бы один размер.", 'error')
|
| 1706 |
+
return redirect(url_for('admin'))
|
| 1707 |
+
sizes = [{'name': s_name} for s_name in size_names]
|
|
|
|
|
|
|
|
|
|
| 1708 |
|
| 1709 |
|
| 1710 |
product_data = {
|
| 1711 |
'name': name,
|
| 1712 |
'description': request.form.get('description', '').strip(),
|
| 1713 |
'category': request.form.get('category'),
|
| 1714 |
+
'product_type': 'odezhda',
|
| 1715 |
'variants': variants,
|
| 1716 |
'sizes': sizes
|
| 1717 |
}
|
|
|
|
| 1815 |
settings=current_data.get('settings', {}),
|
| 1816 |
status_map_ru=STATUS_MAPS['ru'],
|
| 1817 |
repo_id=REPO_ID,
|
|
|
|
| 1818 |
currency_code=CURRENCY_CODE,
|
| 1819 |
currency_name=CURRENCY_NAME
|
| 1820 |
)
|
|
|
|
| 1827 |
threading.Thread(target=periodic_backup, daemon=True).start()
|
| 1828 |
port = int(os.environ.get('PORT', 7860))
|
| 1829 |
app.run(debug=False, host='0.0.0.0', port=port)
|
| 1830 |
+
|