Files
shop-go/internal/handlers/templates/shop_pages.html
T

209 lines
8.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{{define "cart.html"}}
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{.Title}}</title>
<link rel="stylesheet" href="/static/css/style.css">
<link rel="stylesheet" href="/static/css/shop.css">
</head>
<body>
{{template "shop_header" .}}
<main class="shop-page container">
<h1>Корзина</h1>
{{if .Items}}
<div class="cart-layout">
<div class="cart-items">
{{range .Items}}
<div class="cart-item">
<img src="{{.Product.ImageURL}}" alt="{{.Product.Name}}" class="cart-item__img">
<div class="cart-item__info">
<h3><a href="/product/{{.ProductID}}">{{.Product.Name}}</a></h3>
<div class="price-block">
{{if .Product.HasSale}}
<span class="price-block__old">{{printf "%.0f" .Product.Price}} ₽</span>
<span class="price-block__sale">{{printf "%.0f" .Product.SalePrice}} ₽</span>
{{else}}
<span class="cart-item__price">{{printf "%.0f" .Product.Price}} ₽</span>
{{end}}
</div>
</div>
<form method="POST" action="/cart/update" class="cart-item__qty">
<input type="hidden" name="product_id" value="{{.ProductID}}">
<input type="number" name="quantity" value="{{.Quantity}}" min="1" max="99">
<button type="submit" class="btn btn--ghost btn--sm">OK</button>
</form>
<form method="POST" action="/cart/remove">
<input type="hidden" name="product_id" value="{{.ProductID}}">
<button type="submit" class="btn btn--danger btn--sm">×</button>
</form>
</div>
{{end}}
</div>
<aside class="cart-summary">
<h2>Итого</h2>
<p class="cart-summary__total">{{printf "%.0f" .Total}} ₽</p>
<a href="/checkout" class="btn btn--primary btn--lg">Оформить заказ</a>
<p class="shop-hint">Регистрация не обязательна</p>
</aside>
</div>
{{else}}
<div class="shop-card shop-card--empty">
<p>Корзина пуста</p>
<a href="/" class="btn btn--primary">В каталог</a>
</div>
{{end}}
</main>
</body>
</html>
{{end}}
{{define "checkout.html"}}
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{.Title}}</title>
<link rel="stylesheet" href="/static/css/style.css">
<link rel="stylesheet" href="/static/css/shop.css">
</head>
<body>
{{template "shop_header" .}}
<main class="shop-page container">
<h1>Оформление заказа</h1>
{{if .Error}}<div class="shop-alert shop-alert--error">{{.Error}}</div>{{end}}
<div class="checkout-layout">
<form method="POST" action="/checkout" class="shop-card shop-form">
<h2>Данные для доставки</h2>
{{if .User}}
<p class="shop-hint">Вы вошли как {{.User.Email}}. Данные подставлены из профиля.</p>
{{else}}
<p class="shop-hint">Покупка без регистрации — укажите контакты для доставки.</p>
{{end}}
<label>Имя<input type="text" name="name" value="{{.Name}}" required></label>
<label>Email<input type="email" name="email" value="{{.Email}}" required></label>
<label>Телефон<input type="tel" name="phone" value="{{.Phone}}" required></label>
<label>Адрес доставки<textarea name="address" rows="3" required>{{.Address}}</textarea></label>
<button type="submit" class="btn btn--primary btn--lg">Подтвердить заказ</button>
</form>
<aside class="cart-summary">
<h2>Ваш заказ</h2>
{{range .Items}}
<div class="checkout-item">
<span>{{.Product.Name}} × {{.Quantity}}</span>
<span>{{printf "%.0f" .Product.Price}} ₽</span>
</div>
{{end}}
<p class="cart-summary__total">Итого: {{printf "%.0f" .Total}} ₽</p>
</aside>
</div>
</main>
</body>
</html>
{{end}}
{{define "order_success.html"}}
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{.Title}}</title>
<link rel="stylesheet" href="/static/css/style.css">
<link rel="stylesheet" href="/static/css/shop.css">
</head>
<body>
{{template "shop_header" .}}
<main class="shop-page container">
<div class="shop-card shop-card--success">
<h1>✓ Заказ оформлен!</h1>
<p>{{.Success}}</p>
<p class="shop-hint">Мы свяжемся с вами для подтверждения доставки.</p>
<div class="shop-actions">
<a href="/" class="btn btn--primary">На главную</a>
{{if .User}}<a href="/account" class="btn btn--outline">Мои заказы</a>{{end}}
</div>
</div>
</main>
</body>
</html>
{{end}}
{{define "account.html"}}
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{.Title}}</title>
<link rel="stylesheet" href="/static/css/style.css">
<link rel="stylesheet" href="/static/css/shop.css">
</head>
<body>
{{template "shop_header" .}}
<main class="shop-page container">
<div class="account-header">
<h1>Личный кабинет</h1>
<form method="POST" action="/logout">
<button type="submit" class="btn btn--ghost">Выйти</button>
</form>
</div>
{{if .Success}}<div class="shop-alert shop-alert--ok">{{.Success}}</div>{{end}}
<div class="account-layout">
<section class="shop-card">
<h2>Профиль</h2>
<p class="shop-hint">Email: {{.User.Email}}</p>
<form method="POST" action="/account" class="shop-form">
<label>Имя<input type="text" name="name" value="{{.Name}}" required></label>
<label>Телефон<input type="tel" name="phone" value="{{.Phone}}"></label>
<label>Адрес<textarea name="address" rows="2">{{.Address}}</textarea></label>
<button type="submit" class="btn btn--primary">Сохранить</button>
</form>
</section>
<section class="shop-card">
<h2>Мои заказы</h2>
{{if .Orders}}
{{range .Orders}}
<div class="order-card">
<div class="order-card__head">
<div>
<strong>Заказ #{{.ID}}</strong>
<span class="order-card__date">{{.CreatedAt.Format "02.01.2006 15:04"}}</span>
</div>
<span class="order-status {{orderClass .Status}}">{{orderLabel .Status}}</span>
</div>
{{if not (orderTerminal .Status)}}
<div class="order-timeline">
{{range orderTimeline}}
<div class="order-timeline__step {{if stepCurrent $.Status .}}order-timeline__step--current{{end}} {{if stepDone $.Status .}}order-timeline__step--done{{end}}">
<span class="order-timeline__dot"></span>
<span class="order-timeline__label">{{orderLabel .}}</span>
</div>
{{end}}
</div>
{{end}}
<ul class="order-card__items">
{{range .Items}}
<li>{{.ProductName}} × {{.Quantity}} — {{printf "%.0f" .Price}} ₽</li>
{{end}}
</ul>
<p class="order-card__total">Итого: {{printf "%.0f" .Total}} ₽</p>
</div>
{{end}}
{{else}}
<p class="shop-hint">Заказов пока нет. <a href="/">Перейти в каталог</a></p>
{{end}}
</section>
</div>
</main>
</body>
</html>
{{end}}