Compare commits
43 Commits
52d75a0af8
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e476e36855 | ||
|
|
69a8138226 | ||
|
|
b6f81a12ea | ||
|
|
28316b58ab | ||
|
|
2c593a53a1 | ||
|
|
fe1487a1f5 | ||
|
|
26c82eca08 | ||
|
|
217adaba63 | ||
|
|
083da573e0 | ||
|
|
e212712cac | ||
|
|
e5bc6cfbc0 | ||
|
|
dc74a416d0 | ||
|
|
bfd3b54154 | ||
|
|
31de50c40a | ||
|
|
acce73329a | ||
|
|
8e6a4db0ad | ||
|
|
1dad6cc160 | ||
|
|
89fd7a2f46 | ||
|
|
f583062d54 | ||
|
|
257fd7481a | ||
|
|
1506bfcf09 | ||
|
|
b3a5f42980 | ||
|
|
66489a918f | ||
|
|
4dcec14dac | ||
|
|
7e77301838 | ||
|
|
2ad874af33 | ||
|
|
ec94b0320d | ||
|
|
2d1ee8338e | ||
|
|
ce3fa4f689 | ||
|
|
2a2baba4a4 | ||
|
|
83488e97a9 | ||
|
|
fcaf17eacd | ||
|
|
59c47f2b03 | ||
|
|
1a8a3ee563 | ||
|
|
962aad7c86 | ||
|
|
1d546191c1 | ||
|
|
e4550576df | ||
|
|
8a787d5582 | ||
|
|
3a60f670ba | ||
|
|
7e2d20d889 | ||
|
|
312192a6d6 | ||
|
|
2c3d52299c | ||
|
|
1a66b745da |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -414,3 +414,5 @@ FodyWeavers.xsd
|
||||
# Built Visual Studio Code Extensions
|
||||
*.vsix
|
||||
|
||||
/Web-Jarmark/Web-Jarmark/jarmark.db-shm
|
||||
/Web-Jarmark/Web-Jarmark/jarmark.db-wal
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
if (result.Succeeded)
|
||||
{
|
||||
Logger.LogInformation("User logged in.");
|
||||
RedirectManager.RedirectTo(ReturnUrl);
|
||||
RedirectManager.RedirectTo(string.IsNullOrWhiteSpace(ReturnUrl) ? "admin" : ReturnUrl);
|
||||
}
|
||||
else if (result.RequiresTwoFactor)
|
||||
{
|
||||
|
||||
@@ -6,37 +6,21 @@
|
||||
@inject UserManager<ApplicationUser> UserManager
|
||||
@inject IdentityRedirectManager RedirectManager
|
||||
|
||||
<PageTitle>Personal Data</PageTitle>
|
||||
<PageTitle>Osobní údaje</PageTitle>
|
||||
|
||||
<StatusMessage />
|
||||
<h3>Personal Data</h3>
|
||||
<h3>Osobní údaje</h3>
|
||||
<p>
|
||||
V účtu jsou uložené osobní údaje, které jsi zadal. Tady si je můžeš stáhnout nebo účet smazat.
|
||||
</p>
|
||||
<p>
|
||||
<strong>Smazání údajů trvale odstraní účet a nelze to vrátit zpět.</strong>
|
||||
</p>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<p>Your account contains personal data that you have given us. This page allows you to download or delete that data.</p>
|
||||
<p>
|
||||
<strong>Deleting this data will permanently remove your account, and this cannot be recovered.</strong>
|
||||
</p>
|
||||
<form action="Account/Manage/DownloadPersonalData" method="post">
|
||||
<AntiforgeryToken />
|
||||
<button class="btn btn-primary" type="submit">Download</button>
|
||||
</form>
|
||||
<p>
|
||||
<a href="Account/Manage/DeletePersonalData" class="btn btn-danger">Delete</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="manage-actions">
|
||||
<form method="post" action="Account/Manage/DownloadPersonalData">
|
||||
<AntiforgeryToken />
|
||||
<button type="submit" class="btn btn-primary">Stáhnout data</button>
|
||||
</form>
|
||||
|
||||
@code {
|
||||
[CascadingParameter]
|
||||
private HttpContext HttpContext { get; set; } = default!;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var user = await UserManager.GetUserAsync(HttpContext.User);
|
||||
if (user is null)
|
||||
{
|
||||
RedirectManager.RedirectToInvalidUser(UserManager, HttpContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
<a class="btn btn-primary" href="Account/Manage/DeletePersonalData">Smazat účet</a>
|
||||
</div>
|
||||
@@ -1,17 +1,23 @@
|
||||
@inherits LayoutComponentBase
|
||||
@layout Web_Jarmark.Components.Layout.MainLayout
|
||||
@layout Web_Jarmark.Components.Layout.Admin.AdminLayout
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
|
||||
<h1>Manage your account</h1>
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
|
||||
<div>
|
||||
<h2>Change your account settings</h2>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-lg-3">
|
||||
<div class="ap ao manage-shell">
|
||||
<header class="ao-hero">
|
||||
<p class="ao-eyebrow">Účet</p>
|
||||
<h1>Správa účtu</h1>
|
||||
<p class="ao-sub">Profil, heslo a zabezpečení.</p>
|
||||
</header>
|
||||
|
||||
<div class="manage-grid">
|
||||
<aside class="manage-nav-card">
|
||||
<p class="manage-nav-title">Nastavení</p>
|
||||
<ManageNavMenu />
|
||||
</div>
|
||||
<div class="col-lg-9">
|
||||
</aside>
|
||||
<section class="manage-content-card">
|
||||
@Body
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,34 +1,23 @@
|
||||
@using Microsoft.AspNetCore.Identity
|
||||
@using Web_Jarmark.Data
|
||||
|
||||
@inject SignInManager<ApplicationUser> SignInManager
|
||||
|
||||
<ul class="nav nav-pills flex-column">
|
||||
<li class="nav-item">
|
||||
<NavLink class="nav-link" href="Account/Manage" Match="NavLinkMatch.All">Profile</NavLink>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<NavLink class="nav-link" href="Account/Manage/Email">Email</NavLink>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<NavLink class="nav-link" href="Account/Manage/ChangePassword">Password</NavLink>
|
||||
</li>
|
||||
<nav class="manage-nav">
|
||||
<NavLink class="manage-nav-link" href="Account/Manage" Match="NavLinkMatch.All">Profil</NavLink>
|
||||
<NavLink class="manage-nav-link" href="Account/Manage/Email">E-mail</NavLink>
|
||||
<NavLink class="manage-nav-link" href="Account/Manage/ChangePassword">Heslo</NavLink>
|
||||
|
||||
@if (hasExternalLogins)
|
||||
{
|
||||
<li class="nav-item">
|
||||
<NavLink class="nav-link" href="Account/Manage/ExternalLogins">External logins</NavLink>
|
||||
</li>
|
||||
<NavLink class="manage-nav-link" href="Account/Manage/ExternalLogins">Externí přihlášení</NavLink>
|
||||
}
|
||||
<li class="nav-item">
|
||||
<NavLink class="nav-link" href="Account/Manage/TwoFactorAuthentication">Two-factor authentication</NavLink>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<NavLink class="nav-link" href="Account/Manage/Passkeys">Passkeys</NavLink>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<NavLink class="nav-link" href="Account/Manage/PersonalData">Personal data</NavLink>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<NavLink class="manage-nav-link" href="Account/Manage/TwoFactorAuthentication">2FA</NavLink>
|
||||
<NavLink class="manage-nav-link" href="Account/Manage/Passkeys">Passkeys</NavLink>
|
||||
<NavLink class="manage-nav-link" href="Account/Manage/PersonalData">Osobní údaje</NavLink>
|
||||
|
||||
<a class="manage-nav-link manage-nav-back" href="/admin">← Admin</a>
|
||||
</nav>
|
||||
|
||||
@code {
|
||||
private bool hasExternalLogins;
|
||||
@@ -37,4 +26,4 @@
|
||||
{
|
||||
hasExternalLogins = (await SignInManager.GetExternalAuthenticationSchemesAsync()).Any();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,89 @@
|
||||
@inherits LayoutComponentBase
|
||||
@implements IDisposable
|
||||
@inject NavigationManager Nav
|
||||
|
||||
<div class="wj-dashboard">
|
||||
<div class="admin-shell @(collapsed ? "is-collapsed" : null)">
|
||||
<aside class="admin-sidebar">
|
||||
<div class="admin-sidebar-head">
|
||||
<a href="/admin" class="admin-logo">
|
||||
<span class="admin-logo-mark">W</span>
|
||||
<span class="admin-logo-text">Web-Jarmark</span>
|
||||
</a>
|
||||
|
||||
<AdminNavMenu />
|
||||
<button type="button"
|
||||
class="admin-toggle"
|
||||
title="@(collapsed ? "Rozbalit" : "Sbalit")"
|
||||
@onclick="Toggle">
|
||||
☰
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<main class="wj-main">
|
||||
<AdminNavMenu />
|
||||
|
||||
<header class="wj-topbar">
|
||||
<div class="wj-topbar-label">ADMINISTRACE</div>
|
||||
<div class="wj-topbar-right">
|
||||
<span class="wj-status-dot"></span>
|
||||
<div class="admin-sidebar-foot">
|
||||
<div class="admin-foot-card">
|
||||
<span class="admin-logo-mark small">W</span>
|
||||
<div class="admin-foot-text">
|
||||
<strong>Web-Jarmark</strong>
|
||||
<small>Administrace</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<div class="admin-main">
|
||||
<header class="admin-topbar">
|
||||
<div class="admin-topbar-title">@SectionTitle</div>
|
||||
<div class="admin-topbar-user">
|
||||
<span class="admin-dot"></span>
|
||||
<span>Administrátor</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="wj-content">
|
||||
<main class="admin-content">
|
||||
@Body
|
||||
</section>
|
||||
|
||||
</main>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private bool collapsed;
|
||||
private string SectionTitle = "Přehled";
|
||||
|
||||
private void Toggle() => collapsed = !collapsed;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
UpdateTitle();
|
||||
Nav.LocationChanged += OnLocationChanged;
|
||||
}
|
||||
|
||||
private void OnLocationChanged(object? sender, LocationChangedEventArgs e)
|
||||
{
|
||||
UpdateTitle();
|
||||
_ = InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private void UpdateTitle()
|
||||
{
|
||||
var path = "/" + Nav.ToBaseRelativePath(Nav.Uri).Split('?', '#')[0].Trim('/');
|
||||
|
||||
SectionTitle = path switch
|
||||
{
|
||||
"/admin" => "Přehled",
|
||||
var p when p.StartsWith("/admin/kategorie") => "Kategorie",
|
||||
var p when p.StartsWith("/admin/zbozi") => "Zboží",
|
||||
var p when p.StartsWith("/admin/objednavky") => "Objednávky",
|
||||
var p when p.StartsWith("/admin/administratori") => "Administrátoři",
|
||||
var p when p.StartsWith("/admin/sklad") => "Sklad",
|
||||
var p when p.StartsWith("/admin/statistiky") => "Statistiky",
|
||||
var p when p.StartsWith("/admin/nastaveni") => "Nastavení",
|
||||
_ => "Administrace"
|
||||
};
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Nav.LocationChanged -= OnLocationChanged;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +1,279 @@
|
||||
```css
|
||||
/* Administrátorské rozložení */
|
||||
.wj-dashboard {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
/* Apple-like admin – plovoucí, hodně zaoblené */
|
||||
|
||||
.admin-shell {
|
||||
--bg: #f5f5f7;
|
||||
--ink: #1d1d1f;
|
||||
--muted: #6e6e73;
|
||||
--line: rgba(0, 0, 0, 0.06);
|
||||
--sidebar-w: 280px;
|
||||
--sidebar-w-collapsed: 92px;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow-x: hidden;
|
||||
background: #f8f8f8;
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
padding: 14px;
|
||||
box-sizing: border-box;
|
||||
background: var(--bg);
|
||||
color: var(--ink);
|
||||
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
.wj-main {
|
||||
/* ===== SIDEBAR CARD ===== */
|
||||
.admin-sidebar {
|
||||
width: var(--sidebar-w);
|
||||
flex-shrink: 0;
|
||||
position: sticky;
|
||||
top: 14px;
|
||||
height: calc(100vh - 28px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: rgba(255, 255, 255, 0.86);
|
||||
border: 1px solid rgba(0, 0, 0, 0.04);
|
||||
border-radius: 28px;
|
||||
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
|
||||
backdrop-filter: blur(18px);
|
||||
overflow: hidden;
|
||||
transition: width 0.3s cubic-bezier(0.22, 1, 0.36, 1);
|
||||
}
|
||||
|
||||
.admin-shell.is-collapsed .admin-sidebar {
|
||||
width: var(--sidebar-w-collapsed);
|
||||
}
|
||||
|
||||
.admin-sidebar-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
padding: 18px 16px 12px;
|
||||
}
|
||||
|
||||
.admin-logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
text-decoration: none;
|
||||
color: var(--ink);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.admin-logo-mark {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 14px;
|
||||
background: #1d1d1f;
|
||||
color: #fff;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
font-weight: 800;
|
||||
font-size: 15px;
|
||||
flex-shrink: 0;
|
||||
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.admin-logo-mark.small {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 11px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin-logo-text {
|
||||
font-weight: 700;
|
||||
font-size: 16px;
|
||||
letter-spacing: -0.03em;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.admin-toggle {
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
border: 0;
|
||||
border-radius: 13px;
|
||||
background: #f0f0f2;
|
||||
color: var(--ink);
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition: background 0.2s ease, transform 0.15s ease;
|
||||
}
|
||||
|
||||
.admin-toggle:hover {
|
||||
background: #e6e6ea;
|
||||
transform: scale(1.03);
|
||||
}
|
||||
|
||||
/* NAV */
|
||||
::deep .admin-nav {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
padding: 8px 12px 12px;
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
::deep .admin-nav-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 13px 14px;
|
||||
border-radius: 16px;
|
||||
text-decoration: none;
|
||||
color: var(--muted);
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
letter-spacing: -0.01em;
|
||||
transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
::deep .admin-nav-link:hover {
|
||||
background: rgba(0, 0, 0, 0.04);
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
::deep .admin-nav-link.active {
|
||||
background: #1d1d1f;
|
||||
color: #fff;
|
||||
box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
|
||||
}
|
||||
|
||||
::deep .admin-nav-ico {
|
||||
width: 22px;
|
||||
text-align: center;
|
||||
flex-shrink: 0;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
::deep .admin-nav-label {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* FOOT */
|
||||
.admin-sidebar-foot {
|
||||
padding: 10px 12px 14px;
|
||||
}
|
||||
|
||||
.admin-foot-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 12px;
|
||||
border-radius: 18px;
|
||||
background: #f5f5f7;
|
||||
}
|
||||
|
||||
.admin-foot-text {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.admin-foot-text strong {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.admin-foot-text small {
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
/* ===== MAIN CARD ===== */
|
||||
.admin-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: rgba(255, 255, 255, 0.72);
|
||||
border: 1px solid rgba(0, 0, 0, 0.04);
|
||||
border-radius: 28px;
|
||||
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.04);
|
||||
backdrop-filter: blur(18px);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.admin-topbar {
|
||||
height: 68px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 0 28px;
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
|
||||
background: rgba(255, 255, 255, 0.55);
|
||||
}
|
||||
|
||||
.admin-topbar-title {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.03em;
|
||||
}
|
||||
|
||||
.admin-topbar-user {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
border-radius: 999px;
|
||||
background: #f5f5f7;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.admin-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: #1d1d1f;
|
||||
}
|
||||
|
||||
.admin-content {
|
||||
padding: 22px 28px 36px;
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/* Collapsed */
|
||||
.admin-shell.is-collapsed .admin-logo-text,
|
||||
.admin-shell.is-collapsed ::deep .admin-nav-label,
|
||||
.admin-shell.is-collapsed .admin-foot-text {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.admin-shell.is-collapsed ::deep .admin-nav-link {
|
||||
justify-content: center;
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.admin-shell.is-collapsed .admin-sidebar-head {
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.wj-content {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 28px 32px;
|
||||
box-sizing: border-box;
|
||||
.admin-shell.is-collapsed .admin-foot-card {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* Plynulé přechody */
|
||||
.wj-main,
|
||||
.wj-content {
|
||||
transition: all 0.25s ease;
|
||||
.admin-shell.is-collapsed .admin-logo {
|
||||
justify-content: center;
|
||||
}
|
||||
/* SVG ikony v menu */
|
||||
::deep .admin-nav-ico {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Menší obrazovky */
|
||||
@media (max-width: 768px) {
|
||||
.wj-content {
|
||||
padding: 20px 16px;
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
::deep .admin-nav-ico svg {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
display: block;
|
||||
}
|
||||
@@ -1,62 +1,96 @@
|
||||
@implements IDisposable
|
||||
@inject NavigationManager Nav
|
||||
|
||||
<aside class="wj-sidebar">
|
||||
<a href="/admin" class="wj-brand">
|
||||
<span class="wj-brand-icon">W</span>
|
||||
<span>Web-Jarmark</span>
|
||||
<nav class="admin-nav">
|
||||
<a href="/" class="admin-nav-link">
|
||||
<span class="admin-nav-ico" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M15 18 9 12l6-6" />
|
||||
</svg>
|
||||
</span>
|
||||
<span class="admin-nav-label">E-shop</span>
|
||||
</a>
|
||||
|
||||
<nav class="wj-nav">
|
||||
<a href="/admin"
|
||||
class="wj-nav-link @(IsCurrent("/admin", true) ? "active" : "")">
|
||||
<span>⌂</span> Přehled
|
||||
</a>
|
||||
<a href="/admin" class="admin-nav-link @(IsCurrent("/admin", true) ? "active" : null)">
|
||||
<span class="admin-nav-ico" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M4 10.5 12 4l8 6.5V20a1 1 0 0 1-1 1h-5v-6H10v6H5a1 1 0 0 1-1-1v-9.5Z" />
|
||||
</svg>
|
||||
</span>
|
||||
<span class="admin-nav-label">Přehled</span>
|
||||
</a>
|
||||
|
||||
<a href="/admin/kategorie"
|
||||
class="wj-nav-link @(IsCurrent("/admin/kategorie") ? "active" : "")">
|
||||
<span>▤</span> Kategorie
|
||||
</a>
|
||||
<a href="/admin/kategorie" class="admin-nav-link @(IsCurrent("/admin/kategorie") ? "active" : null)">
|
||||
<span class="admin-nav-ico" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
||||
<rect x="4" y="4" width="7" height="7" rx="1.5" />
|
||||
<rect x="13" y="4" width="7" height="7" rx="1.5" />
|
||||
<rect x="4" y="13" width="7" height="7" rx="1.5" />
|
||||
<rect x="13" y="13" width="7" height="7" rx="1.5" />
|
||||
</svg>
|
||||
</span>
|
||||
<span class="admin-nav-label">Kategorie</span>
|
||||
</a>
|
||||
|
||||
<a href="/admin/zbozi"
|
||||
class="wj-nav-link @(IsCurrent("/admin/zbozi") ? "active" : "")">
|
||||
<span>◇</span> Zboží
|
||||
</a>
|
||||
<a href="/admin/zbozi" class="admin-nav-link @(IsCurrent("/admin/zbozi") ? "active" : null)">
|
||||
<span class="admin-nav-ico" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M7 7h10l1.2 12.2a1.5 1.5 0 0 1-1.5 1.6H7.3a1.5 1.5 0 0 1-1.5-1.6L7 7Z" />
|
||||
<path d="M9 7a3 3 0 0 1 6 0" />
|
||||
</svg>
|
||||
</span>
|
||||
<span class="admin-nav-label">Zboží</span>
|
||||
</a>
|
||||
|
||||
<a href="/admin/objednavky"
|
||||
class="wj-nav-link @(IsCurrent("/admin/objednavky") ? "active" : "")">
|
||||
<span>▣</span> Objednávky
|
||||
</a>
|
||||
<a href="/admin/objednavky" class="admin-nav-link @(IsCurrent("/admin/objednavky") ? "active" : null)">
|
||||
<span class="admin-nav-ico" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M7 4h10a2 2 0 0 1 2 2v14l-3-2-3 2-3-2-3 2V6a2 2 0 0 1 2-2Z" />
|
||||
<path d="M9 9h6M9 13h6" />
|
||||
</svg>
|
||||
</span>
|
||||
<span class="admin-nav-label">Objednávky</span>
|
||||
</a>
|
||||
|
||||
<a href="/admin/zakaznici"
|
||||
class="wj-nav-link @(IsCurrent("/admin/zakaznici") ? "active" : "")">
|
||||
<span>♙</span> Zákazníci
|
||||
</a>
|
||||
<a href="/admin/administratori" class="admin-nav-link @(IsCurrent("/admin/administratori") ? "active" : null)">
|
||||
<span class="admin-nav-ico" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
||||
<circle cx="12" cy="8" r="3.5" />
|
||||
<path d="M5.5 19a6.5 6.5 0 0 1 13 0" />
|
||||
</svg>
|
||||
</span>
|
||||
<span class="admin-nav-label">Administrátoři</span>
|
||||
</a>
|
||||
|
||||
<a href="/admin/sklad"
|
||||
class="wj-nav-link @(IsCurrent("/admin/sklad") ? "active" : "")">
|
||||
<span>▥</span> Sklad
|
||||
</a>
|
||||
<a href="/admin/sklad" class="admin-nav-link @(IsCurrent("/admin/sklad") ? "active" : null)">
|
||||
<span class="admin-nav-ico" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M4 8.5 12 4l8 4.5V19a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V8.5Z" />
|
||||
<path d="M12 12v8M8 10.5 12 12l4-1.5" />
|
||||
</svg>
|
||||
</span>
|
||||
<span class="admin-nav-label">Sklad</span>
|
||||
</a>
|
||||
|
||||
<a href="/admin/statistiky"
|
||||
class="wj-nav-link @(IsCurrent("/admin/statistiky") ? "active" : "")">
|
||||
<span>▤</span> Statistiky
|
||||
</a>
|
||||
<a href="/admin/statistiky" class="admin-nav-link @(IsCurrent("/admin/statistiky") ? "active" : null)">
|
||||
<span class="admin-nav-ico" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M5 19V11M12 19V5M19 19v-7" />
|
||||
</svg>
|
||||
</span>
|
||||
<span class="admin-nav-label">Statistiky</span>
|
||||
</a>
|
||||
|
||||
<a href="/admin/nastaveni"
|
||||
class="wj-nav-link @(IsCurrent("/admin/nastaveni") ? "active" : "")">
|
||||
<span>⚙</span> Nastavení
|
||||
</a>
|
||||
</nav>
|
||||
|
||||
<div class="wj-sidebar-bottom">
|
||||
<div class="wj-sidebar-mark">W</div>
|
||||
<div>
|
||||
<strong>Web-Jarmark</strong>
|
||||
<small>E-shop s domácími produkty</small>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
<a href="/admin/nastaveni" class="admin-nav-link @(IsCurrent("/admin/nastaveni") ? "active" : null)">
|
||||
<span class="admin-nav-ico" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
<path d="M12 3.5v2.2M12 18.3v2.2M4.9 6.4l1.6 1.6M17.5 16l1.6 1.6M3.5 12h2.2M18.3 12h2.2M4.9 17.6l1.6-1.6M17.5 8l1.6-1.6" />
|
||||
</svg>
|
||||
</span>
|
||||
<span class="admin-nav-label">Nastavení</span>
|
||||
</a>
|
||||
</nav>
|
||||
|
||||
@code {
|
||||
private string CurrentPath => "/" +
|
||||
@@ -90,5 +124,4 @@
|
||||
{
|
||||
Nav.LocationChanged -= HandleLocationChanged;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +1,41 @@
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
<div class="page">
|
||||
<div class="sidebar">
|
||||
<div class="page public-layout">
|
||||
|
||||
<a href="#public-main-content"
|
||||
class="public-skip-link visually-hidden-focusable">
|
||||
Přeskočit na hlavní obsah
|
||||
</a>
|
||||
|
||||
<header class="sidebar public-header">
|
||||
<NavMenu />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<div class="top-row px-4">
|
||||
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
|
||||
</div>
|
||||
<main id="public-main-content"
|
||||
class="main-content public-main"
|
||||
tabindex="-1">
|
||||
|
||||
<article class="content px-4">
|
||||
<article class="content public-container">
|
||||
@Body
|
||||
</article>
|
||||
|
||||
</main>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="blazor-error-ui" data-nosnippet>
|
||||
An unhandled error has occurred.
|
||||
<a href="." class="reload">Reload</a>
|
||||
<span class="dismiss">🗙</span>
|
||||
<span role="alert">
|
||||
Nastala neočekávaná chyba.
|
||||
</span>
|
||||
|
||||
<a href="." class="reload">
|
||||
Obnovit stránku
|
||||
</a>
|
||||
|
||||
<button type="button"
|
||||
class="dismiss"
|
||||
aria-label="Zavřít chybové hlášení"
|
||||
style="background: none; border: none; color: inherit;">
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -1,98 +1,406 @@
|
||||
.page {
|
||||
|
||||
/* ========================================
|
||||
SKOLNI JARMARK - PUBLIC LAYOUT
|
||||
======================================== */
|
||||
|
||||
.page.public-layout {
|
||||
--public-primary: #244b36;
|
||||
--public-primary-hover: #193b29;
|
||||
--public-secondary: #e6eddf;
|
||||
--public-background: #f7f7f2;
|
||||
--public-surface: #ffffff;
|
||||
--public-text: #26372b;
|
||||
--public-muted: #59665b;
|
||||
--public-border: #dce3d9;
|
||||
--public-radius-sm: 4px;
|
||||
--public-radius-md: 8px;
|
||||
--public-radius-lg: 12px;
|
||||
--public-space-1: 4px;
|
||||
--public-space-2: 8px;
|
||||
--public-space-3: 12px;
|
||||
--public-space-4: 16px;
|
||||
--public-space-5: 20px;
|
||||
--public-space-6: 24px;
|
||||
--public-space-8: 32px;
|
||||
--public-space-12: 48px;
|
||||
--public-space-16: 64px;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
min-height: 100vh;
|
||||
min-height: 100dvh;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: var(--public-background);
|
||||
color: var(--public-text);
|
||||
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
|
||||
font-size: 16px;
|
||||
line-height: 1.6;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
main {
|
||||
flex: 1;
|
||||
|
||||
/* ========================================
|
||||
BOX SIZING
|
||||
======================================== */
|
||||
|
||||
.public-layout,
|
||||
.public-layout ::deep *,
|
||||
.public-layout ::deep *::before,
|
||||
.public-layout ::deep *::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
|
||||
}
|
||||
|
||||
.top-row {
|
||||
background-color: #f7f7f7;
|
||||
border-bottom: 1px solid #d6d5d5;
|
||||
justify-content: flex-end;
|
||||
height: 3.5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
/* ========================================
|
||||
PUBLIC HEADER - OVERLAP FIX
|
||||
======================================== */
|
||||
|
||||
.top-row ::deep a, .top-row ::deep .btn-link {
|
||||
white-space: nowrap;
|
||||
margin-left: 1.5rem;
|
||||
text-decoration: none;
|
||||
.public-layout > .sidebar.public-header {
|
||||
position: relative !important;
|
||||
top: auto !important;
|
||||
right: auto !important;
|
||||
bottom: auto !important;
|
||||
left: auto !important;
|
||||
display: block;
|
||||
flex: 0 0 auto;
|
||||
align-self: stretch;
|
||||
width: 100% !important;
|
||||
min-width: 0 !important;
|
||||
max-width: 100%;
|
||||
height: auto !important;
|
||||
min-height: 0 !important;
|
||||
max-height: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: var(--public-surface);
|
||||
border-right: none !important;
|
||||
border-bottom: 1px solid var(--public-border);
|
||||
transform: none;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
|
||||
|
||||
/* ========================================
|
||||
NAVIGATION CONTAINER
|
||||
======================================== */
|
||||
|
||||
.public-header ::deep .nav-panel {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
height: auto;
|
||||
min-height: 68px;
|
||||
max-height: none;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.public-header ::deep .nav-scrollable {
|
||||
position: static;
|
||||
height: auto;
|
||||
min-height: 0;
|
||||
max-height: none;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
MAIN CONTENT - OVERLAP FIX
|
||||
======================================== */
|
||||
|
||||
.public-layout > .main-content.public-main {
|
||||
position: relative !important;
|
||||
top: auto;
|
||||
left: auto;
|
||||
right: auto;
|
||||
bottom: auto;
|
||||
display: block;
|
||||
flex: 1 0 auto;
|
||||
width: 100% !important;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
min-height: 0;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
background: var(--public-background);
|
||||
transform: none;
|
||||
scroll-margin-top: 16px;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
CONTENT CONTAINER
|
||||
======================================== */
|
||||
|
||||
.public-main > .content.public-container {
|
||||
position: relative;
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-width: 1440px;
|
||||
min-width: 0;
|
||||
margin: 0 auto !important;
|
||||
padding: 32px 32px 64px !important;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
TYPOGRAPHY
|
||||
======================================== */
|
||||
|
||||
.public-container ::deep h1,
|
||||
.public-container ::deep h2,
|
||||
.public-container ::deep h3 {
|
||||
color: var(--public-text);
|
||||
font-family: Georgia, "Times New Roman", serif;
|
||||
font-weight: 700;
|
||||
line-height: 1.2;
|
||||
letter-spacing: normal;
|
||||
}
|
||||
|
||||
.public-container ::deep h1 {
|
||||
font-size: clamp(28px, 4vw, 44px);
|
||||
}
|
||||
|
||||
.public-container ::deep h2 {
|
||||
font-size: clamp(24px, 3vw, 32px);
|
||||
}
|
||||
|
||||
.public-container ::deep h3 {
|
||||
font-size: clamp(18px, 2vw, 24px);
|
||||
}
|
||||
|
||||
.public-container ::deep p {
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
LINKS
|
||||
======================================== */
|
||||
|
||||
.public-container ::deep a {
|
||||
text-underline-offset: 3px;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
KEYBOARD ACCESSIBILITY
|
||||
======================================== */
|
||||
|
||||
.public-layout ::deep a:focus-visible,
|
||||
.public-layout ::deep button:focus-visible,
|
||||
.public-layout ::deep input:focus-visible,
|
||||
.public-layout ::deep select:focus-visible,
|
||||
.public-layout ::deep textarea:focus-visible,
|
||||
.public-layout ::deep [tabindex]:focus-visible {
|
||||
outline: 3px solid #527b49;
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
.public-main:focus-visible {
|
||||
outline: 3px solid #527b49;
|
||||
outline-offset: -3px;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
SKIP NAVIGATION LINK
|
||||
======================================== */
|
||||
|
||||
.public-skip-link {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
left: 12px;
|
||||
z-index: 1100;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.public-skip-link:focus {
|
||||
width: auto;
|
||||
height: auto;
|
||||
padding: 12px 16px;
|
||||
overflow: visible;
|
||||
clip-path: none;
|
||||
background: var(--public-primary);
|
||||
color: #ffffff;
|
||||
border-radius: var(--public-radius-md);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
text-decoration: none;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
BLAZOR ERROR MESSAGE
|
||||
======================================== */
|
||||
|
||||
#blazor-error-ui {
|
||||
display: none;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 1000;
|
||||
width: 100%;
|
||||
padding: 16px 56px 16px 24px;
|
||||
background: #fff4d6;
|
||||
color: #58451b;
|
||||
border-top: 1px solid #e5d4a1;
|
||||
box-sizing: border-box;
|
||||
color-scheme: light;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
#blazor-error-ui .reload {
|
||||
display: inline-block;
|
||||
margin-left: 8px;
|
||||
color: #244b36;
|
||||
font-weight: 700;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.top-row ::deep a:first-child {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
@media (max-width: 640.98px) {
|
||||
.top-row {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.top-row ::deep a, .top-row ::deep .btn-link {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 641px) {
|
||||
.page {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
width: 250px;
|
||||
height: 100vh;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.top-row {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.top-row.auth ::deep a:first-child {
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.top-row, article {
|
||||
padding-left: 2rem !important;
|
||||
padding-right: 1.5rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
#blazor-error-ui {
|
||||
color-scheme: light only;
|
||||
background: lightyellow;
|
||||
bottom: 0;
|
||||
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
|
||||
box-sizing: border-box;
|
||||
display: none;
|
||||
left: 0;
|
||||
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
#blazor-error-ui .dismiss {
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
right: 0.75rem;
|
||||
top: 0.5rem;
|
||||
top: 50%;
|
||||
right: 8px;
|
||||
transform: translateY(-50%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
color: #58451b;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
font-size: 24px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#blazor-error-ui .dismiss:focus-visible,
|
||||
#blazor-error-ui .reload:focus-visible {
|
||||
outline: 3px solid #527b49;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
TABLET - MAX 1024 PX
|
||||
======================================== */
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
|
||||
.public-main > .content.public-container {
|
||||
padding: 24px 24px 48px !important;
|
||||
}
|
||||
|
||||
.public-layout > .sidebar.public-header {
|
||||
position: relative !important;
|
||||
width: 100% !important;
|
||||
height: auto !important;
|
||||
min-height: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
MOBILE - MAX 640 PX
|
||||
======================================== */
|
||||
|
||||
@media (max-width: 640px) {
|
||||
|
||||
.page.public-layout {
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.public-layout > .sidebar.public-header {
|
||||
position: relative !important;
|
||||
top: auto !important;
|
||||
width: 100% !important;
|
||||
min-width: 0 !important;
|
||||
height: auto !important;
|
||||
min-height: 0 !important;
|
||||
}
|
||||
|
||||
.public-layout > .main-content.public-main {
|
||||
width: 100% !important;
|
||||
min-width: 0;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.public-main > .content.public-container {
|
||||
width: 100%;
|
||||
padding: 16px 16px 32px !important;
|
||||
}
|
||||
|
||||
.public-container ::deep h1 {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.public-container ::deep h2 {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.public-container ::deep h3 {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
#blazor-error-ui {
|
||||
padding: 12px 56px 12px 16px;
|
||||
}
|
||||
|
||||
#blazor-error-ui .reload {
|
||||
margin-left: 0;
|
||||
margin-top: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
SMALL MOBILE - MAX 360 PX
|
||||
======================================== */
|
||||
|
||||
@media (max-width: 360px) {
|
||||
|
||||
.public-main > .content.public-container {
|
||||
padding: 12px 12px 24px !important;
|
||||
}
|
||||
|
||||
.public-container ::deep h1 {
|
||||
font-size: 26px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
REDUCED MOTION
|
||||
======================================== */
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
|
||||
.public-layout,
|
||||
.public-layout ::deep *,
|
||||
.public-layout ::deep *::before,
|
||||
.public-layout ::deep *::after {
|
||||
scroll-behavior: auto !important;
|
||||
animation-duration: 0.01ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.01ms !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,82 +1,212 @@
|
||||
|
||||
@implements IDisposable
|
||||
|
||||
@implements IDisposable
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
<div class="top-row ps-3 navbar navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="">Web-Jarmark</a>
|
||||
<div class="nav-panel">
|
||||
|
||||
<div class="nav-brand-area">
|
||||
<a class="navbar-brand" href="/">
|
||||
|
||||
<svg class="brand-symbol"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.6"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
aria-hidden="true">
|
||||
|
||||
<path d="M20 4C10 4 5 8 5 15
|
||||
c0 3 2 5 5 5
|
||||
C17 20 20 12 20 4Z" />
|
||||
|
||||
<path d="M3 22L15 10" />
|
||||
|
||||
</svg>
|
||||
|
||||
<span class="brand-text">
|
||||
<strong>Školní jarmark</strong>
|
||||
</span>
|
||||
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="checkbox" title="Navigation menu" class="navbar-toggler" />
|
||||
<input type="checkbox"
|
||||
id="public-menu-toggle"
|
||||
title="Navigační menu"
|
||||
aria-label="Rozbalit nebo sbalit navigační menu"
|
||||
aria-controls="public-navigation"
|
||||
class="navbar-toggler" />
|
||||
|
||||
<div class="nav-scrollable"
|
||||
id="public-navigation">
|
||||
|
||||
<nav class="nav public-nav-links"
|
||||
aria-label="Hlavní navigace">
|
||||
|
||||
<div class="nav-item">
|
||||
<NavLink class="nav-link"
|
||||
href=""
|
||||
Match="NavLinkMatch.All"
|
||||
onclick="document.getElementById('public-menu-toggle').checked = false">
|
||||
|
||||
<span>Katalog</span>
|
||||
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
<AuthorizeView Roles="Admin">
|
||||
<Authorized>
|
||||
|
||||
<div class="nav-item">
|
||||
<NavLink class="nav-link"
|
||||
href="admin"
|
||||
onclick="document.getElementById('public-menu-toggle').checked = false">
|
||||
|
||||
<span>Administrace</span>
|
||||
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
</Authorized>
|
||||
</AuthorizeView>
|
||||
|
||||
</nav>
|
||||
|
||||
<div class="nav-bottom public-account-links">
|
||||
|
||||
<AuthorizeView>
|
||||
|
||||
<Authorized>
|
||||
|
||||
<div class="nav-item account-item">
|
||||
<NavLink class="nav-link"
|
||||
href="Account/Manage"
|
||||
onclick="document.getElementById('public-menu-toggle').checked = false">
|
||||
|
||||
<svg class="nav-icon"
|
||||
width="20"
|
||||
height="20"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.7"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
aria-hidden="true">
|
||||
|
||||
<circle cx="12"
|
||||
cy="8"
|
||||
r="4" />
|
||||
|
||||
<path d="M4 21v-2
|
||||
a8 8 0 0 1 16 0
|
||||
v2" />
|
||||
|
||||
</svg>
|
||||
|
||||
<span class="user-name">
|
||||
@context.User.Identity?.Name
|
||||
</span>
|
||||
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
<div class="nav-item">
|
||||
|
||||
<form action="Account/Logout"
|
||||
method="post">
|
||||
|
||||
<AntiforgeryToken />
|
||||
|
||||
<input type="hidden"
|
||||
name="ReturnUrl"
|
||||
value="@currentUrl" />
|
||||
|
||||
<button type="submit"
|
||||
class="nav-link logout-link">
|
||||
|
||||
<span>Odhlásit</span>
|
||||
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</Authorized>
|
||||
|
||||
<NotAuthorized>
|
||||
|
||||
<div class="nav-item">
|
||||
|
||||
<NavLink class="nav-link"
|
||||
href="Account/Login"
|
||||
onclick="document.getElementById('public-menu-toggle').checked = false">
|
||||
|
||||
<span>Přihlášení</span>
|
||||
|
||||
</NavLink>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="nav-item">
|
||||
|
||||
<NavLink class="nav-link"
|
||||
href="Account/Register"
|
||||
onclick="document.getElementById('public-menu-toggle').checked = false">
|
||||
|
||||
<span>Registrace</span>
|
||||
|
||||
</NavLink>
|
||||
|
||||
</div>
|
||||
|
||||
</NotAuthorized>
|
||||
|
||||
</AuthorizeView>
|
||||
|
||||
<div class="nav-item cart-item">
|
||||
|
||||
<NavLink class="nav-link public-cart-link"
|
||||
href="kosik"
|
||||
onclick="document.getElementById('public-menu-toggle').checked = false">
|
||||
|
||||
<svg class="nav-icon"
|
||||
width="20"
|
||||
height="20"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.7"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
aria-hidden="true">
|
||||
|
||||
<path d="M3 3h2l3.5 13h10
|
||||
l3-10H6" />
|
||||
|
||||
<circle cx="10"
|
||||
cy="20"
|
||||
r="1" />
|
||||
|
||||
<circle cx="18"
|
||||
cy="20"
|
||||
r="1" />
|
||||
|
||||
</svg>
|
||||
|
||||
<span>Košík</span>
|
||||
|
||||
</NavLink>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
|
||||
<nav class="nav flex-column">
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
|
||||
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="kosik">
|
||||
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Kosik
|
||||
</NavLink>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="FF">
|
||||
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> FF
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="NovaObjednavka">
|
||||
<span class="bi bi-lock-nav-menu" aria-hidden="true"></span> Nova objednavka
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="DetailObjednavky">
|
||||
<span class="bi bi-lock-nav-menu" aria-hidden="true"></span> Detail objednavky
|
||||
</NavLink>
|
||||
</div>
|
||||
<AuthorizeView>
|
||||
<Authorized>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="Account/Manage">
|
||||
<span class="bi bi-person-fill-nav-menu" aria-hidden="true"></span> @context.User.Identity?.Name
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<form action="Account/Logout" method="post">
|
||||
<AntiforgeryToken />
|
||||
<input type="hidden" name="ReturnUrl" value="@currentUrl" />
|
||||
<button type="submit" class="nav-link">
|
||||
<span class="bi bi-arrow-bar-left-nav-menu" aria-hidden="true"></span> Logout
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</Authorized>
|
||||
<NotAuthorized>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="Account/Register">
|
||||
<span class="bi bi-person-nav-menu" aria-hidden="true"></span> Register
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="Account/Login">
|
||||
<span class="bi bi-person-badge-nav-menu" aria-hidden="true"></span> Login
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="admin">
|
||||
<span class="bi bi-gear-nav-menu" aria-hidden="true"></span> Admin
|
||||
</NavLink>
|
||||
</div>
|
||||
</NotAuthorized>
|
||||
</AuthorizeView>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
@@ -84,18 +214,24 @@
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
currentUrl = NavigationManager.ToBaseRelativePath(NavigationManager.Uri);
|
||||
currentUrl = NavigationManager.ToBaseRelativePath(
|
||||
NavigationManager.Uri);
|
||||
|
||||
NavigationManager.LocationChanged += OnLocationChanged;
|
||||
}
|
||||
|
||||
private void OnLocationChanged(object? sender, LocationChangedEventArgs e)
|
||||
private void OnLocationChanged(
|
||||
object? sender,
|
||||
LocationChangedEventArgs e)
|
||||
{
|
||||
currentUrl = NavigationManager.ToBaseRelativePath(e.Location);
|
||||
StateHasChanged();
|
||||
currentUrl = NavigationManager.ToBaseRelativePath(
|
||||
e.Location);
|
||||
|
||||
_ = InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
NavigationManager.LocationChanged -= OnLocationChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,211 +1,522 @@
|
||||
|
||||
/* ==========================================
|
||||
WEB JARMARK – MODERNÍ BOČNÍ NAVIGACE
|
||||
========================================== */
|
||||
/* ========================================
|
||||
SKOLNI JARMARK - PUBLIC NAVIGATION
|
||||
======================================== */
|
||||
|
||||
.top-row {
|
||||
min-height: 76px;
|
||||
.nav-panel {
|
||||
--nav-primary: #244b36;
|
||||
--nav-primary-hover: #193b29;
|
||||
--nav-secondary: #e6eddf;
|
||||
--nav-text: #26372b;
|
||||
--nav-muted: #59665b;
|
||||
--nav-border: #dce3d9;
|
||||
--nav-surface: #ffffff;
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 24px !important;
|
||||
background: linear-gradient(135deg, #10233f, #183d68);
|
||||
border-bottom: 1px solid rgba(255, 255, 255, .08);
|
||||
gap: 32px;
|
||||
width: 100%;
|
||||
max-width: 1440px;
|
||||
min-width: 0;
|
||||
min-height: 76px;
|
||||
margin: 0 auto;
|
||||
padding: 12px 32px;
|
||||
background: var(--nav-surface);
|
||||
color: var(--nav-text);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
BRAND
|
||||
======================================== */
|
||||
|
||||
.nav-brand-area {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
color: #ffffff !important;
|
||||
font-size: 21px;
|
||||
font-weight: 800;
|
||||
letter-spacing: -.5px;
|
||||
transition: color .25s ease;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-height: 44px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: var(--nav-primary);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.navbar-brand:hover {
|
||||
color: #8fc5ff !important;
|
||||
color: var(--nav-primary-hover);
|
||||
}
|
||||
|
||||
/* Pozadí navigace */
|
||||
.nav-scrollable {
|
||||
background: linear-gradient(180deg, #142b4a 0%, #10223b 100%);
|
||||
min-height: calc(100vh - 76px);
|
||||
padding: 22px 13px;
|
||||
.brand-symbol {
|
||||
display: block;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
flex-shrink: 0;
|
||||
color: var(--nav-primary);
|
||||
}
|
||||
|
||||
.brand-text {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.brand-text strong {
|
||||
font-family: Georgia, "Times New Roman", serif;
|
||||
font-size: 23px;
|
||||
font-weight: 700;
|
||||
line-height: 1.2;
|
||||
letter-spacing: normal;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
NAVIGATION STRUCTURE
|
||||
======================================== */
|
||||
|
||||
.nav-scrollable {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex: 1;
|
||||
gap: 16px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.public-nav-links {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.public-account-links {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
margin: 0 0 0 auto;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Položky menu */
|
||||
.nav-item {
|
||||
display: block;
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 7px;
|
||||
}
|
||||
|
||||
/* Odkazy */
|
||||
|
||||
/* ========================================
|
||||
NAVIGATION LINKS
|
||||
======================================== */
|
||||
|
||||
.nav-item ::deep .nav-link {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
min-height: 49px;
|
||||
padding: 0 16px;
|
||||
justify-content: flex-start;
|
||||
gap: 8px;
|
||||
min-height: 44px;
|
||||
margin: 0;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 12px;
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
color: #b9c9dc;
|
||||
text-decoration: none;
|
||||
line-height: normal;
|
||||
transition: background .25s ease, color .25s ease, border-color .25s ease, transform .25s ease, box-shadow .25s ease;
|
||||
}
|
||||
|
||||
/* Hover efekt */
|
||||
.nav-item ::deep .nav-link:hover {
|
||||
color: #ffffff;
|
||||
background: rgba(255, 255, 255, .09);
|
||||
border-color: rgba(255, 255, 255, .08);
|
||||
transform: translateX(4px);
|
||||
}
|
||||
|
||||
/* Aktivní stránka */
|
||||
.nav-item ::deep a.active {
|
||||
color: #ffffff;
|
||||
background: linear-gradient( 100deg, rgba(40, 130, 235, .32), rgba(40, 130, 235, .12) );
|
||||
border-color: rgba(105, 175, 255, .25);
|
||||
box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
|
||||
}
|
||||
|
||||
/* Modrý indikátor aktivní stránky */
|
||||
.nav-item ::deep a.active::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: -13px;
|
||||
top: 10px;
|
||||
bottom: 10px;
|
||||
width: 3px;
|
||||
border-radius: 0 5px 5px 0;
|
||||
background: #58a6ff;
|
||||
}
|
||||
|
||||
/* Ikony */
|
||||
.nav-item ::deep .bi {
|
||||
width: 21px;
|
||||
height: 21px;
|
||||
margin-right: 13px;
|
||||
flex-shrink: 0;
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
opacity: .85;
|
||||
transition: transform .25s ease, opacity .25s ease;
|
||||
}
|
||||
|
||||
.nav-item ::deep .nav-link:hover .bi,
|
||||
.nav-item ::deep a.active .bi {
|
||||
opacity: 1;
|
||||
transform: scale(1.08);
|
||||
}
|
||||
|
||||
/* Odhlášení */
|
||||
.nav-item ::deep form {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-item ::deep button.nav-link {
|
||||
text-align: left;
|
||||
color: var(--nav-muted);
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
|
||||
}
|
||||
|
||||
/* Mobilní tlačítko */
|
||||
.navbar-toggler {
|
||||
appearance: none;
|
||||
width: 43px;
|
||||
height: 39px;
|
||||
position: absolute;
|
||||
top: 18px;
|
||||
right: 16px;
|
||||
border: 1px solid rgba(255, 255, 255, .2);
|
||||
border-radius: 10px;
|
||||
background-color: rgba(255, 255, 255, .08);
|
||||
cursor: pointer;
|
||||
transition: background .2s ease;
|
||||
}
|
||||
.nav-item ::deep .nav-link:hover {
|
||||
background: #f1f4ef;
|
||||
color: var(--nav-primary);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.navbar-toggler:hover,
|
||||
.navbar-toggler:checked {
|
||||
background-color: rgba(255, 255, 255, .18);
|
||||
.nav-item ::deep a.nav-link.active {
|
||||
background: var(--nav-secondary);
|
||||
color: var(--nav-primary);
|
||||
border-color: #dce5d7;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
/* Plynulé otevření menu na mobilu */
|
||||
.nav-scrollable {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.navbar-toggler:not(:checked) ~ .nav-scrollable {
|
||||
display: none;
|
||||
}
|
||||
/* ========================================
|
||||
ICONS
|
||||
======================================== */
|
||||
|
||||
.navbar-toggler:checked ~ .nav-scrollable {
|
||||
.nav-icon {
|
||||
display: block;
|
||||
animation: menuEnter .28s ease both;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
@keyframes menuEnter {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-8px);
|
||||
|
||||
/* ========================================
|
||||
USER ACCOUNT
|
||||
======================================== */
|
||||
|
||||
.account-item {
|
||||
min-width: 0;
|
||||
max-width: 200px;
|
||||
}
|
||||
|
||||
.user-name {
|
||||
display: block;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.nav-item ::deep form {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.nav-item ::deep button.nav-link {
|
||||
width: 100%;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.nav-item ::deep .logout-link {
|
||||
color: #8b4038;
|
||||
}
|
||||
|
||||
.nav-item ::deep .logout-link:hover {
|
||||
background: #fbefed;
|
||||
color: #74342d;
|
||||
border-color: #efd8d4;
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
|
||||
/* ========================================
|
||||
SHOPPING CART - PRIMARY ACTION
|
||||
======================================== */
|
||||
|
||||
.cart-item {
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.cart-item ::deep .public-cart-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
min-height: 44px;
|
||||
padding: 10px 20px;
|
||||
border: 1px solid var(--nav-primary);
|
||||
border-radius: 6px;
|
||||
background: var(--nav-primary);
|
||||
color: #ffffff;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.cart-item ::deep .public-cart-link:hover {
|
||||
background: var(--nav-primary-hover);
|
||||
border-color: var(--nav-primary-hover);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.cart-item ::deep a.public-cart-link.active {
|
||||
background: var(--nav-primary-hover);
|
||||
border-color: var(--nav-primary-hover);
|
||||
color: #ffffff;
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 4px;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
KEYBOARD ACCESSIBILITY
|
||||
======================================== */
|
||||
|
||||
.navbar-brand:focus-visible,
|
||||
.navbar-toggler:focus-visible,
|
||||
.nav-panel ::deep .nav-link:focus-visible {
|
||||
outline: 3px solid #527b49;
|
||||
outline-offset: 3px;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
MOBILE MENU TOGGLE
|
||||
======================================== */
|
||||
|
||||
.navbar-toggler {
|
||||
display: none;
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: 24px;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 1px solid var(--nav-border);
|
||||
border-radius: 6px;
|
||||
background: var(--nav-surface);
|
||||
color: var(--nav-primary);
|
||||
cursor: pointer;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.navbar-toggler::before,
|
||||
.navbar-toggler::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 11px;
|
||||
width: 20px;
|
||||
height: 2px;
|
||||
background: currentColor;
|
||||
border-radius: 1px;
|
||||
}
|
||||
|
||||
.navbar-toggler::before {
|
||||
top: 14px;
|
||||
box-shadow: 0 6px 0 currentColor;
|
||||
}
|
||||
|
||||
.navbar-toggler::after {
|
||||
top: 26px;
|
||||
}
|
||||
|
||||
.navbar-toggler:checked {
|
||||
background: var(--nav-secondary);
|
||||
}
|
||||
|
||||
.navbar-toggler:checked::before {
|
||||
top: 20px;
|
||||
transform: rotate(45deg);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.navbar-toggler:checked::after {
|
||||
top: 20px;
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
.navbar-toggler:hover {
|
||||
background-color: var(--nav-secondary);
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
COMPACT DESKTOP
|
||||
======================================== */
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
|
||||
.nav-panel {
|
||||
gap: 16px;
|
||||
padding: 12px 24px;
|
||||
}
|
||||
|
||||
.brand-text strong {
|
||||
font-size: 21px;
|
||||
}
|
||||
|
||||
.public-account-links {
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.nav-item ::deep .nav-link {
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
.cart-item ::deep .public-cart-link {
|
||||
padding: 10px 16px;
|
||||
}
|
||||
|
||||
.account-item {
|
||||
max-width: 160px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Scrollbar */
|
||||
.nav-scrollable::-webkit-scrollbar {
|
||||
width: 5px;
|
||||
}
|
||||
|
||||
.nav-scrollable::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, .2);
|
||||
border-radius: 10px;
|
||||
}
|
||||
/* ========================================
|
||||
TABLET AND MOBILE
|
||||
======================================== */
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
|
||||
.nav-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 0;
|
||||
min-height: 68px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.nav-brand-area {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 68px;
|
||||
padding: 12px 84px 12px 24px;
|
||||
}
|
||||
|
||||
/* Desktop */
|
||||
@media (min-width: 641px) {
|
||||
.navbar-toggler {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.nav-scrollable {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-scrollable {
|
||||
display: block !important;
|
||||
height: calc(100vh - 76px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
|
||||
/* Menší displeje */
|
||||
@media (max-width: 640px) {
|
||||
.top-row {
|
||||
min-height: 70px;
|
||||
}
|
||||
|
||||
.nav-scrollable {
|
||||
min-height: auto;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.nav-item ::deep .nav-link,
|
||||
.nav-item ::deep .bi {
|
||||
transition: none;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 16px;
|
||||
width: 100%;
|
||||
padding: 16px 24px 24px;
|
||||
border-top: 1px solid var(--nav-border);
|
||||
}
|
||||
|
||||
.navbar-toggler:checked ~ .nav-scrollable {
|
||||
animation: none;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.public-nav-links {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 4px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.public-account-links {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 4px;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid var(--nav-border);
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-item ::deep .nav-link {
|
||||
width: 100%;
|
||||
min-height: 48px;
|
||||
padding: 12px 16px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.account-item {
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.cart-item {
|
||||
margin: 12px 0 0;
|
||||
}
|
||||
|
||||
.cart-item ::deep .public-cart-link {
|
||||
width: 100%;
|
||||
min-height: 48px;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
MOBILE - MAX 640 PX
|
||||
======================================== */
|
||||
|
||||
@media (max-width: 640px) {
|
||||
|
||||
.nav-brand-area {
|
||||
padding: 12px 76px 12px 16px;
|
||||
}
|
||||
|
||||
.navbar-toggler {
|
||||
right: 16px;
|
||||
}
|
||||
|
||||
.brand-symbol {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
.brand-text strong {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.nav-scrollable {
|
||||
padding: 12px 16px 20px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
SMALL MOBILE
|
||||
======================================== */
|
||||
|
||||
@media (max-width: 360px) {
|
||||
|
||||
.brand-text strong {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.brand-symbol {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.nav-brand-area {
|
||||
padding-left: 12px;
|
||||
padding-right: 68px;
|
||||
}
|
||||
|
||||
.navbar-toggler {
|
||||
right: 12px;
|
||||
}
|
||||
|
||||
.nav-scrollable {
|
||||
padding: 12px 12px 16px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
REDUCED MOTION
|
||||
======================================== */
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
|
||||
.navbar-brand,
|
||||
.navbar-toggler,
|
||||
.nav-panel ::deep .nav-link {
|
||||
transition: none !important;
|
||||
animation: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,257 +7,350 @@
|
||||
@using Web_Jarmark.Data.Models
|
||||
@inject ApplicationDbContext Db
|
||||
|
||||
@attribute [Authorize]
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
|
||||
<PageTitle>Přehled administrace</PageTitle>
|
||||
|
||||
<div class="wj-page-heading">
|
||||
<div>
|
||||
<div class="wj-eyebrow">VÁŠ OBCHOD NA JEDNOM MÍSTĚ</div>
|
||||
<h1>Přehled administrace</h1>
|
||||
<p>Rychlý přehled o aktuálním stavu vašeho obchodu.</p>
|
||||
</div>
|
||||
|
||||
<div class="wj-date">
|
||||
<span>◷</span>
|
||||
@DateTime.Now.ToString("d. M. yyyy")
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (loading)
|
||||
{
|
||||
<div class="wj-panel p-4">Načítám data obchodu…</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="wj-stats-grid">
|
||||
|
||||
<div class="wj-stat-card">
|
||||
<div class="wj-stat-top">
|
||||
<span class="wj-stat-icon">↗</span>
|
||||
<span class="wj-stat-caption">KATALOG</span>
|
||||
<div class="dash">
|
||||
@if (loading)
|
||||
{
|
||||
<div class="ao-loading">Načítám přehled…</div>
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(error))
|
||||
{
|
||||
<div class="ao-alert">@error</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<header class="dash-hero">
|
||||
<div>
|
||||
<p class="dash-eyebrow">Web-Jarmark</p>
|
||||
<h1>Přehled</h1>
|
||||
<p class="dash-sub">Aktuální stav obchodu na jednom místě.</p>
|
||||
</div>
|
||||
<div class="wj-stat-label">Celkem produktů</div>
|
||||
<div class="wj-stat-value">@productCount</div>
|
||||
<div class="wj-stat-foot">Všechny produkty v obchodě</div>
|
||||
</div>
|
||||
|
||||
<div class="wj-stat-card">
|
||||
<div class="wj-stat-top">
|
||||
<span class="wj-stat-icon">▤</span>
|
||||
<span class="wj-stat-caption">SORTIMENT</span>
|
||||
<div class="dash-hero-actions">
|
||||
<a class="ap-btn ap-btn-primary" href="/admin/objednavky">Objednávky</a>
|
||||
<a class="ap-btn" href="/admin/zbozi">Zboží</a>
|
||||
<a class="ap-btn" href="/admin/sklad">Sklad</a>
|
||||
</div>
|
||||
<div class="wj-stat-label">Počet kategorií</div>
|
||||
<div class="wj-stat-value">@categoryCount</div>
|
||||
<div class="wj-stat-foot">Kategorie vašeho zboží</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="wj-stat-card">
|
||||
<div class="wj-stat-top">
|
||||
<span class="wj-stat-icon">◉</span>
|
||||
<span class="wj-stat-caption">E-SHOP</span>
|
||||
</div>
|
||||
<div class="wj-stat-label">Viditelné produkty</div>
|
||||
<div class="wj-stat-value">@visibleCount</div>
|
||||
<div class="wj-stat-foot">Produkty dostupné v katalogu</div>
|
||||
</div>
|
||||
<section class="dash-kpis">
|
||||
<article class="dash-kpi" style="--i:0">
|
||||
<span>Objednávky</span>
|
||||
<strong class="dash-count">@orderCount</strong>
|
||||
<small>@pendingCount čeká na platbu</small>
|
||||
</article>
|
||||
<article class="dash-kpi" style="--i:1">
|
||||
<span>Tržby</span>
|
||||
<strong class="dash-count">@revenue.ToString("N0")</strong>
|
||||
<small>Kč uhrazené / dokončené</small>
|
||||
</article>
|
||||
<article class="dash-kpi" style="--i:2">
|
||||
<span>Produkty</span>
|
||||
<strong class="dash-count">@productCount</strong>
|
||||
<small>@visibleCount viditelných</small>
|
||||
</article>
|
||||
<article class="dash-kpi" style="--i:3">
|
||||
<span>Sklad</span>
|
||||
<strong class="dash-count">@stockUnits</strong>
|
||||
<small>@stockValue.ToString("N0") Kč hodnota</small>
|
||||
</article>
|
||||
<article class="dash-kpi" style="--i:4">
|
||||
<span>Nízký sklad</span>
|
||||
<strong class="dash-count">@lowStockCount</strong>
|
||||
<small>≤ 5 ks</small>
|
||||
</article>
|
||||
<article class="dash-kpi" style="--i:5">
|
||||
<span>Kategorie</span>
|
||||
<strong class="dash-count">@categoryCount</strong>
|
||||
<small>@activeCategoryCount aktivních</small>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<div class="wj-stat-card">
|
||||
<div class="wj-stat-top">
|
||||
<span class="wj-stat-icon">!</span>
|
||||
<span class="wj-stat-caption">SKLAD</span>
|
||||
</div>
|
||||
<div class="wj-stat-label">Dochází skladem</div>
|
||||
<div class="wj-stat-value">@lowStockCount</div>
|
||||
<div class="wj-stat-foot">Produkty s 5 nebo méně kusy</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wj-middle-grid">
|
||||
|
||||
<section class="wj-panel">
|
||||
<div class="wj-panel-heading">
|
||||
<div>
|
||||
<h2>Produkty podle kategorií</h2>
|
||||
<p>Rozložení vašeho sortimentu</p>
|
||||
<section class="dash-row-3">
|
||||
<article class="dash-card" style="--i:6">
|
||||
<div class="dash-card-head">
|
||||
<h2>Viditelnost</h2>
|
||||
<p>Katalog v e-shopu</p>
|
||||
</div>
|
||||
<a href="/admin/kategorie" class="wj-text-link">Kategorie ↗</a>
|
||||
</div>
|
||||
|
||||
@if (categoryStats.Count == 0)
|
||||
{
|
||||
<div class="wj-empty">Zatím nemáte žádné kategorie.</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="wj-category-list">
|
||||
@foreach (var category in categoryStats)
|
||||
{
|
||||
<div class="wj-category-item">
|
||||
<div class="wj-category-info">
|
||||
<span>@category.Name</span>
|
||||
<strong>@category.ProductCount</strong>
|
||||
<div class="dash-stack">
|
||||
<div class="dash-stack-top">
|
||||
<strong>@productCount</strong>
|
||||
<span>produktů celkem</span>
|
||||
</div>
|
||||
<div class="dash-progress">
|
||||
<div class="dash-progress-fill is-dark" style="width:@visPercent%"></div>
|
||||
</div>
|
||||
<div class="dash-split">
|
||||
<div class="dash-split-item">
|
||||
<span class="dash-dot is-on"></span>
|
||||
<div>
|
||||
<strong>@visibleCount</strong>
|
||||
<small>Viditelné</small>
|
||||
</div>
|
||||
<div class="wj-progress">
|
||||
<div class="wj-progress-fill"
|
||||
style="@($"width: {GetWidth(category.ProductCount)}%")">
|
||||
</div>
|
||||
</div>
|
||||
<div class="dash-split-item">
|
||||
<span class="dash-dot is-off"></span>
|
||||
<div>
|
||||
<strong>@hiddenCount</strong>
|
||||
<small>Skryté</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article class="dash-card" style="--i:7">
|
||||
<div class="dash-card-head">
|
||||
<h2>Stav skladu</h2>
|
||||
<p>Produkty podle zásob</p>
|
||||
</div>
|
||||
<div class="dash-stack">
|
||||
<div class="dash-stack-top">
|
||||
<strong>@stockUnits</strong>
|
||||
<span>ks na skladě · @stockValue.ToString("N0") Kč</span>
|
||||
</div>
|
||||
<div class="dash-progress dash-progress-multi">
|
||||
<div class="dash-progress-fill is-dark" style="width:@okPercent%"></div>
|
||||
<div class="dash-progress-fill is-mid" style="width:@lowPercent%"></div>
|
||||
<div class="dash-progress-fill is-light" style="width:@outPercent%"></div>
|
||||
</div>
|
||||
<div class="dash-split three">
|
||||
<div class="dash-split-item">
|
||||
<span class="dash-dot is-on"></span>
|
||||
<div>
|
||||
<strong>@okStockCount</strong>
|
||||
<small>V pořádku</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dash-split-item">
|
||||
<span class="dash-dot is-mid"></span>
|
||||
<div>
|
||||
<strong>@lowStockCount</strong>
|
||||
<small>Nízký</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dash-split-item">
|
||||
<span class="dash-dot is-off"></span>
|
||||
<div>
|
||||
<strong>@outOfStockCount</strong>
|
||||
<small>Prázdný</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article class="dash-card" style="--i:8">
|
||||
<div class="dash-card-head">
|
||||
<h2>Objednávky</h2>
|
||||
<p>Podle stavu</p>
|
||||
</div>
|
||||
<div class="dash-bars">
|
||||
@foreach (var b in orderBars)
|
||||
{
|
||||
<div class="dash-bar-row">
|
||||
<div class="dash-bar-label">
|
||||
<span>@b.Label</span>
|
||||
<strong>@b.Count</strong>
|
||||
</div>
|
||||
<div class="dash-bar-track">
|
||||
<div class="dash-bar-fill" style="width:@b.Percent%"></div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="dash-row-2">
|
||||
<article class="dash-card" style="--i:9">
|
||||
<div class="dash-card-head">
|
||||
<h2>Rychlé akce</h2>
|
||||
<p>Nejčastější správa</p>
|
||||
</div>
|
||||
<div class="dash-actions">
|
||||
<a class="dash-action" href="/admin/objednavky"><strong>Objednávky</strong><span>@pendingCount čeká</span></a>
|
||||
<a class="dash-action" href="/admin/zbozi"><strong>Zboží</strong><span>@productCount produktů</span></a>
|
||||
<a class="dash-action" href="/admin/sklad"><strong>Sklad</strong><span>@lowStockCount nízký</span></a>
|
||||
<a class="dash-action" href="/admin/kategorie"><strong>Kategorie</strong><span>@categoryCount položek</span></a>
|
||||
<a class="dash-action" href="/admin/statistiky"><strong>Statistiky</strong><span>detailní přehled</span></a>
|
||||
<a class="dash-action" href="/admin/administratori"><strong>Uživatelé</strong><span>správa účtů</span></a>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article class="dash-card" style="--i:10">
|
||||
<div class="dash-card-head">
|
||||
<h2>Pozor na sklad</h2>
|
||||
<p>Nízký stav a vyprodané</p>
|
||||
</div>
|
||||
@if (attentionProducts.Count == 0)
|
||||
{
|
||||
<div class="dash-empty">Všechny produkty mají dostatek kusů.</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="dash-mini-list">
|
||||
@foreach (var p in attentionProducts)
|
||||
{
|
||||
<a class="dash-mini-item" href="@($"/admin/zbozi/edit/{p.Id}")">
|
||||
<div>
|
||||
<strong>@p.Name</strong>
|
||||
<span>@p.CategoryName</span>
|
||||
</div>
|
||||
<span class="ao-badge @(p.StockQuantity <= 0 ? "is-cancel" : "is-pending")">
|
||||
@p.StockQuantity ks
|
||||
</span>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="dash-card" style="--i:11">
|
||||
<div class="dash-card-head row">
|
||||
<div>
|
||||
<h2>Poslední objednávky</h2>
|
||||
<p>Nejnovějších 8</p>
|
||||
</div>
|
||||
<a class="ap-btn ap-btn-ghost" href="/admin/objednavky">Všechny</a>
|
||||
</div>
|
||||
|
||||
@if (recentOrders.Count == 0)
|
||||
{
|
||||
<div class="dash-empty">Zatím žádné objednávky.</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="dash-orders">
|
||||
@foreach (var o in recentOrders)
|
||||
{
|
||||
<article class="dash-order" style="--i:@o.Index">
|
||||
<div>
|
||||
<strong>#@o.Code</strong>
|
||||
<span>@o.CreatedAt.ToLocalTime().ToString("d. M. yyyy HH:mm")</span>
|
||||
</div>
|
||||
<div class="dash-order-mid">
|
||||
@(string.IsNullOrWhiteSpace(o.CustomerName) ? "—" : o.CustomerName)
|
||||
</div>
|
||||
<div class="dash-order-right">
|
||||
<strong>@o.TotalAmount.ToString("N0") Kč</strong>
|
||||
<span class="ao-badge @StatusBadge(o.Status)">@StatusText(o.Status)</span>
|
||||
</div>
|
||||
</article>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
|
||||
<section class="wj-panel">
|
||||
<div class="wj-panel-heading">
|
||||
<div>
|
||||
<h2>Rychlé akce</h2>
|
||||
<p>Nejčastější úkony v administraci</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wj-actions">
|
||||
<a href="/admin/zbozi/edit" class="wj-action">
|
||||
<span class="wj-action-icon">+</span>
|
||||
<span>
|
||||
<strong>Přidat nové zboží</strong>
|
||||
<small>Vytvořit nový produkt</small>
|
||||
</span>
|
||||
<span class="wj-action-arrow">→</span>
|
||||
</a>
|
||||
|
||||
<a href="/admin/kategorie/edit" class="wj-action">
|
||||
<span class="wj-action-icon">▤</span>
|
||||
<span>
|
||||
<strong>Nová kategorie</strong>
|
||||
<small>Rozšířit nabídku kategorií</small>
|
||||
</span>
|
||||
<span class="wj-action-arrow">→</span>
|
||||
</a>
|
||||
|
||||
<a href="/admin/zbozi" class="wj-action">
|
||||
<span class="wj-action-icon">◇</span>
|
||||
<span>
|
||||
<strong>Spravovat zboží</strong>
|
||||
<small>Upravit nebo skrýt produkty</small>
|
||||
</span>
|
||||
<span class="wj-action-arrow">→</span>
|
||||
</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
<section class="wj-panel wj-products-panel">
|
||||
<div class="wj-panel-heading">
|
||||
<div>
|
||||
<h2>Přehled produktů</h2>
|
||||
<p>Ukázka produktů z vašeho katalogu</p>
|
||||
</div>
|
||||
<a href="/admin/zbozi" class="wj-text-link">Zobrazit vše →</a>
|
||||
</div>
|
||||
|
||||
@if (productPreview.Count == 0)
|
||||
{
|
||||
<div class="wj-empty">Zatím nemáte žádné produkty.</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="wj-table-wrap">
|
||||
<table class="wj-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Produkt</th>
|
||||
<th>Kategorie</th>
|
||||
<th>Cena</th>
|
||||
<th>Skladem</th>
|
||||
<th>Stav</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var product in productPreview)
|
||||
{
|
||||
<tr>
|
||||
<td class="wj-product-name">@product.Name</td>
|
||||
<td>@product.CategoryName</td>
|
||||
<td class="wj-price">@product.Price.ToString("N2") Kč</td>
|
||||
<td>@product.StockQuantity ks</td>
|
||||
<td>
|
||||
@if (product.IsVisible)
|
||||
{
|
||||
<span class="wj-pill">Viditelné</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="wj-pill wj-pill-muted">Skryté</span>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private bool loading = true;
|
||||
private string? error;
|
||||
|
||||
private int productCount;
|
||||
private int categoryCount;
|
||||
private int visibleCount;
|
||||
private int lowStockCount;
|
||||
private int productCount, visibleCount, hiddenCount, categoryCount, activeCategoryCount;
|
||||
private int stockUnits, lowStockCount, outOfStockCount, okStockCount;
|
||||
private int orderCount, pendingCount, paidCount, shippedCount, deliveredCount, cancelledCount;
|
||||
private decimal revenue, stockValue;
|
||||
|
||||
private List<CategoryStat> categoryStats = new();
|
||||
private List<ProductPreview> productPreview = new();
|
||||
private int visPercent, okPercent, lowPercent, outPercent;
|
||||
|
||||
private List<BarItem> orderBars = new();
|
||||
private List<RecentOrder> recentOrders = new();
|
||||
private List<AttentionProduct> attentionProducts = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
productCount = await Db.Set<Product>().CountAsync();
|
||||
categoryCount = await Db.Set<Category>().CountAsync();
|
||||
visibleCount = await Db.Set<Product>().CountAsync(p => p.IsVisible);
|
||||
lowStockCount = await Db.Set<Product>().CountAsync(p => p.StockQuantity <= 5);
|
||||
try
|
||||
{
|
||||
var products = await Db.Products.AsNoTracking().Include(p => p.Category).ToListAsync();
|
||||
productCount = products.Count;
|
||||
visibleCount = products.Count(p => p.IsVisible);
|
||||
hiddenCount = productCount - visibleCount;
|
||||
stockUnits = products.Sum(p => p.StockQuantity);
|
||||
stockValue = products.Sum(p => p.Price * p.StockQuantity);
|
||||
lowStockCount = products.Count(p => p.StockQuantity > 0 && p.StockQuantity <= 5);
|
||||
outOfStockCount = products.Count(p => p.StockQuantity <= 0);
|
||||
okStockCount = products.Count(p => p.StockQuantity > 5);
|
||||
|
||||
var categories = await Db.Set<Category>()
|
||||
.AsNoTracking()
|
||||
.Include(c => c.Products)
|
||||
.OrderBy(c => c.Name)
|
||||
.ToListAsync();
|
||||
categoryCount = await Db.Categories.CountAsync();
|
||||
activeCategoryCount = await Db.Categories.CountAsync(c => c.IsActive);
|
||||
|
||||
categoryStats = categories
|
||||
.Select(c => new CategoryStat(c.Name, c.Products.Count))
|
||||
.ToList();
|
||||
var orders = await Db.Orders.AsNoTracking().ToListAsync();
|
||||
orderCount = orders.Count;
|
||||
pendingCount = orders.Count(o => o.Status == OrderStatus.Pending);
|
||||
paidCount = orders.Count(o => o.Status == OrderStatus.Paid);
|
||||
shippedCount = orders.Count(o => o.Status == OrderStatus.Shipped);
|
||||
deliveredCount = orders.Count(o => o.Status == OrderStatus.Delivered);
|
||||
cancelledCount = orders.Count(o => o.Status == OrderStatus.Cancelled);
|
||||
|
||||
productPreview = await Db.Set<Product>()
|
||||
.AsNoTracking()
|
||||
.OrderBy(p => p.Name)
|
||||
.Take(5)
|
||||
.Select(p => new ProductPreview(
|
||||
p.Name,
|
||||
p.Category.Name,
|
||||
p.Price,
|
||||
p.StockQuantity,
|
||||
p.IsVisible))
|
||||
.ToListAsync();
|
||||
revenue = orders
|
||||
.Where(o => o.Status is OrderStatus.Paid or OrderStatus.Shipped or OrderStatus.Delivered)
|
||||
.Sum(o => o.TotalAmount);
|
||||
|
||||
loading = false;
|
||||
visPercent = productCount == 0 ? 0 : (int)Math.Round(100.0 * visibleCount / productCount);
|
||||
okPercent = productCount == 0 ? 0 : (int)Math.Round(100.0 * okStockCount / productCount);
|
||||
lowPercent = productCount == 0 ? 0 : (int)Math.Round(100.0 * lowStockCount / productCount);
|
||||
outPercent = productCount == 0 ? 0 : Math.Max(0, 100 - okPercent - lowPercent);
|
||||
|
||||
var total = Math.Max(orderCount, 1);
|
||||
orderBars = new List<BarItem>
|
||||
{
|
||||
new("Čeká na zaplacení", pendingCount, pendingCount * 100 / total),
|
||||
new("Zaplaceno", paidCount, paidCount * 100 / total),
|
||||
new("Odesláno", shippedCount, shippedCount * 100 / total),
|
||||
new("Dokončeno", deliveredCount, deliveredCount * 100 / total),
|
||||
new("Zrušeno", cancelledCount, cancelledCount * 100 / total),
|
||||
};
|
||||
|
||||
recentOrders = orders
|
||||
.OrderByDescending(o => o.CreatedAt)
|
||||
.Take(8)
|
||||
.Select((o, idx) => new RecentOrder(o.Code, o.CustomerName, o.TotalAmount, o.Status, o.CreatedAt, idx))
|
||||
.ToList();
|
||||
|
||||
attentionProducts = products
|
||||
.Where(p => p.StockQuantity <= 5)
|
||||
.OrderBy(p => p.StockQuantity)
|
||||
.ThenBy(p => p.Name)
|
||||
.Take(8)
|
||||
.Select(p => new AttentionProduct(p.Id, p.Name, p.Category?.Name ?? "—", p.StockQuantity))
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
error = "Přehled se nepodařilo načíst: " + ex.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private int GetWidth(int count)
|
||||
private static string StatusText(OrderStatus s) => s switch
|
||||
{
|
||||
var max = categoryStats.Count == 0 ? 1 : categoryStats.Max(c => c.ProductCount);
|
||||
return count == 0 ? 0 : Math.Max(5, (int)Math.Round(count * 100.0 / Math.Max(1, max)));
|
||||
}
|
||||
OrderStatus.Pending => "Čeká",
|
||||
OrderStatus.Paid => "Zaplaceno",
|
||||
OrderStatus.Shipped => "Odesláno",
|
||||
OrderStatus.Delivered => "Dokončeno",
|
||||
OrderStatus.Cancelled => "Zrušeno",
|
||||
_ => "?"
|
||||
};
|
||||
|
||||
private record CategoryStat(string Name, int ProductCount);
|
||||
private static string StatusBadge(OrderStatus s) => s switch
|
||||
{
|
||||
OrderStatus.Pending => "is-pending",
|
||||
OrderStatus.Paid => "is-paid",
|
||||
OrderStatus.Shipped => "is-shipped",
|
||||
OrderStatus.Delivered => "is-done",
|
||||
OrderStatus.Cancelled => "is-cancel",
|
||||
_ => ""
|
||||
};
|
||||
|
||||
private record ProductPreview(
|
||||
string Name,
|
||||
string CategoryName,
|
||||
decimal Price,
|
||||
int StockQuantity,
|
||||
bool IsVisible);
|
||||
}
|
||||
private sealed record BarItem(string Label, int Count, int Percent);
|
||||
private sealed record RecentOrder(string Code, string CustomerName, decimal TotalAmount, OrderStatus Status, DateTime CreatedAt, int Index);
|
||||
private sealed record AttentionProduct(int Id, string Name, string CategoryName, int StockQuantity);
|
||||
}
|
||||
498
Web-Jarmark/Web-Jarmark/Components/Pages/Admin/Admin.razor.css
Normal file
498
Web-Jarmark/Web-Jarmark/Components/Pages/Admin/Admin.razor.css
Normal file
@@ -0,0 +1,498 @@
|
||||
/* Plná šířka dashboard */
|
||||
|
||||
.dash {
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
margin: 0;
|
||||
color: #1d1d1f;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
.dash-hero {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-end;
|
||||
gap: 16px;
|
||||
flex-wrap: wrap;
|
||||
padding: 4px 2px 22px;
|
||||
animation: dash-in 0.45s ease both;
|
||||
}
|
||||
|
||||
.dash-eyebrow {
|
||||
margin: 0 0 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: #6e6e73;
|
||||
}
|
||||
|
||||
.dash-hero h1 {
|
||||
margin: 0;
|
||||
font-size: 34px;
|
||||
font-weight: 750;
|
||||
letter-spacing: -0.03em;
|
||||
}
|
||||
|
||||
.dash-sub {
|
||||
margin: 8px 0 0;
|
||||
color: #6e6e73;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.dash-hero-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.dash-kpis {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.dash-kpi {
|
||||
background: #fff;
|
||||
border: 1px solid rgba(0, 0, 0, 0.05);
|
||||
border-radius: 22px;
|
||||
padding: 16px 14px;
|
||||
box-shadow: 0 10px 28px rgba(0, 0, 0, 0.04);
|
||||
animation: dash-rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
|
||||
animation-delay: calc(var(--i, 0) * 0.05s);
|
||||
transition: transform 0.25s ease, box-shadow 0.25s ease;
|
||||
}
|
||||
|
||||
.dash-kpi:hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: 0 16px 36px rgba(0, 0, 0, 0.07);
|
||||
}
|
||||
|
||||
.dash-kpi span {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
font-weight: 650;
|
||||
color: #6e6e73;
|
||||
}
|
||||
|
||||
.dash-kpi strong.dash-count {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
font-size: 26px;
|
||||
font-weight: 750;
|
||||
letter-spacing: -0.03em;
|
||||
line-height: 1;
|
||||
animation: dash-pop 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
|
||||
animation-delay: calc(var(--i, 0) * 0.05s + 0.1s);
|
||||
}
|
||||
|
||||
.dash-kpi small {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
font-size: 11px;
|
||||
color: #86868b;
|
||||
}
|
||||
|
||||
.dash-row-3 {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.dash-row-2 {
|
||||
display: grid;
|
||||
grid-template-columns: 1.2fr 0.8fr;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.dash-card {
|
||||
background: #fff;
|
||||
border: 1px solid rgba(0, 0, 0, 0.05);
|
||||
border-radius: 24px;
|
||||
padding: 18px;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
|
||||
animation: dash-rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
|
||||
animation-delay: calc(var(--i, 0) * 0.05s);
|
||||
}
|
||||
|
||||
.dash-card-head {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.dash-card-head.row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.dash-card-head h2 {
|
||||
margin: 0;
|
||||
font-size: 17px;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.dash-card-head p {
|
||||
margin: 4px 0 0;
|
||||
font-size: 13px;
|
||||
color: #6e6e73;
|
||||
}
|
||||
|
||||
/* Progress verze místo donutů */
|
||||
.dash-stack {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.dash-stack-top strong {
|
||||
display: block;
|
||||
font-size: 28px;
|
||||
font-weight: 750;
|
||||
letter-spacing: -0.03em;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.dash-stack-top span {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
font-size: 13px;
|
||||
color: #6e6e73;
|
||||
}
|
||||
|
||||
.dash-progress {
|
||||
height: 12px;
|
||||
border-radius: 999px;
|
||||
background: #f0f0f2;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.dash-progress-multi {
|
||||
display: flex;
|
||||
background: #f0f0f2;
|
||||
}
|
||||
|
||||
.dash-progress-fill {
|
||||
height: 100%;
|
||||
border-radius: 999px;
|
||||
transform-origin: left center;
|
||||
animation: dash-bar 0.85s cubic-bezier(0.22, 1, 0.36, 1) both;
|
||||
}
|
||||
|
||||
.dash-progress-multi .dash-progress-fill {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.dash-progress-multi .dash-progress-fill:first-child {
|
||||
border-radius: 999px 0 0 999px;
|
||||
}
|
||||
|
||||
.dash-progress-multi .dash-progress-fill:last-child {
|
||||
border-radius: 0 999px 999px 0;
|
||||
}
|
||||
|
||||
.dash-progress-fill.is-dark {
|
||||
background: #1d1d1f;
|
||||
}
|
||||
|
||||
.dash-progress-fill.is-mid {
|
||||
background: #8e8e93;
|
||||
}
|
||||
|
||||
.dash-progress-fill.is-light {
|
||||
background: #d2d2d7;
|
||||
}
|
||||
|
||||
.dash-split {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.dash-split.three {
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
}
|
||||
|
||||
.dash-split-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
padding: 12px;
|
||||
border-radius: 14px;
|
||||
background: #f5f5f7;
|
||||
}
|
||||
|
||||
.dash-split-item strong {
|
||||
display: block;
|
||||
font-size: 18px;
|
||||
font-weight: 750;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
.dash-split-item small {
|
||||
display: block;
|
||||
margin-top: 3px;
|
||||
font-size: 12px;
|
||||
color: #6e6e73;
|
||||
}
|
||||
|
||||
.dash-dot {
|
||||
width: 9px;
|
||||
height: 9px;
|
||||
border-radius: 50%;
|
||||
background: #e8e8ed;
|
||||
flex-shrink: 0;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.dash-dot.is-on {
|
||||
background: #1d1d1f;
|
||||
}
|
||||
|
||||
.dash-dot.is-mid {
|
||||
background: #8e8e93;
|
||||
}
|
||||
|
||||
.dash-dot.is-off {
|
||||
background: #e8e8ed;
|
||||
border: 1px solid #d2d2d7;
|
||||
}
|
||||
|
||||
.dash-bars {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.dash-bar-label {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 5px;
|
||||
font-size: 12px;
|
||||
color: #6e6e73;
|
||||
}
|
||||
|
||||
.dash-bar-label strong {
|
||||
color: #1d1d1f;
|
||||
}
|
||||
|
||||
.dash-bar-track {
|
||||
height: 8px;
|
||||
border-radius: 999px;
|
||||
background: #f0f0f2;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.dash-bar-fill {
|
||||
height: 100%;
|
||||
border-radius: 999px;
|
||||
background: #1d1d1f;
|
||||
transform-origin: left center;
|
||||
animation: dash-bar 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
|
||||
}
|
||||
|
||||
.dash-actions {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.dash-action {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
padding: 14px;
|
||||
border-radius: 16px;
|
||||
background: #f5f5f7;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
.dash-action:hover {
|
||||
background: #fff;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 10px 24px rgba(0, 0, 0, 0.06);
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.dash-action strong {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.dash-action span {
|
||||
font-size: 12px;
|
||||
color: #6e6e73;
|
||||
}
|
||||
|
||||
.dash-mini-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.dash-mini-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 14px;
|
||||
background: #f5f5f7;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
transition: background 0.2s ease, transform 0.15s ease;
|
||||
}
|
||||
|
||||
.dash-mini-item:hover {
|
||||
background: #ececee;
|
||||
transform: translateX(2px);
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.dash-mini-item strong {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.dash-mini-item span {
|
||||
font-size: 12px;
|
||||
color: #6e6e73;
|
||||
}
|
||||
|
||||
.dash-empty {
|
||||
padding: 18px;
|
||||
text-align: center;
|
||||
color: #6e6e73;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.dash-orders {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.dash-order {
|
||||
display: grid;
|
||||
grid-template-columns: 1.2fr 1fr auto;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
padding: 14px 16px;
|
||||
border-radius: 16px;
|
||||
background: #f7f7f8;
|
||||
animation: dash-rise 0.45s ease both;
|
||||
animation-delay: calc(var(--i, 0) * 0.04s);
|
||||
transition: background 0.2s ease, transform 0.15s ease;
|
||||
}
|
||||
|
||||
.dash-order:hover {
|
||||
background: #f0f0f2;
|
||||
transform: translateX(2px);
|
||||
}
|
||||
|
||||
.dash-order strong {
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.dash-order span {
|
||||
font-size: 12px;
|
||||
color: #6e6e73;
|
||||
}
|
||||
|
||||
.dash-order-mid {
|
||||
font-size: 13px;
|
||||
color: #6e6e73;
|
||||
}
|
||||
|
||||
.dash-order-right {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
@keyframes dash-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(8px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes dash-rise {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(16px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes dash-pop {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: scale(0.92);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes dash-bar {
|
||||
from {
|
||||
transform: scaleX(0);
|
||||
}
|
||||
|
||||
to {
|
||||
transform: scaleX(1);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.dash-kpis {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.dash-row-3 {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.dash-row-2 {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.dash-kpis {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.dash-actions {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
|
||||
.dash-order {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.dash-split.three {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
321
Web-Jarmark/Web-Jarmark/Components/Pages/Admin/AdminUsers.razor
Normal file
321
Web-Jarmark/Web-Jarmark/Components/Pages/Admin/AdminUsers.razor
Normal file
@@ -0,0 +1,321 @@
|
||||
@page "/admin/administratori"
|
||||
@layout Web_Jarmark.Components.Layout.Admin.AdminLayout
|
||||
@rendermode InteractiveServer
|
||||
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Microsoft.AspNetCore.Identity
|
||||
@using Microsoft.AspNetCore.Components.Authorization
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Web_Jarmark.Data
|
||||
|
||||
@inject UserManager<ApplicationUser> UserManager
|
||||
@inject RoleManager<IdentityRole> RoleManager
|
||||
@inject AuthenticationStateProvider AuthenticationStateProvider
|
||||
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
|
||||
<PageTitle>Registrovaní uživatelé</PageTitle>
|
||||
|
||||
<div class="ap">
|
||||
<header class="ap-hero ap-hero-left">
|
||||
<p class="ap-eyebrow">Administrace</p>
|
||||
<div class="ap-hero-row">
|
||||
<div>
|
||||
<h1>Uživatelé</h1>
|
||||
<p class="ap-sub">Správa registrovaných účtů a administrátorských oprávnění.</p>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@if (!string.IsNullOrEmpty(message))
|
||||
{
|
||||
<div class="ap-alert">@message</div>
|
||||
}
|
||||
|
||||
@if (loading)
|
||||
{
|
||||
<div class="ap-loading">Načítám uživatele…</div>
|
||||
}
|
||||
else if (users.Count == 0)
|
||||
{
|
||||
<section class="ap-panel">
|
||||
<p class="ap-empty">Zatím žádní registrovaní uživatelé.</p>
|
||||
</section>
|
||||
}
|
||||
else
|
||||
{
|
||||
<section class="ap-panel ap-panel-table">
|
||||
<div class="ap-panel-head">
|
||||
<h2>Registrované účty</h2>
|
||||
<span class="ap-muted">@users.Count účtů</span>
|
||||
</div>
|
||||
|
||||
<div class="ap-table-wrap">
|
||||
<table class="ap-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>E-mail</th>
|
||||
<th>Potvrzený</th>
|
||||
<th>Admin</th>
|
||||
<th>Stav</th>
|
||||
<th>Akce</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var u in users)
|
||||
{
|
||||
<tr @key="u.Id">
|
||||
<td class="ap-name">@u.Email</td>
|
||||
<td>
|
||||
<span class="ap-status @(u.EmailConfirmed ? "is-on" : "is-off")">
|
||||
@(u.EmailConfirmed ? "Ano" : "Ne")
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="ap-status @(u.IsAdmin ? "is-on" : "is-off")">
|
||||
@(u.IsAdmin ? "Admin" : "Uživatel")
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="ap-status @(u.IsLocked ? "is-off" : "is-on")">
|
||||
@(u.IsLocked ? "Zamčený" : "Aktivní")
|
||||
</span>
|
||||
</td>
|
||||
<td class="ap-actions-cell">
|
||||
<button type="button"
|
||||
class="ap-btn ap-btn-ghost"
|
||||
disabled="@busy"
|
||||
@onclick="() => ToggleAdminAsync(u)">
|
||||
@(u.IsAdmin ? "Odebrat admin" : "Udělat admin")
|
||||
</button>
|
||||
|
||||
<button type="button"
|
||||
class="ap-btn ap-btn-ghost"
|
||||
disabled="@busy"
|
||||
@onclick="() => ToggleLockAsync(u)">
|
||||
@(u.IsLocked ? "Odemknout" : "Zamknout")
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private List<UserRow> users = new();
|
||||
private bool loading = true;
|
||||
private bool busy;
|
||||
private string? message;
|
||||
|
||||
private const string AdminRole = "Admin";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await EnsureAdminRoleAsync();
|
||||
await LoadUsersAsync();
|
||||
loading = false;
|
||||
}
|
||||
|
||||
private async Task EnsureAdminRoleAsync()
|
||||
{
|
||||
if (!await RoleManager.RoleExistsAsync(AdminRole))
|
||||
{
|
||||
var result = await RoleManager.CreateAsync(
|
||||
new IdentityRole(AdminRole));
|
||||
|
||||
if (!result.Succeeded)
|
||||
{
|
||||
message = "Nepodařilo se vytvořit roli Admin: "
|
||||
+ string.Join(", ", result.Errors.Select(e => e.Description));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadUsersAsync()
|
||||
{
|
||||
var list = await UserManager.Users
|
||||
.AsNoTracking()
|
||||
.OrderBy(u => u.Email)
|
||||
.ToListAsync();
|
||||
|
||||
users = new List<UserRow>();
|
||||
|
||||
foreach (var user in list)
|
||||
{
|
||||
var roles = await UserManager.GetRolesAsync(user);
|
||||
|
||||
var isLocked = user.LockoutEnd.HasValue
|
||||
&& user.LockoutEnd > DateTimeOffset.UtcNow;
|
||||
|
||||
users.Add(new UserRow(
|
||||
user.Id,
|
||||
user.Email ?? "(bez e-mailu)",
|
||||
user.EmailConfirmed,
|
||||
roles.Contains(AdminRole),
|
||||
isLocked));
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ToggleAdminAsync(UserRow row)
|
||||
{
|
||||
if (busy)
|
||||
return;
|
||||
|
||||
busy = true;
|
||||
message = null;
|
||||
|
||||
try
|
||||
{
|
||||
var user = await UserManager.FindByIdAsync(row.Id);
|
||||
|
||||
if (user is null)
|
||||
{
|
||||
message = "Uživatel nebyl nalezen.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!await RoleManager.RoleExistsAsync(AdminRole))
|
||||
{
|
||||
var createRoleResult = await RoleManager.CreateAsync(
|
||||
new IdentityRole(AdminRole));
|
||||
|
||||
if (!createRoleResult.Succeeded)
|
||||
{
|
||||
message = "Nepodařilo se vytvořit roli Admin: "
|
||||
+ string.Join(", ", createRoleResult.Errors.Select(e => e.Description));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (row.IsAdmin)
|
||||
{
|
||||
var admins = await UserManager.GetUsersInRoleAsync(AdminRole);
|
||||
|
||||
if (admins.Count <= 1)
|
||||
{
|
||||
message = "Nelze odebrat roli poslednímu administrátorovi.";
|
||||
return;
|
||||
}
|
||||
|
||||
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||
var currentUserId = UserManager.GetUserId(authState.User);
|
||||
|
||||
if (currentUserId == user.Id)
|
||||
{
|
||||
message = "Nemůžeš odebrat administrátorskou roli sám sobě.";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
IdentityResult result;
|
||||
|
||||
if (row.IsAdmin)
|
||||
{
|
||||
result = await UserManager.RemoveFromRoleAsync(user, AdminRole);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await UserManager.AddToRoleAsync(user, AdminRole);
|
||||
}
|
||||
|
||||
if (!result.Succeeded)
|
||||
{
|
||||
message = "Změna role se nepodařila: "
|
||||
+ string.Join(", ", result.Errors.Select(e => e.Description));
|
||||
return;
|
||||
}
|
||||
|
||||
message = row.IsAdmin
|
||||
? $"Administrátorská role byla odebrána: {row.Email}"
|
||||
: $"Administrátorská role byla přidána: {row.Email}";
|
||||
|
||||
await LoadUsersAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = "Chyba při změně role: " + ex.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
busy = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ToggleLockAsync(UserRow row)
|
||||
{
|
||||
if (busy)
|
||||
return;
|
||||
|
||||
busy = true;
|
||||
message = null;
|
||||
|
||||
try
|
||||
{
|
||||
var user = await UserManager.FindByIdAsync(row.Id);
|
||||
|
||||
if (user is null)
|
||||
{
|
||||
message = "Uživatel nebyl nalezen.";
|
||||
return;
|
||||
}
|
||||
|
||||
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||
var currentUserId = UserManager.GetUserId(authState.User);
|
||||
|
||||
if (currentUserId == user.Id)
|
||||
{
|
||||
message = "Nemůžeš zamknout vlastní účet.";
|
||||
return;
|
||||
}
|
||||
|
||||
IdentityResult result;
|
||||
|
||||
if (row.IsLocked)
|
||||
{
|
||||
result = await UserManager.SetLockoutEndDateAsync(user, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await UserManager.SetLockoutEnabledAsync(user, true);
|
||||
|
||||
if (result.Succeeded)
|
||||
{
|
||||
result = await UserManager.SetLockoutEndDateAsync(
|
||||
user, DateTimeOffset.UtcNow.AddYears(100));
|
||||
}
|
||||
}
|
||||
|
||||
if (!result.Succeeded)
|
||||
{
|
||||
message = "Změna stavu účtu se nepodařila: "
|
||||
+ string.Join(", ", result.Errors.Select(e => e.Description));
|
||||
return;
|
||||
}
|
||||
|
||||
message = row.IsLocked
|
||||
? $"Účet byl odemčen: {row.Email}"
|
||||
: $"Účet byl zamčen: {row.Email}";
|
||||
|
||||
await LoadUsersAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = "Chyba: " + ex.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
busy = false;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed record UserRow(
|
||||
string Id,
|
||||
string Email,
|
||||
bool EmailConfirmed,
|
||||
bool IsAdmin,
|
||||
bool IsLocked);
|
||||
}
|
||||
@@ -2,10 +2,6 @@
|
||||
@page "/admin/kategorie/edit/{Id:int}"
|
||||
@layout Web_Jarmark.Components.Layout.Admin.AdminLayout
|
||||
@rendermode InteractiveServer
|
||||
@using System.ComponentModel.DataAnnotations
|
||||
@using System.Globalization
|
||||
@using System.Text
|
||||
@using System.Text.RegularExpressions
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Web_Jarmark.Data
|
||||
@@ -13,206 +9,148 @@
|
||||
@inject ApplicationDbContext Db
|
||||
@inject NavigationManager Nav
|
||||
|
||||
@attribute [Authorize]
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
|
||||
<AuthorizeView Context="authContext">
|
||||
<PageTitle>@(Id is null ? "Nová kategorie" : "Upravit kategorii")</PageTitle>
|
||||
<PageTitle>@(IsNew ? "Nová kategorie" : "Upravit kategorii")</PageTitle>
|
||||
|
||||
<div class="wj-admin-page container-fluid py-3">
|
||||
<div class="wj-page-back">
|
||||
<a href="/admin" class="wj-back-admin">
|
||||
<span>←</span> Zpět na administraci
|
||||
</a>
|
||||
<div class="ap ao">
|
||||
<header class="ao-hero">
|
||||
<p class="ao-eyebrow">Kategorie</p>
|
||||
<h1>@(IsNew ? "Nová kategorie" : "Upravit kategorii")</h1>
|
||||
<p class="ao-sub">Název a stav kategorie.</p>
|
||||
</header>
|
||||
|
||||
@if (!string.IsNullOrEmpty(error))
|
||||
{
|
||||
<div class="ao-alert">@error</div>
|
||||
}
|
||||
|
||||
@if (notFound)
|
||||
{
|
||||
<div class="ao-empty">Kategorie nebyla nalezena.</div>
|
||||
<div style="text-align:center;margin-top:12px">
|
||||
<a class="ap-btn" href="/admin/kategorie">Zpět</a>
|
||||
</div>
|
||||
|
||||
<div class="wj-heading mb-4">
|
||||
<div class="wj-eyebrow">ADMINISTRACE / KATEGORIE</div>
|
||||
<h2>@(Id is null ? "Nová kategorie" : "Upravit kategorii")</h2>
|
||||
<p>Vyplňte základní informace o kategorii.</p>
|
||||
</div>
|
||||
|
||||
@if (notFound)
|
||||
{
|
||||
<div class="wj-panel">
|
||||
<div class="alert alert-warning rounded-4 mb-3">
|
||||
Kategorie nebyla nalezena.
|
||||
</div>
|
||||
<a class="wj-button wj-button-secondary" href="/admin/kategorie">
|
||||
Zpět na seznam
|
||||
</a>
|
||||
}
|
||||
else if (loading)
|
||||
{
|
||||
<div class="ao-loading">Načítám…</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<section class="ao-panel" style="max-width:560px;margin:0 auto">
|
||||
<div class="ap-field">
|
||||
<label>Název</label>
|
||||
<input class="ao-input" @bind="name" />
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="wj-form-card">
|
||||
<div class="wj-form-header">
|
||||
<div class="wj-form-icon">📁</div>
|
||||
<div>
|
||||
<h4>Informace o kategorii</h4>
|
||||
<p>Název a adresa kategorie</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<EditForm Model="form" OnValidSubmit="Save" FormName="categoryForm">
|
||||
<DataAnnotationsValidator />
|
||||
<ValidationSummary class="text-danger mb-3" />
|
||||
|
||||
@if (!string.IsNullOrEmpty(error))
|
||||
{
|
||||
<div class="alert alert-danger rounded-4">@error</div>
|
||||
}
|
||||
|
||||
<div class="wj-field">
|
||||
<label for="name">Název kategorie</label>
|
||||
<InputText id="name"
|
||||
class="form-control wj-input"
|
||||
placeholder="Např. Cukroví"
|
||||
@bind-Value="form.Name" />
|
||||
<ValidationMessage For="@(() => form.Name)" class="text-danger small" />
|
||||
</div>
|
||||
|
||||
<div class="wj-field">
|
||||
<label for="slug">Adresa kategorie (slug)</label>
|
||||
<InputText id="slug"
|
||||
class="form-control wj-input"
|
||||
placeholder="napr-cukrovi"
|
||||
@bind-Value="form.Slug" />
|
||||
<small>Pokud pole necháte prázdné, adresa se vytvoří automaticky z názvu.</small>
|
||||
</div>
|
||||
|
||||
<div class="wj-switch-card">
|
||||
<div class="form-check form-switch">
|
||||
<InputCheckbox id="active"
|
||||
class="form-check-input"
|
||||
@bind-Value="form.IsActive" />
|
||||
<label class="form-check-label fw-semibold" for="active">
|
||||
Aktivní kategorie
|
||||
</label>
|
||||
</div>
|
||||
<small>Aktivní kategorie může být nabízena zákazníkům.</small>
|
||||
</div>
|
||||
|
||||
<div class="wj-form-actions">
|
||||
<button type="submit" class="wj-button wj-button-primary">
|
||||
Uložit kategorii
|
||||
</button>
|
||||
<a class="wj-button wj-button-secondary" href="/admin/kategorie">
|
||||
Zrušit
|
||||
</a>
|
||||
</div>
|
||||
</EditForm>
|
||||
<div class="ap-field">
|
||||
<label>Slug</label>
|
||||
<input class="ao-input" @bind="categorySlug" />
|
||||
<small class="ap-help">Když necháš prázdné, vytvoří se z názvu.</small>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</AuthorizeView>
|
||||
|
||||
<label class="ap-switch">
|
||||
<input type="checkbox" @bind="isActive" />
|
||||
<span>Aktivní kategorie</span>
|
||||
</label>
|
||||
|
||||
<div class="ap-form-actions">
|
||||
<button type="button" class="ap-btn ap-btn-primary" disabled="@saving" @onclick="SaveAsync">
|
||||
@(saving ? "Ukládám…" : "Uložit")
|
||||
</button>
|
||||
<a class="ap-btn" href="/admin/kategorie">Zrušit</a>
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public int? Id { get; set; }
|
||||
[Parameter]
|
||||
public int? Id { get; set; }
|
||||
|
||||
private CategoryForm form = new();
|
||||
private string? error;
|
||||
private bool IsNew => Id is null;
|
||||
|
||||
private string name = "";
|
||||
private string categorySlug = "";
|
||||
private bool isActive = true;
|
||||
|
||||
private bool loading = true;
|
||||
private bool saving;
|
||||
private bool notFound;
|
||||
private string? error;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
loading = true;
|
||||
notFound = false;
|
||||
error = null;
|
||||
|
||||
if (Id is null) return;
|
||||
if (IsNew)
|
||||
{
|
||||
name = "";
|
||||
categorySlug = "";
|
||||
isActive = true;
|
||||
loading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
var cat = await Db.Set<Category>()
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync(c => c.Id == Id);
|
||||
|
||||
if (cat is null)
|
||||
var entity = await Db.Categories.AsNoTracking().FirstOrDefaultAsync(c => c.Id == Id!.Value);
|
||||
if (entity is null)
|
||||
{
|
||||
notFound = true;
|
||||
loading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
form = new CategoryForm
|
||||
{
|
||||
Name = cat.Name,
|
||||
Slug = cat.Slug,
|
||||
IsActive = cat.IsActive
|
||||
};
|
||||
name = entity.Name ?? "";
|
||||
categorySlug = entity.Slug ?? "";
|
||||
isActive = entity.IsActive;
|
||||
loading = false;
|
||||
}
|
||||
|
||||
private async Task Save()
|
||||
private async Task SaveAsync()
|
||||
{
|
||||
saving = true;
|
||||
error = null;
|
||||
|
||||
var name = form.Name.Trim();
|
||||
var slug = Slugify(string.IsNullOrWhiteSpace(form.Slug) ? name : form.Slug);
|
||||
|
||||
if (string.IsNullOrEmpty(slug))
|
||||
try
|
||||
{
|
||||
error = "Ze zadaného názvu nelze vytvořit slug.";
|
||||
return;
|
||||
}
|
||||
|
||||
var slugTaken = await Db.Set<Category>()
|
||||
.AnyAsync(c => c.Slug == slug && c.Id != (Id ?? 0));
|
||||
|
||||
if (slugTaken)
|
||||
{
|
||||
error = $"Slug „{slug}“ už používá jiná kategorie.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (Id is null)
|
||||
{
|
||||
Db.Set<Category>().Add(new Category
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
Name = name,
|
||||
Slug = slug,
|
||||
IsActive = form.IsActive
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var cat = await Db.Set<Category>().FindAsync(Id);
|
||||
|
||||
if (cat is null)
|
||||
{
|
||||
notFound = true;
|
||||
error = "Zadejte název kategorie.";
|
||||
return;
|
||||
}
|
||||
|
||||
cat.Name = name;
|
||||
cat.Slug = slug;
|
||||
cat.IsActive = form.IsActive;
|
||||
var finalSlug = string.IsNullOrWhiteSpace(categorySlug)
|
||||
? name.Trim().ToLowerInvariant().Replace(' ', '-')
|
||||
: categorySlug.Trim();
|
||||
|
||||
Category entity;
|
||||
if (IsNew)
|
||||
{
|
||||
entity = new Category();
|
||||
Db.Categories.Add(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
entity = await Db.Categories.FirstAsync(c => c.Id == Id!.Value);
|
||||
}
|
||||
|
||||
entity.Name = name.Trim();
|
||||
entity.Slug = finalSlug;
|
||||
entity.IsActive = isActive;
|
||||
|
||||
await Db.SaveChangesAsync();
|
||||
Nav.NavigateTo("/admin/kategorie");
|
||||
}
|
||||
|
||||
await Db.SaveChangesAsync();
|
||||
Nav.NavigateTo("/admin/kategorie");
|
||||
}
|
||||
|
||||
private static string Slugify(string text)
|
||||
{
|
||||
var normalized = text.Trim()
|
||||
.ToLowerInvariant()
|
||||
.Normalize(NormalizationForm.FormD);
|
||||
|
||||
var sb = new StringBuilder();
|
||||
|
||||
foreach (var ch in normalized)
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (CharUnicodeInfo.GetUnicodeCategory(ch) != UnicodeCategory.NonSpacingMark)
|
||||
sb.Append(ch);
|
||||
error = "Uložení se nezdařilo: " + ex.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
saving = false;
|
||||
}
|
||||
|
||||
var noDiacritics = sb.ToString().Normalize(NormalizationForm.FormC);
|
||||
return Regex.Replace(noDiacritics, "[^a-z0-9]+", "-").Trim('-');
|
||||
}
|
||||
|
||||
private class CategoryForm
|
||||
{
|
||||
[Required(ErrorMessage = "Zadej název kategorie.")]
|
||||
[StringLength(100, ErrorMessage = "Název může mít nejvýše 100 znaků.")]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
public string? Slug { get; set; }
|
||||
public bool IsActive { get; set; } = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,211 +2,106 @@
|
||||
@layout Web_Jarmark.Components.Layout.Admin.AdminLayout
|
||||
@rendermode InteractiveServer
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Web_Jarmark.Data
|
||||
@using Web_Jarmark.Data.Models
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@inject ApplicationDbContext Db
|
||||
@inject NavigationManager Nav
|
||||
|
||||
@attribute [Authorize]
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
|
||||
<AuthorizeView>
|
||||
<PageTitle>Kategorie</PageTitle>
|
||||
<PageTitle>Kategorie</PageTitle>
|
||||
|
||||
<div class="wj-admin-page container-fluid py-3">
|
||||
<div class="wj-page-back">
|
||||
<a href="/admin" class="wj-back-admin">
|
||||
<span aria-hidden="true">←</span>
|
||||
Zpět na administraci
|
||||
</a>
|
||||
<div class="ap ao">
|
||||
<header class="ao-hero">
|
||||
<p class="ao-eyebrow">Administrace</p>
|
||||
<h1>Kategorie</h1>
|
||||
<p class="ao-sub">Správa kategorií sortimentu.</p>
|
||||
<div style="margin-top:16px">
|
||||
<a class="ap-btn ap-btn-primary" href="/admin/kategorie/edit">Nová kategorie</a>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="d-flex flex-wrap justify-content-between align-items-center gap-3 mb-4">
|
||||
<div>
|
||||
<div class="text-muted small mb-1">ADMINISTRACE / SPRÁVA OBCHODU</div>
|
||||
<h2 class="fw-bold mb-1">Kategorie</h2>
|
||||
<p class="text-muted mb-0">Spravujte kategorie svého zboží.</p>
|
||||
</div>
|
||||
@if (!string.IsNullOrEmpty(error))
|
||||
{
|
||||
<div class="ao-alert">@error</div>
|
||||
}
|
||||
|
||||
<a class="btn btn-primary rounded-3 px-4 py-2 shadow-sm"
|
||||
href="/admin/kategorie/edit">
|
||||
<span class="me-2">+</span> Nová kategorie
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(error))
|
||||
{
|
||||
<div class="alert alert-danger rounded-3 shadow-sm">
|
||||
@error
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (categories is null)
|
||||
{
|
||||
<div class="card border-0 shadow-sm rounded-4 p-4">
|
||||
<div class="text-muted">Načítám kategorie…</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="card border-0 shadow-sm rounded-4 mb-4">
|
||||
<div class="card-body p-4">
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<div class="rounded-3 bg-primary bg-opacity-10 text-primary p-3 fs-3">
|
||||
🗂️
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-muted small">Celkem kategorií</div>
|
||||
<div class="fs-3 fw-bold">@categories.Count</div>
|
||||
</div>
|
||||
</div>
|
||||
@if (items is null)
|
||||
{
|
||||
<div class="ao-loading">Načítám kategorie…</div>
|
||||
}
|
||||
else if (items.Count == 0)
|
||||
{
|
||||
<div class="ao-empty">Zatím žádné kategorie.</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<section class="ao-panel">
|
||||
<div class="ao-panel-head">
|
||||
<div>
|
||||
<h2>Seznam kategorií</h2>
|
||||
<p>@items.Count položek</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card border-0 shadow-sm rounded-4 overflow-hidden">
|
||||
<div class="card-header bg-white border-0 px-4 pt-4 pb-3">
|
||||
<h5 class="fw-bold mb-1">Přehled kategorií</h5>
|
||||
<div class="text-muted small">Seznam všech kategorií v obchodě</div>
|
||||
</div>
|
||||
|
||||
@if (categories.Count == 0)
|
||||
<div class="ao-list">
|
||||
@foreach (var c in items)
|
||||
{
|
||||
<div class="text-center p-5">
|
||||
<div class="fs-1 mb-3">📂</div>
|
||||
<h5 class="fw-bold">Zatím tu nejsou žádné kategorie</h5>
|
||||
<p class="text-muted">Začněte vytvořením první kategorie.</p>
|
||||
<a class="btn btn-primary rounded-3 px-4"
|
||||
href="/admin/kategorie/edit">
|
||||
+ Přidat kategorii
|
||||
</a>
|
||||
</div>
|
||||
<article class="ao-card" @key="c.Id">
|
||||
<div class="ao-card-main" style="cursor:default">
|
||||
<div class="ao-card-left">
|
||||
<span class="ao-code">@c.Name</span>
|
||||
<span class="ao-date">@c.Slug</span>
|
||||
</div>
|
||||
<div class="ao-card-mid">
|
||||
<span class="ao-pay">@c.ProductCount produktů</span>
|
||||
</div>
|
||||
<div class="ao-card-right">
|
||||
<span class="ao-badge @(c.IsActive ? "is-paid" : "is-cancel")">
|
||||
@(c.IsActive ? "Aktivní" : "Neaktivní")
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sklad-row">
|
||||
<a class="ap-btn ap-btn-ghost" href="@($"/admin/kategorie/edit/{c.Id}")">Upravit</a>
|
||||
</div>
|
||||
</article>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th class="ps-4 py-3">Název kategorie</th>
|
||||
<th class="py-3">Adresa (slug)</th>
|
||||
<th class="text-center py-3">Počet produktů</th>
|
||||
<th class="text-center py-3">Stav</th>
|
||||
<th class="text-end pe-4 py-3">Akce</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var c in categories)
|
||||
{
|
||||
<tr>
|
||||
<td class="ps-4 py-3 fw-semibold">
|
||||
<span class="me-2">📁</span>@c.Name
|
||||
</td>
|
||||
<td>
|
||||
<code class="bg-light px-2 py-1 rounded">@c.Slug</code>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span class="badge bg-light text-dark rounded-pill px-3 py-2">
|
||||
@c.ProductCount
|
||||
</span>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
@if (c.IsActive)
|
||||
{
|
||||
<span class="badge bg-success bg-opacity-10 text-success rounded-pill px-3 py-2">
|
||||
Aktivní
|
||||
</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="badge bg-secondary bg-opacity-10 text-secondary rounded-pill px-3 py-2">
|
||||
Neaktivní
|
||||
</span>
|
||||
}
|
||||
|
||||
<div class="form-check form-switch d-flex justify-content-center mt-2">
|
||||
<input type="checkbox"
|
||||
class="form-check-input"
|
||||
checked="@c.IsActive"
|
||||
title="Změnit aktivitu"
|
||||
@onchange="() => ToggleActive(c.Id)" />
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-end pe-4">
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<a class="btn btn-sm btn-outline-primary rounded-3 px-3"
|
||||
href="/admin/kategorie/edit/@c.Id">
|
||||
Upravit
|
||||
</a>
|
||||
<button class="btn btn-sm btn-outline-danger rounded-3 px-3"
|
||||
disabled="@(c.ProductCount > 0)"
|
||||
title="@(c.ProductCount > 0 ? "Kategorie obsahuje produkty" : "Smazat")"
|
||||
@onclick="() => Delete(c.Id)">
|
||||
Smazat
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="card-footer bg-white border-0 px-4 py-3">
|
||||
<small class="text-muted">
|
||||
Zobrazeno kategorií: @categories.Count
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</AuthorizeView>
|
||||
</section>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private List<CategoryRow>? categories;
|
||||
private List<Row>? items;
|
||||
private string? error;
|
||||
|
||||
protected override async Task OnInitializedAsync() => await Load();
|
||||
|
||||
private async Task Load()
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
categories = await Db.Set<Category>()
|
||||
.AsNoTracking()
|
||||
.OrderBy(c => c.Name)
|
||||
.Select(c => new CategoryRow(c.Id, c.Name, c.Slug, c.IsActive, c.Products.Count))
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
private async Task ToggleActive(int id)
|
||||
{
|
||||
var cat = await Db.Set<Category>().FindAsync(id);
|
||||
if (cat is null) return;
|
||||
|
||||
cat.IsActive = !cat.IsActive;
|
||||
await Db.SaveChangesAsync();
|
||||
await Load();
|
||||
}
|
||||
|
||||
private async Task Delete(int id)
|
||||
{
|
||||
error = null;
|
||||
|
||||
var cat = await Db.Set<Category>()
|
||||
.Include(c => c.Products)
|
||||
.FirstOrDefaultAsync(c => c.Id == id);
|
||||
|
||||
if (cat is null) return;
|
||||
|
||||
if (cat.Products.Count > 0)
|
||||
try
|
||||
{
|
||||
error = "Kategorii nelze smazat, obsahuje produkty.";
|
||||
return;
|
||||
items = await Db.Categories
|
||||
.AsNoTracking()
|
||||
.OrderBy(c => c.Name)
|
||||
.Select(c => new Row(
|
||||
c.Id,
|
||||
c.Name,
|
||||
c.Slug,
|
||||
c.IsActive,
|
||||
c.Products.Count))
|
||||
.ToListAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
error = "Nepodařilo se načíst kategorie: " + ex.Message;
|
||||
items = new();
|
||||
}
|
||||
|
||||
Db.Set<Category>().Remove(cat);
|
||||
await Db.SaveChangesAsync();
|
||||
await Load();
|
||||
}
|
||||
|
||||
private record CategoryRow(int Id, string Name, string Slug, bool IsActive, int ProductCount);
|
||||
}
|
||||
private sealed record Row(
|
||||
int Id,
|
||||
string Name,
|
||||
string Slug,
|
||||
bool IsActive,
|
||||
int ProductCount);
|
||||
}
|
||||
130
Web-Jarmark/Web-Jarmark/Components/Pages/Admin/Nastaveni.razor
Normal file
130
Web-Jarmark/Web-Jarmark/Components/Pages/Admin/Nastaveni.razor
Normal file
@@ -0,0 +1,130 @@
|
||||
@page "/admin/nastaveni"
|
||||
@layout Web_Jarmark.Components.Layout.Admin.AdminLayout
|
||||
@rendermode InteractiveServer
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Microsoft.AspNetCore.Identity
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Microsoft.AspNetCore.Components.Authorization
|
||||
@using Web_Jarmark.Data
|
||||
@using Web_Jarmark.Data.Models
|
||||
@inject ApplicationDbContext Db
|
||||
@inject UserManager<ApplicationUser> UserManager
|
||||
@inject AuthenticationStateProvider AuthState
|
||||
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
|
||||
<PageTitle>Nastavení</PageTitle>
|
||||
|
||||
<div class="ap ao">
|
||||
<header class="ao-hero">
|
||||
<p class="ao-eyebrow">Administrace</p>
|
||||
<h1>Nastavení</h1>
|
||||
<p class="ao-sub">Účet, e-shop a rychlé odkazy.</p>
|
||||
</header>
|
||||
|
||||
@if (loading)
|
||||
{
|
||||
<div class="ao-loading">Načítám…</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<section class="ao-stats">
|
||||
<article class="ao-stat">
|
||||
<span>Uživatelé</span>
|
||||
<strong>@userCount</strong>
|
||||
<small>registrovaných</small>
|
||||
</article>
|
||||
<article class="ao-stat">
|
||||
<span>Administrátoři</span>
|
||||
<strong>@adminCount</strong>
|
||||
<small>role Admin</small>
|
||||
</article>
|
||||
<article class="ao-stat">
|
||||
<span>Produkty</span>
|
||||
<strong>@productCount</strong>
|
||||
<small>v katalogu</small>
|
||||
</article>
|
||||
<article class="ao-stat">
|
||||
<span>Objednávky</span>
|
||||
<strong>@orderCount</strong>
|
||||
<small>celkem</small>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="ao-panel">
|
||||
<div class="ao-panel-head">
|
||||
<div>
|
||||
<h2>Tvůj účet</h2>
|
||||
<p>Přihlášený administrátor</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ao-list">
|
||||
<div class="ao-item">
|
||||
<div><strong>E-mail</strong><span>přihlášení</span></div>
|
||||
<strong>@currentEmail</strong>
|
||||
</div>
|
||||
<div class="ao-item">
|
||||
<div><strong>Role</strong><span>oprávnění</span></div>
|
||||
<strong>@currentRoles</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sklad-row">
|
||||
<a class="ap-btn ap-btn-ghost" href="/Account/Manage">Správa účtu</a>
|
||||
<a class="ap-btn ap-btn-ghost" href="/Account/Manage/ChangePassword">Změna hesla</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="ao-panel" style="margin-top:14px">
|
||||
<div class="ao-panel-head">
|
||||
<div>
|
||||
<h2>Rychlé odkazy</h2>
|
||||
<p>Administrace e-shopu</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sklad-row">
|
||||
<a class="ap-btn" href="/">E-shop</a>
|
||||
<a class="ap-btn" href="/admin">Přehled</a>
|
||||
<a class="ap-btn" href="/admin/administratori">Uživatelé</a>
|
||||
<a class="ap-btn" href="/admin/sklad">Sklad</a>
|
||||
<a class="ap-btn" href="/admin/objednavky">Objednávky</a>
|
||||
<a class="ap-btn" href="/admin/statistiky">Statistiky</a>
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private bool loading = true;
|
||||
private int userCount, adminCount, productCount, orderCount;
|
||||
private string currentEmail = "—";
|
||||
private string currentRoles = "—";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
userCount = await UserManager.Users.CountAsync();
|
||||
var admins = await UserManager.GetUsersInRoleAsync("Admin");
|
||||
adminCount = admins.Count;
|
||||
productCount = await Db.Products.CountAsync();
|
||||
orderCount = await Db.Orders.CountAsync();
|
||||
|
||||
var state = await AuthState.GetAuthenticationStateAsync();
|
||||
var user = state.User;
|
||||
if (user.Identity?.IsAuthenticated == true)
|
||||
{
|
||||
currentEmail = user.Identity?.Name ?? "—";
|
||||
var appUser = await UserManager.FindByEmailAsync(currentEmail);
|
||||
if (appUser is not null)
|
||||
{
|
||||
var roles = await UserManager.GetRolesAsync(appUser);
|
||||
currentRoles = roles.Count == 0 ? "bez role" : string.Join(", ", roles);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
231
Web-Jarmark/Web-Jarmark/Components/Pages/Admin/Objednavky.razor
Normal file
231
Web-Jarmark/Web-Jarmark/Components/Pages/Admin/Objednavky.razor
Normal file
@@ -0,0 +1,231 @@
|
||||
@page "/admin/objednavky"
|
||||
@layout Web_Jarmark.Components.Layout.Admin.AdminLayout
|
||||
@rendermode InteractiveServer
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Web_Jarmark.Data
|
||||
@using Web_Jarmark.Data.Models
|
||||
@inject ApplicationDbContext Db
|
||||
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
|
||||
<PageTitle>Objednávky</PageTitle>
|
||||
|
||||
<div class="ap ao">
|
||||
<header class="ao-hero">
|
||||
<p class="ao-eyebrow">Administrace</p>
|
||||
<h1>Objednávky</h1>
|
||||
<p class="ao-sub">Přehled všech objednávek a jejich aktuálního stavu.</p>
|
||||
</header>
|
||||
|
||||
@if (isLoading)
|
||||
{
|
||||
<div class="ao-loading">Načítám objednávky…</div>
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(errorMessage))
|
||||
{
|
||||
<div class="ao-alert">@errorMessage</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<section class="ao-stats">
|
||||
<article class="ao-stat" style="--i:0">
|
||||
<span>Celkem</span>
|
||||
<strong>@orders.Count</strong>
|
||||
<small>objednávek</small>
|
||||
</article>
|
||||
<article class="ao-stat" style="--i:1">
|
||||
<span>Čeká na zaplacení</span>
|
||||
<strong>@orders.Count(o => o.Status == OrderStatus.Pending)</strong>
|
||||
<small>k vyřízení</small>
|
||||
</article>
|
||||
<article class="ao-stat" style="--i:2">
|
||||
<span>Zaplaceno</span>
|
||||
<strong>@orders.Count(o => o.Status == OrderStatus.Paid)</strong>
|
||||
<small>uhrazeno</small>
|
||||
</article>
|
||||
<article class="ao-stat" style="--i:3">
|
||||
<span>Hodnota</span>
|
||||
<strong>@orders.Sum(o => o.TotalAmount).ToString("N0")</strong>
|
||||
<small>Kč celkem</small>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="ao-panel" style="--i:4">
|
||||
<div class="ao-panel-head">
|
||||
<div>
|
||||
<h2>Seznam objednávek</h2>
|
||||
<p>@FilteredOrders.Count zobrazených</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ao-filters">
|
||||
<input class="ao-input"
|
||||
placeholder="Hledat podle kódu…"
|
||||
@bind="searchText"
|
||||
@bind:event="oninput" />
|
||||
|
||||
<select class="ao-select" @bind="statusFilter">
|
||||
<option value="Vše">Všechny stavy</option>
|
||||
<option value="Čeká na zaplacení">Čeká na zaplacení</option>
|
||||
<option value="Zaplaceno">Zaplaceno</option>
|
||||
<option value="Odesláno">Odesláno</option>
|
||||
<option value="Dokončeno">Dokončeno</option>
|
||||
<option value="Zrušeno">Zrušeno</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@if (FilteredOrders.Count == 0)
|
||||
{
|
||||
<div class="ao-empty">Žádné objednávky k zobrazení.</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="ao-list">
|
||||
@foreach (var order in FilteredOrders)
|
||||
{
|
||||
var open = selectedOrderId == order.Id;
|
||||
|
||||
<article class="ao-card @(open ? "is-open" : null)" @key="order.Id">
|
||||
<button type="button" class="ao-card-main" @onclick="() => ToggleDetail(order.Id)">
|
||||
<div class="ao-card-left">
|
||||
<span class="ao-code">#@order.Code</span>
|
||||
<span class="ao-date">@order.CreatedAt.ToLocalTime().ToString("d. M. yyyy HH:mm")</span>
|
||||
</div>
|
||||
<div class="ao-card-mid">
|
||||
<span class="ao-pay">@GetPaymentText(order.PreferredPayment)</span>
|
||||
<span class="ao-qty">@order.OrderItems.Sum(i => i.Quantity) ks</span>
|
||||
</div>
|
||||
<div class="ao-card-right">
|
||||
<span class="ao-price">@order.TotalAmount.ToString("N0") Kč</span>
|
||||
<span class="ao-badge @GetBadgeClass(order.Status)">@GetStatusText(order.Status)</span>
|
||||
</div>
|
||||
<span class="ao-chevron @(open ? "is-open" : null)">›</span>
|
||||
</button>
|
||||
|
||||
@if (open)
|
||||
{
|
||||
<div class="ao-detail">
|
||||
<div class="ao-detail-grid">
|
||||
<div>
|
||||
<span>Zákazník</span>
|
||||
<strong>@(string.IsNullOrWhiteSpace(order.CustomerName) ? "—" : order.CustomerName)</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span>E-mail</span>
|
||||
<strong>@(string.IsNullOrWhiteSpace(order.Email) ? "—" : order.Email)</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span>Telefon</span>
|
||||
<strong>@(string.IsNullOrWhiteSpace(order.Phone) ? "—" : order.Phone)</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span>Stav</span>
|
||||
<strong>@GetStatusText(order.Status)</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrWhiteSpace(order.Note))
|
||||
{
|
||||
<p class="ao-note">@order.Note</p>
|
||||
}
|
||||
|
||||
<div class="ao-items">
|
||||
@foreach (var item in order.OrderItems)
|
||||
{
|
||||
<div class="ao-item">
|
||||
<div>
|
||||
<strong>@item.ProductName</strong>
|
||||
<span>@item.Quantity ks × @item.UnitPrice.ToString("N0") Kč</span>
|
||||
</div>
|
||||
<strong>@((item.Quantity * item.UnitPrice).ToString("N0")) Kč</strong>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="ao-total">
|
||||
<span>Celkem</span>
|
||||
<strong>@order.TotalAmount.ToString("N0") Kč</strong>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</article>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private List<Order> orders = new();
|
||||
private bool isLoading = true;
|
||||
private string? errorMessage;
|
||||
private string searchText = "";
|
||||
private string statusFilter = "Vše";
|
||||
private int? selectedOrderId;
|
||||
|
||||
private List<Order> FilteredOrders =>
|
||||
orders
|
||||
.Where(o =>
|
||||
string.IsNullOrWhiteSpace(searchText) ||
|
||||
o.Code.Contains(searchText.Trim(), StringComparison.OrdinalIgnoreCase))
|
||||
.Where(o =>
|
||||
statusFilter == "Vše" ||
|
||||
GetStatusText(o.Status) == statusFilter)
|
||||
.ToList();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
orders = await Db.Orders
|
||||
.AsNoTracking()
|
||||
.Include(o => o.OrderItems)
|
||||
.OrderByDescending(o => o.CreatedAt)
|
||||
.ToListAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
errorMessage = "Objednávky se nepodařilo načíst.";
|
||||
}
|
||||
finally
|
||||
{
|
||||
isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleDetail(int orderId)
|
||||
{
|
||||
selectedOrderId = selectedOrderId == orderId ? null : orderId;
|
||||
}
|
||||
|
||||
private static string GetStatusText(OrderStatus status) => status switch
|
||||
{
|
||||
OrderStatus.Pending => "Čeká na zaplacení",
|
||||
OrderStatus.Paid => "Zaplaceno",
|
||||
OrderStatus.Shipped => "Odesláno",
|
||||
OrderStatus.Delivered => "Dokončeno",
|
||||
OrderStatus.Cancelled => "Zrušeno",
|
||||
_ => "Neznámý stav"
|
||||
};
|
||||
|
||||
private static string GetBadgeClass(OrderStatus status) => status switch
|
||||
{
|
||||
OrderStatus.Pending => "is-pending",
|
||||
OrderStatus.Paid => "is-paid",
|
||||
OrderStatus.Shipped => "is-shipped",
|
||||
OrderStatus.Delivered => "is-done",
|
||||
OrderStatus.Cancelled => "is-cancel",
|
||||
_ => ""
|
||||
};
|
||||
|
||||
private static string GetPaymentText(PaymentMethod method) => method switch
|
||||
{
|
||||
PaymentMethod.BankTransfer => "Bankovní převod",
|
||||
PaymentMethod.Cash => "Hotově",
|
||||
PaymentMethod.CreditCard => "Karta",
|
||||
PaymentMethod.PayPal => "PayPal",
|
||||
_ => "—"
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,426 @@
|
||||
/* Apple-like objednávky */
|
||||
|
||||
.ao {
|
||||
max-width: 980px;
|
||||
margin: 0 auto;
|
||||
color: #1d1d1f;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
.ao-hero {
|
||||
text-align: center;
|
||||
padding: 18px 8px 28px;
|
||||
animation: ao-in 0.45s ease both;
|
||||
}
|
||||
|
||||
.ao-eyebrow {
|
||||
margin: 0 0 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: #6e6e73;
|
||||
}
|
||||
|
||||
.ao-hero h1 {
|
||||
margin: 0;
|
||||
font-size: 36px;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.03em;
|
||||
}
|
||||
|
||||
.ao-sub {
|
||||
margin: 10px auto 0;
|
||||
max-width: 420px;
|
||||
color: #6e6e73;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.ao-loading,
|
||||
.ao-empty,
|
||||
.ao-alert {
|
||||
padding: 20px;
|
||||
border-radius: 20px;
|
||||
background: #fff;
|
||||
border: 1px solid rgba(0, 0, 0, 0.05);
|
||||
color: #6e6e73;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.ao-alert {
|
||||
color: #1d1d1f;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
/* Stats */
|
||||
.ao-stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.ao-stat {
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
border: 1px solid rgba(0, 0, 0, 0.04);
|
||||
border-radius: 22px;
|
||||
padding: 18px 16px;
|
||||
box-shadow: 0 10px 28px rgba(0, 0, 0, 0.04);
|
||||
animation: ao-rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
|
||||
animation-delay: calc(var(--i, 0) * 0.06s);
|
||||
transition: transform 0.25s ease, box-shadow 0.25s ease;
|
||||
}
|
||||
|
||||
.ao-stat:hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: 0 14px 34px rgba(0, 0, 0, 0.07);
|
||||
}
|
||||
|
||||
.ao-stat span {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #6e6e73;
|
||||
}
|
||||
|
||||
.ao-stat strong {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
font-size: 28px;
|
||||
font-weight: 750;
|
||||
letter-spacing: -0.03em;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.ao-stat small {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: #86868b;
|
||||
}
|
||||
|
||||
/* Panel */
|
||||
.ao-panel {
|
||||
background: rgba(255, 255, 255, 0.92);
|
||||
border: 1px solid rgba(0, 0, 0, 0.045);
|
||||
border-radius: 26px;
|
||||
padding: 18px 18px 12px;
|
||||
box-shadow: 0 12px 36px rgba(0, 0, 0, 0.04);
|
||||
animation: ao-rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
|
||||
animation-delay: calc(var(--i, 0) * 0.06s);
|
||||
}
|
||||
|
||||
.ao-panel-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
padding: 4px 6px 14px;
|
||||
}
|
||||
|
||||
.ao-panel-head h2 {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.ao-panel-head p {
|
||||
margin: 4px 0 0;
|
||||
color: #6e6e73;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.ao-filters {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
padding: 0 6px 16px;
|
||||
}
|
||||
|
||||
.ao-input,
|
||||
.ao-select {
|
||||
border: 1px solid #d2d2d7;
|
||||
border-radius: 14px;
|
||||
padding: 12px 14px;
|
||||
font-size: 14px;
|
||||
background: #fff;
|
||||
color: #1d1d1f;
|
||||
outline: none;
|
||||
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
.ao-input {
|
||||
flex: 1;
|
||||
min-width: 180px;
|
||||
}
|
||||
|
||||
.ao-select {
|
||||
min-width: 190px;
|
||||
}
|
||||
|
||||
.ao-input:focus,
|
||||
.ao-select:focus {
|
||||
border-color: #1d1d1f;
|
||||
box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
/* Cards list */
|
||||
.ao-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.ao-card {
|
||||
border: 1px solid rgba(0, 0, 0, 0.05);
|
||||
border-radius: 20px;
|
||||
background: #fafafa;
|
||||
overflow: hidden;
|
||||
transition: background 0.2s ease, box-shadow 0.25s ease, transform 0.2s ease;
|
||||
}
|
||||
|
||||
.ao-card:hover {
|
||||
background: #f5f5f7;
|
||||
}
|
||||
|
||||
.ao-card.is-open {
|
||||
background: #fff;
|
||||
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.ao-card-main {
|
||||
width: 100%;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
display: grid;
|
||||
grid-template-columns: 1.2fr 1fr 1fr auto;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
padding: 16px 16px;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.ao-card-left,
|
||||
.ao-card-mid,
|
||||
.ao-card-right {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.ao-card-right {
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.ao-code {
|
||||
font-weight: 750;
|
||||
font-size: 15px;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.ao-date,
|
||||
.ao-pay,
|
||||
.ao-qty {
|
||||
font-size: 12px;
|
||||
color: #6e6e73;
|
||||
}
|
||||
|
||||
.ao-price {
|
||||
font-weight: 750;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.ao-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 4px 10px;
|
||||
border-radius: 999px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
background: #f0f0f2;
|
||||
color: #6e6e73;
|
||||
}
|
||||
|
||||
.ao-badge.is-pending {
|
||||
background: #f0f0f2;
|
||||
color: #1d1d1f;
|
||||
}
|
||||
|
||||
.ao-badge.is-paid {
|
||||
background: #1d1d1f;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.ao-badge.is-shipped {
|
||||
background: #3a3a3c;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.ao-badge.is-done {
|
||||
background: #1d1d1f;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.ao-badge.is-cancel {
|
||||
background: #e8e8ed;
|
||||
color: #6e6e73;
|
||||
}
|
||||
|
||||
.ao-chevron {
|
||||
font-size: 22px;
|
||||
color: #aeaeb2;
|
||||
transform: rotate(0deg);
|
||||
transition: transform 0.25s ease;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.ao-chevron.is-open {
|
||||
transform: rotate(90deg);
|
||||
color: #1d1d1f;
|
||||
}
|
||||
|
||||
/* Detail */
|
||||
.ao-detail {
|
||||
padding: 0 16px 16px;
|
||||
animation: ao-detail 0.28s ease both;
|
||||
}
|
||||
|
||||
.ao-detail-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.ao-detail-grid span {
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
color: #6e6e73;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.ao-detail-grid strong {
|
||||
font-size: 13px;
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.ao-note {
|
||||
margin: 0 0 12px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 14px;
|
||||
background: #f5f5f7;
|
||||
color: #6e6e73;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.ao-items {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.ao-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 14px;
|
||||
background: #f5f5f7;
|
||||
}
|
||||
|
||||
.ao-item span {
|
||||
display: block;
|
||||
margin-top: 2px;
|
||||
font-size: 12px;
|
||||
color: #6e6e73;
|
||||
}
|
||||
|
||||
.ao-total {
|
||||
margin-top: 12px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 4px 4px 0;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.ao-total strong {
|
||||
font-size: 18px;
|
||||
font-weight: 750;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
@keyframes ao-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(8px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes ao-rise {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(14px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes ao-detail {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-6px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.ao-stats {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.ao-card-main {
|
||||
grid-template-columns: 1fr auto;
|
||||
grid-template-areas:
|
||||
"left chev"
|
||||
"mid chev"
|
||||
"right chev";
|
||||
}
|
||||
|
||||
.ao-card-left {
|
||||
grid-area: left;
|
||||
}
|
||||
|
||||
.ao-card-mid {
|
||||
grid-area: mid;
|
||||
}
|
||||
|
||||
.ao-card-right {
|
||||
grid-area: right;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.ao-chevron {
|
||||
grid-area: chev;
|
||||
}
|
||||
|
||||
.ao-detail-grid {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
@@ -1,267 +1,317 @@
|
||||
@page "/admin/zbozi/edit"
|
||||
```razor
|
||||
@page "/admin/zbozi/edit"
|
||||
@page "/admin/zbozi/edit/{Id:int}"
|
||||
@layout Web_Jarmark.Components.Layout.Admin.AdminLayout
|
||||
@rendermode InteractiveServer
|
||||
@using System.ComponentModel.DataAnnotations
|
||||
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Web_Jarmark.Data
|
||||
@using Web_Jarmark.Data.Models
|
||||
|
||||
@inject ApplicationDbContext Db
|
||||
@inject NavigationManager Nav
|
||||
|
||||
@attribute [Authorize]
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
|
||||
<AuthorizeView Context="authContext1">
|
||||
<PageTitle>@(Id is null ? "Nové zboží" : "Upravit zboží")</PageTitle>
|
||||
<PageTitle>@(IsNew ? "Nové zboží" : "Upravit zboží")</PageTitle>
|
||||
|
||||
<div class="wj-admin-page container-fluid py-3">
|
||||
<div class="wj-page-back">
|
||||
<a href="/admin" class="wj-back-admin">
|
||||
<span>←</span> Zpět na administraci
|
||||
</a>
|
||||
<div class="ap ao">
|
||||
<header class="ao-hero">
|
||||
<p class="ao-eyebrow">Zboží</p>
|
||||
<h1>@(IsNew ? "Nové zboží" : "Upravit zboží")</h1>
|
||||
<p class="ao-sub">Údaje produktu v katalogu.</p>
|
||||
</header>
|
||||
|
||||
@if (!string.IsNullOrEmpty(error))
|
||||
{
|
||||
<div class="ao-alert">@error</div>
|
||||
}
|
||||
|
||||
@if (notFound)
|
||||
{
|
||||
<div class="ao-empty">Produkt nebyl nalezen.</div>
|
||||
<div style="text-align:center;margin-top:12px">
|
||||
<a class="ap-btn" href="/admin/zbozi">Zpět</a>
|
||||
</div>
|
||||
|
||||
<div class="wj-heading mb-4">
|
||||
<div class="wj-eyebrow">ADMINISTRACE / ZBOŽÍ</div>
|
||||
<h2>@(Id is null ? "Nové zboží" : "Upravit zboží")</h2>
|
||||
<p>Vyplňte informace o produktu.</p>
|
||||
</div>
|
||||
|
||||
@if (notFound)
|
||||
{
|
||||
<div class="wj-panel">
|
||||
<div class="alert alert-warning rounded-4">Zboží nebylo nalezeno.</div>
|
||||
<a class="wj-button wj-button-secondary" href="/admin/zbozi">
|
||||
Zpět na seznam
|
||||
</a>
|
||||
}
|
||||
else if (loading)
|
||||
{
|
||||
<div class="ao-loading">Načítám…</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<section class="ao-panel" style="max-width:560px;margin:0 auto">
|
||||
<div class="ap-field">
|
||||
<label>Název</label>
|
||||
<input class="ao-input" maxlength="150" @bind="name" />
|
||||
</div>
|
||||
}
|
||||
else if (categories is null)
|
||||
{
|
||||
<div class="wj-panel p-4">
|
||||
<span class="text-muted">Načítám…</span>
|
||||
</div>
|
||||
}
|
||||
else if (categories.Count == 0)
|
||||
{
|
||||
<div class="wj-panel">
|
||||
<div class="alert alert-warning rounded-4">
|
||||
Nejdříve musíš vytvořit alespoň jednu kategorii.
|
||||
<a href="/admin/kategorie/edit" class="alert-link">Přidat kategorii</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="wj-form-card wj-product-form">
|
||||
<div class="wj-form-header">
|
||||
<div class="wj-form-icon">📦</div>
|
||||
<div>
|
||||
<h4>Informace o produktu</h4>
|
||||
<p>Základní údaje, cena a sklad</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<EditForm Model="form" OnValidSubmit="Save" FormName="productForm">
|
||||
<DataAnnotationsValidator />
|
||||
<ValidationSummary class="text-danger mb-3" />
|
||||
|
||||
@if (!string.IsNullOrEmpty(error))
|
||||
<div class="ap-field">
|
||||
<label>Kategorie</label>
|
||||
<select class="ao-select" style="width:100%" @bind="categoryId">
|
||||
<option value="0">— vyberte —</option>
|
||||
@foreach (var c in categories)
|
||||
{
|
||||
<div class="alert alert-danger rounded-4">@error</div>
|
||||
<option value="@c.Id">@c.Name</option>
|
||||
}
|
||||
|
||||
<div class="wj-field">
|
||||
<label for="name">Název zboží</label>
|
||||
<InputText id="name"
|
||||
class="form-control wj-input"
|
||||
placeholder="Např. Domácí cukroví"
|
||||
@bind-Value="form.Name" />
|
||||
<ValidationMessage For="@(() => form.Name)" class="text-danger small" />
|
||||
</div>
|
||||
|
||||
<div class="wj-field">
|
||||
<label for="cat">Kategorie</label>
|
||||
<InputSelect id="cat"
|
||||
class="form-select wj-input"
|
||||
@bind-Value="form.CategoryId">
|
||||
<option value="0">– Vyber kategorii –</option>
|
||||
@foreach (var c in categories)
|
||||
{
|
||||
<option value="@c.Id">@c.Name@(c.IsActive ? "" : " (neaktivní)")</option>
|
||||
}
|
||||
</InputSelect>
|
||||
</div>
|
||||
|
||||
<div class="wj-field">
|
||||
<label for="desc">Popis produktu</label>
|
||||
<InputTextArea id="desc"
|
||||
class="form-control wj-input"
|
||||
rows="4"
|
||||
placeholder="Popište produkt…"
|
||||
@bind-Value="form.Description" />
|
||||
</div>
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<div class="wj-field">
|
||||
<label for="price">Cena (Kč)</label>
|
||||
<InputNumber id="price"
|
||||
class="form-control wj-input"
|
||||
@bind-Value="form.Price" />
|
||||
<ValidationMessage For="@(() => form.Price)" class="text-danger small" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="wj-field">
|
||||
<label for="stock">Skladem (ks)</label>
|
||||
<InputNumber id="stock"
|
||||
class="form-control wj-input"
|
||||
@bind-Value="form.StockQuantity" />
|
||||
<ValidationMessage For="@(() => form.StockQuantity)" class="text-danger small" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wj-field">
|
||||
<label for="img">Adresa obrázku</label>
|
||||
<InputText id="img"
|
||||
class="form-control wj-input"
|
||||
placeholder="/images/produkt.jpg"
|
||||
@bind-Value="form.ImageUrl" />
|
||||
<small>Např. /images/cukrovi.jpg (soubor v wwwroot) nebo celá internetová adresa.</small>
|
||||
</div>
|
||||
|
||||
<div class="wj-switch-card">
|
||||
<div class="form-check form-switch">
|
||||
<InputCheckbox id="visible"
|
||||
class="form-check-input"
|
||||
@bind-Value="form.IsVisible" />
|
||||
<label class="form-check-label fw-semibold" for="visible">
|
||||
Viditelné v katalogu
|
||||
</label>
|
||||
</div>
|
||||
<small>Pokud je zapnuto, zákazníci produkt uvidí v e-shopu.</small>
|
||||
</div>
|
||||
|
||||
<div class="wj-form-actions">
|
||||
<button type="submit" class="wj-button wj-button-primary">
|
||||
Uložit zboží
|
||||
</button>
|
||||
<a class="wj-button wj-button-secondary" href="/admin/zbozi">
|
||||
Zrušit
|
||||
</a>
|
||||
</div>
|
||||
</EditForm>
|
||||
</select>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</AuthorizeView>
|
||||
|
||||
<div class="ap-field">
|
||||
<label>Popis</label>
|
||||
<textarea class="ao-input"
|
||||
maxlength="5000"
|
||||
style="min-height:110px;resize:vertical"
|
||||
@bind="description"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="ap-field">
|
||||
<label>Cena (Kč)</label>
|
||||
<input type="number"
|
||||
min="0"
|
||||
step="0.01"
|
||||
class="ao-input"
|
||||
@bind="price" />
|
||||
</div>
|
||||
|
||||
<div class="ap-field">
|
||||
<label>Sklad (ks)</label>
|
||||
<input type="number"
|
||||
min="0"
|
||||
step="1"
|
||||
class="ao-input"
|
||||
@bind="stockQuantity" />
|
||||
</div>
|
||||
|
||||
<div class="ap-field">
|
||||
<label>URL obrázku</label>
|
||||
<input class="ao-input"
|
||||
maxlength="2048"
|
||||
@bind="imageUrl" />
|
||||
</div>
|
||||
|
||||
<label class="ap-switch">
|
||||
<input type="checkbox" @bind="isVisible" />
|
||||
<span>Viditelné v e-shopu</span>
|
||||
</label>
|
||||
|
||||
<div class="ap-form-actions">
|
||||
<button type="button"
|
||||
class="ap-btn ap-btn-primary"
|
||||
disabled="@saving"
|
||||
@onclick="SaveAsync">
|
||||
@(saving ? "Ukládám…" : "Uložit")
|
||||
</button>
|
||||
|
||||
<a class="ap-btn" href="/admin/zbozi">Zrušit</a>
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public int? Id { get; set; }
|
||||
[Parameter]
|
||||
public int? Id { get; set; }
|
||||
|
||||
private ProductForm form = new();
|
||||
private List<Category>? categories;
|
||||
private string? error;
|
||||
private bool IsNew => Id is null;
|
||||
|
||||
private List<CatOption> categories = new();
|
||||
|
||||
private string name = "";
|
||||
private string description = "";
|
||||
private int categoryId;
|
||||
private decimal price;
|
||||
private int stockQuantity;
|
||||
private string imageUrl = "";
|
||||
private bool isVisible = true;
|
||||
|
||||
private bool loading = true;
|
||||
private bool saving;
|
||||
private bool notFound;
|
||||
private string? error;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
loading = true;
|
||||
notFound = false;
|
||||
error = null;
|
||||
|
||||
categories = await Db.Set<Category>()
|
||||
categories = await Db.Categories
|
||||
.AsNoTracking()
|
||||
.OrderBy(c => c.Name)
|
||||
.Select(c => new CatOption(c.Id, c.Name))
|
||||
.ToListAsync();
|
||||
|
||||
if (Id is null) return;
|
||||
if (IsNew)
|
||||
{
|
||||
name = "";
|
||||
description = "";
|
||||
categoryId = 0;
|
||||
price = 0;
|
||||
stockQuantity = 0;
|
||||
imageUrl = "";
|
||||
isVisible = true;
|
||||
loading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
var p = await Db.Set<Product>()
|
||||
var entity = await Db.Products
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync(x => x.Id == Id);
|
||||
.FirstOrDefaultAsync(p => p.Id == Id!.Value);
|
||||
|
||||
if (p is null)
|
||||
if (entity is null)
|
||||
{
|
||||
notFound = true;
|
||||
loading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
form = new ProductForm
|
||||
{
|
||||
Name = p.Name,
|
||||
CategoryId = p.CategoryId,
|
||||
Description = p.Description,
|
||||
Price = p.Price,
|
||||
StockQuantity = p.StockQuantity,
|
||||
ImageUrl = p.ImageUrl,
|
||||
IsVisible = p.IsVisible
|
||||
};
|
||||
name = entity.Name ?? "";
|
||||
description = entity.Description ?? "";
|
||||
categoryId = entity.CategoryId;
|
||||
price = entity.Price;
|
||||
stockQuantity = entity.StockQuantity;
|
||||
imageUrl = entity.ImageUrl ?? "";
|
||||
isVisible = entity.IsVisible;
|
||||
|
||||
loading = false;
|
||||
}
|
||||
|
||||
private async Task Save()
|
||||
private async Task SaveAsync()
|
||||
{
|
||||
if (saving)
|
||||
return;
|
||||
|
||||
saving = true;
|
||||
error = null;
|
||||
|
||||
if (form.CategoryId == 0)
|
||||
try
|
||||
{
|
||||
error = "Vyber kategorii.";
|
||||
return;
|
||||
}
|
||||
name = name?.Trim() ?? "";
|
||||
description = description?.Trim() ?? "";
|
||||
imageUrl = imageUrl?.Trim() ?? "";
|
||||
|
||||
if (Id is null)
|
||||
{
|
||||
var p = new Product();
|
||||
Apply(p);
|
||||
Db.Set<Product>().Add(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
var p = await Db.Set<Product>().FindAsync(Id);
|
||||
|
||||
if (p is null)
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
notFound = true;
|
||||
error = "Zadejte název produktu.";
|
||||
return;
|
||||
}
|
||||
|
||||
Apply(p);
|
||||
if (name.Length > 150)
|
||||
{
|
||||
error = "Název může mít maximálně 150 znaků.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (description.Length > 5000)
|
||||
{
|
||||
error = "Popis může mít maximálně 5000 znaků.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (price < 0 || price > 100000000)
|
||||
{
|
||||
error = "Cena musí být mezi 0 a 100 000 000 Kč.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (decimal.Round(price, 2) != price)
|
||||
{
|
||||
error = "Cena může mít maximálně dvě desetinná místa.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (stockQuantity < 0)
|
||||
{
|
||||
error = "Počet kusů na skladě nemůže být záporný.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (categoryId <= 0 ||
|
||||
!await Db.Categories.AnyAsync(c => c.Id == categoryId))
|
||||
{
|
||||
error = "Vyberte platnou kategorii.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsValidImageUrl(imageUrl))
|
||||
{
|
||||
error = "Obrázek musí mít platnou HTTPS adresu nebo bezpečnou relativní cestu.";
|
||||
return;
|
||||
}
|
||||
|
||||
Product entity;
|
||||
|
||||
if (IsNew)
|
||||
{
|
||||
entity = new Product();
|
||||
Db.Products.Add(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
entity = await Db.Products
|
||||
.FirstOrDefaultAsync(p => p.Id == Id!.Value);
|
||||
|
||||
if (entity is null)
|
||||
{
|
||||
notFound = true;
|
||||
error = "Produkt již neexistuje.";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
entity.Name = name;
|
||||
entity.Description = description;
|
||||
entity.CategoryId = categoryId;
|
||||
entity.Price = price;
|
||||
entity.StockQuantity = stockQuantity;
|
||||
entity.ImageUrl = imageUrl;
|
||||
entity.IsVisible = isVisible;
|
||||
entity.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
await Db.SaveChangesAsync();
|
||||
|
||||
Nav.NavigateTo("/admin/zbozi");
|
||||
}
|
||||
catch (DbUpdateException)
|
||||
{
|
||||
error = "Produkt se nepodařilo uložit. Zkontrolujte zadané údaje.";
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
error = "Při ukládání nastala neočekávaná chyba.";
|
||||
}
|
||||
finally
|
||||
{
|
||||
saving = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsValidImageUrl(string value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
return true;
|
||||
|
||||
if (value.Length > 2048)
|
||||
return false;
|
||||
|
||||
if (value.StartsWith("//") ||
|
||||
value.Contains('\\') ||
|
||||
value.Any(char.IsControl))
|
||||
return false;
|
||||
|
||||
if (Uri.TryCreate(value, UriKind.Absolute, out var uri))
|
||||
{
|
||||
return uri.Scheme == Uri.UriSchemeHttps &&
|
||||
!string.IsNullOrWhiteSpace(uri.Host);
|
||||
}
|
||||
|
||||
await Db.SaveChangesAsync();
|
||||
Nav.NavigateTo("/admin/zbozi");
|
||||
return value.StartsWith('/') &&
|
||||
!value.StartsWith("//") &&
|
||||
!value.Contains("..");
|
||||
}
|
||||
|
||||
private void Apply(Product p)
|
||||
{
|
||||
p.Name = form.Name.Trim();
|
||||
p.CategoryId = form.CategoryId;
|
||||
p.Description = form.Description?.Trim() ?? "";
|
||||
p.Price = form.Price;
|
||||
p.StockQuantity = form.StockQuantity;
|
||||
p.ImageUrl = form.ImageUrl?.Trim() ?? "";
|
||||
p.IsVisible = form.IsVisible;
|
||||
p.UpdatedAt = DateTime.Now;
|
||||
}
|
||||
|
||||
private class ProductForm
|
||||
{
|
||||
[Required(ErrorMessage = "Zadej název zboží.")]
|
||||
[StringLength(100, ErrorMessage = "Název může mít nejvýše 100 znaků.")]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
public int CategoryId { get; set; }
|
||||
public string? Description { get; set; }
|
||||
|
||||
[Range(0, 100000, ErrorMessage = "Cena musí být 0 až 100 000 Kč.")]
|
||||
public decimal Price { get; set; }
|
||||
|
||||
[Range(0, 100000, ErrorMessage = "Počet kusů musí být 0 nebo více.")]
|
||||
public int StockQuantity { get; set; }
|
||||
|
||||
public string? ImageUrl { get; set; }
|
||||
public bool IsVisible { get; set; } = true;
|
||||
}
|
||||
private sealed record CatOption(int Id, string Name);
|
||||
}
|
||||
```
|
||||
@@ -7,229 +7,121 @@
|
||||
@using Web_Jarmark.Data.Models
|
||||
@inject ApplicationDbContext Db
|
||||
|
||||
@attribute [Authorize]
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
|
||||
<AuthorizeView>
|
||||
<PageTitle>Zboží</PageTitle>
|
||||
<PageTitle>Zboží</PageTitle>
|
||||
|
||||
<div class="wj-admin-page container-fluid py-3">
|
||||
<div class="wj-page-back">
|
||||
<a href="/admin" class="wj-back-admin">
|
||||
<span>←</span> Zpět na administraci
|
||||
</a>
|
||||
<div class="ap ao">
|
||||
<header class="ao-hero">
|
||||
<p class="ao-eyebrow">Administrace</p>
|
||||
<h1>Zboží</h1>
|
||||
<p class="ao-sub">Přehled a správa produktů.</p>
|
||||
<div style="margin-top:16px">
|
||||
<a class="ap-btn ap-btn-primary" href="/admin/zbozi/edit">Nové zboží</a>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="wj-heading d-flex flex-wrap justify-content-between align-items-center gap-3 mb-4">
|
||||
<div>
|
||||
<div class="wj-eyebrow">ADMINISTRACE / SPRÁVA OBCHODU</div>
|
||||
<h2>Zboží</h2>
|
||||
<p>Přehled a správa produktů v obchodě.</p>
|
||||
</div>
|
||||
<a class="wj-button wj-button-primary" href="/admin/zbozi/edit">
|
||||
+ Nové zboží
|
||||
</a>
|
||||
</div>
|
||||
@if (!string.IsNullOrEmpty(error))
|
||||
{
|
||||
<div class="ao-alert">@error</div>
|
||||
}
|
||||
|
||||
@if (!string.IsNullOrEmpty(error))
|
||||
{
|
||||
<div class="alert alert-danger rounded-4">@error</div>
|
||||
}
|
||||
|
||||
@if (products is null)
|
||||
{
|
||||
<div class="wj-panel p-4">
|
||||
<span class="text-muted">Načítám zboží…</span>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row g-3 mb-4">
|
||||
<div class="col-sm-6 col-xl-4">
|
||||
<div class="wj-stat-card">
|
||||
<div class="wj-stat-icon">📦</div>
|
||||
<div class="wj-stat-label">Celkem produktů</div>
|
||||
<div class="wj-stat-value">@products.Count</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6 col-xl-4">
|
||||
<div class="wj-stat-card">
|
||||
<div class="wj-stat-icon">✓</div>
|
||||
<div class="wj-stat-label">Viditelné produkty</div>
|
||||
<div class="wj-stat-value">@products.Count(p => p.IsVisible)</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6 col-xl-4">
|
||||
<div class="wj-stat-card">
|
||||
<div class="wj-stat-icon">📉</div>
|
||||
<div class="wj-stat-label">Dochází skladem (5 a méně)</div>
|
||||
<div class="wj-stat-value">@products.Count(p => p.StockQuantity <= 5)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wj-panel p-0 overflow-hidden">
|
||||
<div class="p-4 d-flex flex-wrap justify-content-between align-items-center gap-3">
|
||||
<div>
|
||||
<h4 class="fw-bold mb-1">Přehled produktů</h4>
|
||||
<p class="text-muted mb-0 small">Všechny produkty v e-shopu</p>
|
||||
</div>
|
||||
|
||||
<div class="wj-search">
|
||||
<span>⌕</span>
|
||||
<input class="form-control"
|
||||
placeholder="Hledat zboží nebo kategorii…"
|
||||
@bind="searchTerm"
|
||||
@bind:event="oninput" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (FilteredProducts.Count == 0)
|
||||
{
|
||||
<div class="text-center p-5">
|
||||
<div class="fs-1 mb-3">🔎</div>
|
||||
<h5 class="fw-bold">Nic jsme nenašli</h5>
|
||||
<p class="text-muted mb-0">Zkuste změnit hledaný výraz.</p>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="table-responsive">
|
||||
<table class="table wj-table align-middle mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="ps-4">Název zboží</th>
|
||||
<th>Kategorie</th>
|
||||
<th class="text-end">Cena</th>
|
||||
<th class="text-center">Skladem</th>
|
||||
<th class="text-center">Viditelnost</th>
|
||||
<th class="text-end pe-4">Akce</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var p in FilteredProducts)
|
||||
{
|
||||
<tr>
|
||||
<td class="ps-4 fw-semibold">@p.Name</td>
|
||||
<td>
|
||||
<span class="wj-tag">@p.CategoryName</span>
|
||||
</td>
|
||||
<td class="text-end fw-semibold">@p.Price.ToString("N2") Kč</td>
|
||||
<td class="text-center">
|
||||
@if (p.StockQuantity <= 5)
|
||||
{
|
||||
<span class="wj-stock-low">@p.StockQuantity ks</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="wj-tag">@p.StockQuantity ks</span>
|
||||
}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<div class="form-check form-switch d-flex justify-content-center">
|
||||
<input type="checkbox"
|
||||
class="form-check-input"
|
||||
checked="@p.IsVisible"
|
||||
title="Změnit viditelnost"
|
||||
@onchange="() => ToggleVisible(p.Id)" />
|
||||
</div>
|
||||
<small class="text-muted">@(p.IsVisible ? "Viditelné" : "Skryté")</small>
|
||||
</td>
|
||||
<td class="text-end pe-4">
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<a class="wj-small-button" href="/admin/zbozi/edit/@p.Id">
|
||||
Upravit
|
||||
</a>
|
||||
<button class="wj-small-button wj-danger-button"
|
||||
@onclick="() => Delete(p.Id)">
|
||||
Smazat
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="border-top px-4 py-3">
|
||||
<small class="text-muted">
|
||||
Zobrazeno: @FilteredProducts.Count z @products.Count produktů
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
<div class="ao-filters">
|
||||
<input class="ao-input" placeholder="Hledat produkt…" @bind="search" @bind:event="oninput" />
|
||||
</div>
|
||||
</AuthorizeView>
|
||||
|
||||
@if (items is null)
|
||||
{
|
||||
<div class="ao-loading">Načítám zboží…</div>
|
||||
}
|
||||
else if (Filtered.Count == 0)
|
||||
{
|
||||
<div class="ao-empty">Žádné produkty.</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<section class="ao-panel">
|
||||
<div class="ao-panel-head">
|
||||
<div>
|
||||
<h2>Katalog</h2>
|
||||
<p>@Filtered.Count položek</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ao-list">
|
||||
@foreach (var p in Filtered)
|
||||
{
|
||||
<article class="ao-card" @key="p.Id">
|
||||
<div class="ao-card-main" style="cursor:default">
|
||||
<div class="ao-card-left">
|
||||
<span class="ao-code">@p.Name</span>
|
||||
<span class="ao-date">@p.CategoryName</span>
|
||||
</div>
|
||||
<div class="ao-card-mid">
|
||||
<span class="ao-pay">@p.Price.ToString("N0") Kč</span>
|
||||
<span class="ao-qty">@p.StockQuantity ks</span>
|
||||
</div>
|
||||
<div class="ao-card-right">
|
||||
<span class="ao-badge @(p.IsVisible ? "is-paid" : "is-cancel")">
|
||||
@(p.IsVisible ? "Viditelné" : "Skryté")
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sklad-row">
|
||||
<a class="ap-btn ap-btn-ghost" href="@($"/admin/zbozi/edit/{p.Id}")">Upravit</a>
|
||||
</div>
|
||||
</article>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private List<ProductRow>? products;
|
||||
private List<Row>? items;
|
||||
private string search = "";
|
||||
private string? error;
|
||||
private string searchTerm = "";
|
||||
|
||||
private List<ProductRow> FilteredProducts =>
|
||||
products?
|
||||
.Where(p => string.IsNullOrWhiteSpace(searchTerm)
|
||||
|| p.Name.Contains(searchTerm, StringComparison.OrdinalIgnoreCase)
|
||||
|| p.CategoryName.Contains(searchTerm, StringComparison.OrdinalIgnoreCase))
|
||||
.ToList() ?? new();
|
||||
|
||||
protected override async Task OnInitializedAsync() => await Load();
|
||||
|
||||
private async Task Load()
|
||||
private List<Row> Filtered
|
||||
{
|
||||
products = await Db.Set<Product>()
|
||||
.AsNoTracking()
|
||||
.OrderBy(p => p.Name)
|
||||
.Select(p => new ProductRow(
|
||||
p.Id,
|
||||
p.Name,
|
||||
p.Category.Name,
|
||||
p.Price,
|
||||
p.StockQuantity,
|
||||
p.IsVisible))
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
private async Task ToggleVisible(int id)
|
||||
{
|
||||
var p = await Db.Set<Product>().FindAsync(id);
|
||||
if (p is null) return;
|
||||
|
||||
p.IsVisible = !p.IsVisible;
|
||||
p.UpdatedAt = DateTime.Now;
|
||||
await Db.SaveChangesAsync();
|
||||
await Load();
|
||||
}
|
||||
|
||||
private async Task Delete(int id)
|
||||
{
|
||||
error = null;
|
||||
|
||||
var p = await Db.Set<Product>()
|
||||
.Include(x => x.OrderItems)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
if (p is null) return;
|
||||
|
||||
if (p.OrderItems.Count > 0)
|
||||
get
|
||||
{
|
||||
error = $"Zboží „{p.Name}“ už je v objednávkách, nelze ho smazat. Odškrtni raději „Viditelné“.";
|
||||
return;
|
||||
if (items is null) return new();
|
||||
if (string.IsNullOrWhiteSpace(search)) return items;
|
||||
return items.Where(p =>
|
||||
p.Name.Contains(search, StringComparison.OrdinalIgnoreCase) ||
|
||||
p.CategoryName.Contains(search, StringComparison.OrdinalIgnoreCase)).ToList();
|
||||
}
|
||||
|
||||
Db.Set<Product>().Remove(p);
|
||||
await Db.SaveChangesAsync();
|
||||
await Load();
|
||||
}
|
||||
|
||||
private record ProductRow(
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
items = await Db.Products
|
||||
.AsNoTracking()
|
||||
.OrderBy(p => p.Name)
|
||||
.Select(p => new Row(
|
||||
p.Id,
|
||||
p.Name,
|
||||
p.Category.Name,
|
||||
p.Price,
|
||||
p.StockQuantity,
|
||||
p.IsVisible))
|
||||
.ToListAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
error = "Nepodařilo se načíst zboží: " + ex.Message;
|
||||
items = new();
|
||||
}
|
||||
}
|
||||
|
||||
private sealed record Row(
|
||||
int Id,
|
||||
string Name,
|
||||
string CategoryName,
|
||||
decimal Price,
|
||||
int StockQuantity,
|
||||
bool IsVisible);
|
||||
}
|
||||
}
|
||||
419
Web-Jarmark/Web-Jarmark/Components/Pages/Admin/Sklad.razor
Normal file
419
Web-Jarmark/Web-Jarmark/Components/Pages/Admin/Sklad.razor
Normal file
@@ -0,0 +1,419 @@
|
||||
@page "/admin/sklad"
|
||||
@layout Web_Jarmark.Components.Layout.Admin.AdminLayout
|
||||
@rendermode InteractiveServer
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Web_Jarmark.Data
|
||||
@using Web_Jarmark.Data.Models
|
||||
@inject ApplicationDbContext Db
|
||||
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
|
||||
<PageTitle>Sklad</PageTitle>
|
||||
|
||||
<div class="ap ao">
|
||||
<header class="ao-hero">
|
||||
<p class="ao-eyebrow">Administrace</p>
|
||||
<h1>Sklad</h1>
|
||||
<p class="ao-sub">Sledování zásob, rychlé úpravy a upozornění na nízký stav.</p>
|
||||
</header>
|
||||
|
||||
@if (!string.IsNullOrEmpty(message))
|
||||
{
|
||||
<div class="ao-alert">@message</div>
|
||||
}
|
||||
|
||||
@if (loading)
|
||||
{
|
||||
<div class="ao-loading">Načítám sklad…</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<section class="ao-stats">
|
||||
<article class="ao-stat" style="--i:0">
|
||||
<span>Produktů</span>
|
||||
<strong>@items.Count</strong>
|
||||
<small>ve skladu</small>
|
||||
</article>
|
||||
<article class="ao-stat" style="--i:1">
|
||||
<span>Nízký sklad</span>
|
||||
<strong>@items.Count(i => i.StockQuantity > 0 && i.StockQuantity <= LowThreshold)</strong>
|
||||
<small>≤ @LowThreshold ks</small>
|
||||
</article>
|
||||
<article class="ao-stat" style="--i:2">
|
||||
<span>Vyprodané</span>
|
||||
<strong>@items.Count(i => i.StockQuantity <= 0)</strong>
|
||||
<small>0 ks</small>
|
||||
</article>
|
||||
<article class="ao-stat" style="--i:3">
|
||||
<span>Hodnota skladu</span>
|
||||
<strong>@items.Sum(i => i.Price * i.StockQuantity).ToString("N0")</strong>
|
||||
<small>@items.Sum(i => i.StockQuantity) ks celkem</small>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<div class="ao-filters">
|
||||
<input class="ao-input" placeholder="Hledat produkt nebo kategorii…"
|
||||
@bind="search" @bind:event="oninput" />
|
||||
|
||||
<select class="ao-select" @bind="stockFilter">
|
||||
<option value="all">Stav: vše</option>
|
||||
<option value="ok">V pořádku (>@LowThreshold)</option>
|
||||
<option value="low">Nízký (1–@LowThreshold)</option>
|
||||
<option value="out">Vyprodané (0)</option>
|
||||
</select>
|
||||
|
||||
<select class="ao-select" @bind="categoryFilter">
|
||||
<option value="all">Kategorie: vše</option>
|
||||
@foreach (var c in categoryNames)
|
||||
{
|
||||
<option value="@c">@c</option>
|
||||
}
|
||||
</select>
|
||||
|
||||
<select class="ao-select" @bind="sortBy">
|
||||
<option value="stock_asc">Řadit: nejméně kusů</option>
|
||||
<option value="stock_desc">Řadit: nejvíce kusů</option>
|
||||
<option value="name">Řadit: název</option>
|
||||
<option value="value">Řadit: hodnota</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="sklad-row" style="padding-left:0;padding-right:0">
|
||||
<button type="button" class="ap-btn ap-btn-ghost" disabled="@busy" @onclick="ReloadAsync">Obnovit</button>
|
||||
<button type="button" class="ap-btn ap-btn-ghost" disabled="@busy || !HasPending" @onclick="SaveAllAsync">
|
||||
Uložit všechny změny @(HasPending ? $"({PendingCount})" : "")
|
||||
</button>
|
||||
<button type="button" class="ap-btn ap-btn-ghost" disabled="@busy" @onclick="() => QuickFilterOut()">
|
||||
Jen vyprodané
|
||||
</button>
|
||||
<button type="button" class="ap-btn ap-btn-ghost" disabled="@busy" @onclick="() => QuickFilterLow()">
|
||||
Jen nízký sklad
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<section class="ao-panel">
|
||||
<div class="ao-panel-head">
|
||||
<div>
|
||||
<h2>Zásoby</h2>
|
||||
<p>@Filtered.Count položek</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (Filtered.Count == 0)
|
||||
{
|
||||
<div class="ao-empty">Nic nenalezeno.</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="ao-list">
|
||||
@foreach (var p in Filtered)
|
||||
{
|
||||
var qty = GetEditQty(p.Id);
|
||||
var dirty = IsDirty(p.Id, p.StockQuantity);
|
||||
|
||||
<article class="ao-card @(dirty ? "is-open" : null)" @key="p.Id">
|
||||
<div class="ao-card-main" style="cursor:default">
|
||||
<div class="ao-card-left">
|
||||
<span class="ao-code">@p.Name</span>
|
||||
<span class="ao-date">@p.CategoryName</span>
|
||||
</div>
|
||||
<div class="ao-card-mid">
|
||||
<span class="ao-pay">@p.Price.ToString("N0") Kč / ks</span>
|
||||
<span class="ao-qty">hodnota @((p.Price * qty).ToString("N0")) Kč</span>
|
||||
</div>
|
||||
<div class="ao-card-right">
|
||||
<span class="ao-badge @StockBadge(qty)">
|
||||
@StockLabel(qty)
|
||||
</span>
|
||||
@if (dirty)
|
||||
{
|
||||
<span class="ao-date">neuloženo</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sklad-row">
|
||||
<button type="button" class="ap-btn ap-btn-ghost" disabled="@busy"
|
||||
@onclick="() => Adjust(p.Id, -5)">
|
||||
−5
|
||||
</button>
|
||||
<button type="button" class="ap-btn ap-btn-ghost" disabled="@busy"
|
||||
@onclick="() => Adjust(p.Id, -1)">
|
||||
−
|
||||
</button>
|
||||
|
||||
<input type="number" min="0" class="ao-input sklad-input"
|
||||
value="@qty"
|
||||
@onchange="e => OnStockInput(p.Id, e)" />
|
||||
|
||||
<button type="button" class="ap-btn ap-btn-ghost" disabled="@busy"
|
||||
@onclick="() => Adjust(p.Id, 1)">
|
||||
+
|
||||
</button>
|
||||
<button type="button" class="ap-btn ap-btn-ghost" disabled="@busy"
|
||||
@onclick="() => Adjust(p.Id, 5)">
|
||||
+5
|
||||
</button>
|
||||
<button type="button" class="ap-btn ap-btn-ghost" disabled="@busy"
|
||||
@onclick="() => Adjust(p.Id, 10)">
|
||||
+10
|
||||
</button>
|
||||
|
||||
<button type="button" class="ap-btn ap-btn-primary" disabled="@busy"
|
||||
@onclick="() => SaveOneAsync(p.Id)">
|
||||
Uložit
|
||||
</button>
|
||||
|
||||
<button type="button" class="ap-btn ap-btn-ghost" disabled="@busy"
|
||||
@onclick="() => SetQty(p.Id, 0)">
|
||||
Na 0
|
||||
</button>
|
||||
|
||||
<button type="button" class="ap-btn ap-btn-ghost" disabled="@busy"
|
||||
@onclick="() => ToggleVisibleAsync(p)">
|
||||
@(p.IsVisible ? "Skrýt" : "Zobrazit")
|
||||
</button>
|
||||
|
||||
<a class="ap-btn ap-btn-ghost" href="@($"/admin/zbozi/edit/{p.Id}")">Upravit</a>
|
||||
</div>
|
||||
</article>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private const int LowThreshold = 5;
|
||||
|
||||
private List<StockRow> items = new();
|
||||
private readonly Dictionary<int, int> edits = new();
|
||||
private List<string> categoryNames = new();
|
||||
|
||||
private bool loading = true;
|
||||
private bool busy;
|
||||
private string? message;
|
||||
|
||||
private string search = "";
|
||||
private string stockFilter = "all";
|
||||
private string categoryFilter = "all";
|
||||
private string sortBy = "stock_asc";
|
||||
|
||||
private bool HasPending => items.Any(i => IsDirty(i.Id, i.StockQuantity));
|
||||
private int PendingCount => items.Count(i => IsDirty(i.Id, i.StockQuantity));
|
||||
|
||||
private List<StockRow> Filtered
|
||||
{
|
||||
get
|
||||
{
|
||||
IEnumerable<StockRow> q = items;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(search))
|
||||
{
|
||||
q = q.Where(p =>
|
||||
p.Name.Contains(search, StringComparison.OrdinalIgnoreCase) ||
|
||||
p.CategoryName.Contains(search, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
if (categoryFilter != "all")
|
||||
{
|
||||
q = q.Where(p => p.CategoryName == categoryFilter);
|
||||
}
|
||||
|
||||
q = stockFilter switch
|
||||
{
|
||||
"ok" => q.Where(p => GetEditQty(p.Id) > LowThreshold),
|
||||
"low" => q.Where(p =>
|
||||
{
|
||||
var n = GetEditQty(p.Id);
|
||||
return n > 0 && n <= LowThreshold;
|
||||
}),
|
||||
"out" => q.Where(p => GetEditQty(p.Id) <= 0),
|
||||
_ => q
|
||||
};
|
||||
|
||||
q = sortBy switch
|
||||
{
|
||||
"stock_desc" => q.OrderByDescending(p => GetEditQty(p.Id)).ThenBy(p => p.Name),
|
||||
"name" => q.OrderBy(p => p.Name),
|
||||
"value" => q.OrderByDescending(p => p.Price * GetEditQty(p.Id)),
|
||||
_ => q.OrderBy(p => GetEditQty(p.Id)).ThenBy(p => p.Name)
|
||||
};
|
||||
|
||||
return q.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await ReloadAsync();
|
||||
loading = false;
|
||||
}
|
||||
|
||||
private async Task ReloadAsync()
|
||||
{
|
||||
items = await Db.Products
|
||||
.AsNoTracking()
|
||||
.OrderBy(p => p.Name)
|
||||
.Select(p => new StockRow(
|
||||
p.Id,
|
||||
p.Name,
|
||||
p.Category.Name,
|
||||
p.Price,
|
||||
p.StockQuantity,
|
||||
p.IsVisible))
|
||||
.ToListAsync();
|
||||
|
||||
categoryNames = items
|
||||
.Select(i => i.CategoryName)
|
||||
.Distinct()
|
||||
.OrderBy(x => x)
|
||||
.ToList();
|
||||
|
||||
edits.Clear();
|
||||
foreach (var i in items)
|
||||
edits[i.Id] = i.StockQuantity;
|
||||
|
||||
message = null;
|
||||
}
|
||||
|
||||
private int GetEditQty(int id) =>
|
||||
edits.TryGetValue(id, out var v) ? v : 0;
|
||||
|
||||
private bool IsDirty(int id, int original) =>
|
||||
edits.TryGetValue(id, out var v) && v != original;
|
||||
|
||||
private void OnStockInput(int id, ChangeEventArgs e)
|
||||
{
|
||||
if (int.TryParse(e.Value?.ToString(), out var val))
|
||||
edits[id] = Math.Max(0, val);
|
||||
}
|
||||
|
||||
private void Adjust(int id, int delta)
|
||||
{
|
||||
edits[id] = Math.Max(0, GetEditQty(id) + delta);
|
||||
}
|
||||
|
||||
private void SetQty(int id, int qty)
|
||||
{
|
||||
edits[id] = Math.Max(0, qty);
|
||||
}
|
||||
|
||||
private void QuickFilterOut()
|
||||
{
|
||||
stockFilter = "out";
|
||||
sortBy = "name";
|
||||
}
|
||||
|
||||
private void QuickFilterLow()
|
||||
{
|
||||
stockFilter = "low";
|
||||
sortBy = "stock_asc";
|
||||
}
|
||||
|
||||
private async Task SaveOneAsync(int id)
|
||||
{
|
||||
busy = true;
|
||||
message = null;
|
||||
try
|
||||
{
|
||||
var entity = await Db.Products.FirstOrDefaultAsync(p => p.Id == id);
|
||||
if (entity is null)
|
||||
{
|
||||
message = "Produkt nebyl nalezen.";
|
||||
return;
|
||||
}
|
||||
|
||||
var qty = GetEditQty(id);
|
||||
entity.StockQuantity = qty;
|
||||
entity.UpdatedAt = DateTime.UtcNow;
|
||||
await Db.SaveChangesAsync();
|
||||
|
||||
message = $"Uloženo: {entity.Name} → {qty} ks";
|
||||
await ReloadAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = "Chyba: " + ex.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
busy = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveAllAsync()
|
||||
{
|
||||
busy = true;
|
||||
message = null;
|
||||
try
|
||||
{
|
||||
var changed = items.Where(i => IsDirty(i.Id, i.StockQuantity)).ToList();
|
||||
if (changed.Count == 0)
|
||||
{
|
||||
message = "Žádné změny k uložení.";
|
||||
return;
|
||||
}
|
||||
|
||||
var ids = changed.Select(c => c.Id).ToList();
|
||||
var entities = await Db.Products.Where(p => ids.Contains(p.Id)).ToListAsync();
|
||||
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
entity.StockQuantity = GetEditQty(entity.Id);
|
||||
entity.UpdatedAt = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
await Db.SaveChangesAsync();
|
||||
message = $"Uloženo změn: {entities.Count}";
|
||||
await ReloadAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = "Hromadné uložení selhalo: " + ex.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
busy = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ToggleVisibleAsync(StockRow row)
|
||||
{
|
||||
busy = true;
|
||||
message = null;
|
||||
try
|
||||
{
|
||||
var entity = await Db.Products.FirstAsync(p => p.Id == row.Id);
|
||||
entity.IsVisible = !entity.IsVisible;
|
||||
entity.UpdatedAt = DateTime.UtcNow;
|
||||
await Db.SaveChangesAsync();
|
||||
message = entity.IsVisible ? $"Zobrazeno: {entity.Name}" : $"Skryto v e-shopu: {entity.Name}";
|
||||
await ReloadAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = ex.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
busy = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static string StockLabel(int q) =>
|
||||
q <= 0 ? "Vyprodané" : q <= LowThreshold ? "Nízký sklad" : "V pořádku";
|
||||
|
||||
private static string StockBadge(int q) =>
|
||||
q <= 0 ? "is-cancel" : q <= LowThreshold ? "is-pending" : "is-paid";
|
||||
|
||||
private sealed record StockRow(
|
||||
int Id,
|
||||
string Name,
|
||||
string CategoryName,
|
||||
decimal Price,
|
||||
int StockQuantity,
|
||||
bool IsVisible);
|
||||
}
|
||||
200
Web-Jarmark/Web-Jarmark/Components/Pages/Admin/Statistiky.razor
Normal file
200
Web-Jarmark/Web-Jarmark/Components/Pages/Admin/Statistiky.razor
Normal file
@@ -0,0 +1,200 @@
|
||||
@page "/admin/statistiky"
|
||||
@layout Web_Jarmark.Components.Layout.Admin.AdminLayout
|
||||
@rendermode InteractiveServer
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Web_Jarmark.Data
|
||||
@using Web_Jarmark.Data.Models
|
||||
@inject ApplicationDbContext Db
|
||||
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
|
||||
<PageTitle>Statistiky</PageTitle>
|
||||
|
||||
<div class="ap ao">
|
||||
<header class="ao-hero">
|
||||
<p class="ao-eyebrow">Administrace</p>
|
||||
<h1>Statistiky</h1>
|
||||
<p class="ao-sub">Přehled e-shopu ze skutečných dat.</p>
|
||||
</header>
|
||||
|
||||
@if (loading)
|
||||
{
|
||||
<div class="ao-loading">Načítám statistiky…</div>
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(error))
|
||||
{
|
||||
<div class="ao-alert">@error</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<section class="ao-stats">
|
||||
<article class="ao-stat">
|
||||
<span>Objednávky</span>
|
||||
<strong>@orderCount</strong>
|
||||
<small>celkem</small>
|
||||
</article>
|
||||
<article class="ao-stat">
|
||||
<span>Tržby</span>
|
||||
<strong>@revenue.ToString("N0")</strong>
|
||||
<small>Kč</small>
|
||||
</article>
|
||||
<article class="ao-stat">
|
||||
<span>Produkty</span>
|
||||
<strong>@productCount</strong>
|
||||
<small>@visibleCount viditelných</small>
|
||||
</article>
|
||||
<article class="ao-stat">
|
||||
<span>Sklad</span>
|
||||
<strong>@stockUnits</strong>
|
||||
<small>@stockValue.ToString("N0") Kč</small>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="ao-stats">
|
||||
<article class="ao-stat">
|
||||
<span>Čeká na zaplacení</span>
|
||||
<strong>@pendingCount</strong>
|
||||
<small>objednávek</small>
|
||||
</article>
|
||||
<article class="ao-stat">
|
||||
<span>Zaplaceno</span>
|
||||
<strong>@paidCount</strong>
|
||||
<small>objednávek</small>
|
||||
</article>
|
||||
<article class="ao-stat">
|
||||
<span>Odesláno / dokončeno</span>
|
||||
<strong>@(shippedCount + deliveredCount)</strong>
|
||||
<small>objednávek</small>
|
||||
</article>
|
||||
<article class="ao-stat">
|
||||
<span>Zrušeno</span>
|
||||
<strong>@cancelledCount</strong>
|
||||
<small>objednávek</small>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="ao-panel">
|
||||
<div class="ao-panel-head">
|
||||
<div>
|
||||
<h2>Katalog a sklad</h2>
|
||||
<p>Aktuální stav</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ao-list">
|
||||
<div class="ao-item">
|
||||
<div><strong>Kategorie</strong><span>celkem</span></div>
|
||||
<strong>@categoryCount</strong>
|
||||
</div>
|
||||
<div class="ao-item">
|
||||
<div><strong>Aktivní kategorie</strong><span>v e-shopu</span></div>
|
||||
<strong>@activeCategoryCount</strong>
|
||||
</div>
|
||||
<div class="ao-item">
|
||||
<div><strong>Nízký sklad</strong><span>≤ 5 ks</span></div>
|
||||
<strong>@lowStockCount</strong>
|
||||
</div>
|
||||
<div class="ao-item">
|
||||
<div><strong>Vyprodané</strong><span>0 ks</span></div>
|
||||
<strong>@outOfStockCount</strong>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="ao-panel" style="margin-top:14px">
|
||||
<div class="ao-panel-head">
|
||||
<div>
|
||||
<h2>Poslední objednávky</h2>
|
||||
<p>Nejnovějších 8</p>
|
||||
</div>
|
||||
<a class="ap-btn ap-btn-ghost" href="/admin/objednavky">Všechny</a>
|
||||
</div>
|
||||
|
||||
@if (recentOrders.Count == 0)
|
||||
{
|
||||
<div class="ao-empty">Žádné objednávky.</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="ao-list">
|
||||
@foreach (var o in recentOrders)
|
||||
{
|
||||
<article class="ao-card">
|
||||
<div class="ao-card-main" style="cursor:default">
|
||||
<div class="ao-card-left">
|
||||
<span class="ao-code">#@o.Code</span>
|
||||
<span class="ao-date">@o.CreatedAt.ToLocalTime().ToString("d. M. yyyy HH:mm")</span>
|
||||
</div>
|
||||
<div class="ao-card-mid">
|
||||
<span class="ao-pay">@(string.IsNullOrWhiteSpace(o.CustomerName) ? "—" : o.CustomerName)</span>
|
||||
</div>
|
||||
<div class="ao-card-right">
|
||||
<span class="ao-price">@o.TotalAmount.ToString("N0") Kč</span>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private bool loading = true;
|
||||
private string? error;
|
||||
|
||||
private int orderCount, pendingCount, paidCount, shippedCount, deliveredCount, cancelledCount;
|
||||
private int productCount, visibleCount, categoryCount, activeCategoryCount;
|
||||
private int stockUnits, lowStockCount, outOfStockCount;
|
||||
private decimal revenue, stockValue;
|
||||
|
||||
private List<RecentOrder> recentOrders = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var orders = await Db.Orders.AsNoTracking().ToListAsync();
|
||||
orderCount = orders.Count;
|
||||
pendingCount = orders.Count(o => o.Status == OrderStatus.Pending);
|
||||
paidCount = orders.Count(o => o.Status == OrderStatus.Paid);
|
||||
shippedCount = orders.Count(o => o.Status == OrderStatus.Shipped);
|
||||
deliveredCount = orders.Count(o => o.Status == OrderStatus.Delivered);
|
||||
cancelledCount = orders.Count(o => o.Status == OrderStatus.Cancelled);
|
||||
|
||||
revenue = orders
|
||||
.Where(o => o.Status == OrderStatus.Paid
|
||||
|| o.Status == OrderStatus.Shipped
|
||||
|| o.Status == OrderStatus.Delivered)
|
||||
.Sum(o => o.TotalAmount);
|
||||
|
||||
var products = await Db.Products.AsNoTracking().ToListAsync();
|
||||
productCount = products.Count;
|
||||
visibleCount = products.Count(p => p.IsVisible);
|
||||
stockUnits = products.Sum(p => p.StockQuantity);
|
||||
stockValue = products.Sum(p => p.Price * p.StockQuantity);
|
||||
lowStockCount = products.Count(p => p.StockQuantity > 0 && p.StockQuantity <= 5);
|
||||
outOfStockCount = products.Count(p => p.StockQuantity <= 0);
|
||||
|
||||
categoryCount = await Db.Categories.CountAsync();
|
||||
activeCategoryCount = await Db.Categories.CountAsync(c => c.IsActive);
|
||||
|
||||
recentOrders = orders
|
||||
.OrderByDescending(o => o.CreatedAt)
|
||||
.Take(8)
|
||||
.Select(o => new RecentOrder(o.Code, o.CustomerName, o.TotalAmount, o.CreatedAt))
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
error = "Statistiky se nepodařilo načíst: " + ex.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed record RecentOrder(string Code, string CustomerName, decimal TotalAmount, DateTime CreatedAt);
|
||||
}
|
||||
@@ -1,6 +1,942 @@
|
||||
@page "/Vyrobek{Id:int}"
|
||||
<h3>DatailVyrobku</h3>
|
||||
@page "/produkt/{Id:int}"
|
||||
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Web_Jarmark.Data
|
||||
@using Web_Jarmark.Data.Models
|
||||
|
||||
@inject ApplicationDbContext DbContext
|
||||
@inject IHttpContextAccessor HttpContextAccessor
|
||||
@inject PersistentComponentState ApplicationState
|
||||
|
||||
@implements IDisposable
|
||||
|
||||
<PageTitle>Detail produktu | Školní jarmark</PageTitle>
|
||||
|
||||
<div class="jarmark-product-detail">
|
||||
|
||||
<!-- NOTIFIKACE -->
|
||||
@if (showNotification)
|
||||
{
|
||||
<div class="jarmark-detail-notification"
|
||||
role="status"
|
||||
aria-live="polite">
|
||||
|
||||
<svg width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.8"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
aria-hidden="true">
|
||||
|
||||
<circle cx="12" cy="12" r="9" />
|
||||
<path d="m8 12 3 3 5-6" />
|
||||
|
||||
</svg>
|
||||
|
||||
<span>@notificationMessage</span>
|
||||
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
<!-- NÁVRAT DO KATALOGU -->
|
||||
|
||||
<a href="/" class="jarmark-detail-back">
|
||||
|
||||
<svg width="20"
|
||||
height="20"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.8"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
aria-hidden="true">
|
||||
|
||||
<path d="M19 12H5M12 19l-7-7 7-7" />
|
||||
|
||||
</svg>
|
||||
|
||||
<span>Zpět do katalogu</span>
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
<!-- NAČÍTÁNÍ -->
|
||||
@if (loading)
|
||||
{
|
||||
<div class="jarmark-detail-empty"
|
||||
role="status"
|
||||
aria-live="polite">
|
||||
|
||||
<h2>Načítáme výrobek</h2>
|
||||
|
||||
<p>Informace o výrobku se právě načítají.</p>
|
||||
|
||||
</div>
|
||||
}
|
||||
else if (product == null)
|
||||
{
|
||||
<div class="jarmark-detail-empty">
|
||||
|
||||
<svg width="48"
|
||||
height="48"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.4"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
aria-hidden="true">
|
||||
|
||||
<circle cx="11" cy="11" r="7" />
|
||||
<path d="m20 20-4-4" />
|
||||
|
||||
</svg>
|
||||
|
||||
<h2>Výrobek nebyl nalezen</h2>
|
||||
|
||||
<p>
|
||||
Tento výrobek již nemusí být dostupný.
|
||||
Další výrobky najdete v katalogu.
|
||||
</p>
|
||||
|
||||
<a href="/"
|
||||
class="jarmark-detail-button">
|
||||
|
||||
Prohlédnout nabídku
|
||||
|
||||
</a>
|
||||
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<article class="jarmark-detail-card">
|
||||
|
||||
<!-- FOTOGRAFIE -->
|
||||
|
||||
<div class="jarmark-detail-image">
|
||||
|
||||
@if (!string.IsNullOrWhiteSpace(product.ImageUrl)
|
||||
&& !imageFailed)
|
||||
{
|
||||
<img src="@product.ImageUrl"
|
||||
alt="@product.Name"
|
||||
decoding="async"
|
||||
@onerror="HandleImageError" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="jarmark-detail-placeholder">
|
||||
|
||||
<svg width="80"
|
||||
height="80"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
aria-hidden="true">
|
||||
|
||||
<rect x="3"
|
||||
y="3"
|
||||
width="18"
|
||||
height="18"
|
||||
rx="2" />
|
||||
|
||||
<circle cx="8.5"
|
||||
cy="8.5"
|
||||
r="1.5" />
|
||||
|
||||
<path d="m21 15-5-5L5 21" />
|
||||
|
||||
</svg>
|
||||
|
||||
<span>Fotografie není dostupná</span>
|
||||
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- INFORMACE O VÝROBKU -->
|
||||
|
||||
<div class="jarmark-detail-info">
|
||||
|
||||
@if (product.Category is not null)
|
||||
{
|
||||
<span class="jarmark-detail-category">
|
||||
|
||||
@product.Category.Name
|
||||
|
||||
</span>
|
||||
}
|
||||
|
||||
<h1 class="jarmark-detail-title">
|
||||
|
||||
@product.Name
|
||||
|
||||
</h1>
|
||||
|
||||
@if (!string.IsNullOrWhiteSpace(product.Description))
|
||||
{
|
||||
<p class="jarmark-detail-description">
|
||||
|
||||
@product.Description
|
||||
|
||||
</p>
|
||||
}
|
||||
|
||||
|
||||
<!-- SKLADOVÁ DOSTUPNOST -->
|
||||
|
||||
<div class="jarmark-detail-stock @(product.StockQuantity > 0 ? "is-available" : "is-unavailable")">
|
||||
|
||||
<span class="jarmark-detail-stock-dot"
|
||||
aria-hidden="true">
|
||||
</span>
|
||||
|
||||
@if (product.StockQuantity > 0)
|
||||
{
|
||||
<span>
|
||||
Skladem: @product.StockQuantity ks
|
||||
</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>Není skladem</span>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- CENA A NÁKUP -->
|
||||
|
||||
<div class="jarmark-detail-purchase">
|
||||
|
||||
<div class="jarmark-detail-price-area">
|
||||
|
||||
<span class="jarmark-detail-price-label">
|
||||
|
||||
Cena produktu
|
||||
|
||||
</span>
|
||||
|
||||
<strong class="jarmark-detail-price">
|
||||
|
||||
@product.Price.ToString("N0") Kč
|
||||
|
||||
</strong>
|
||||
|
||||
</div>
|
||||
|
||||
<button type="button"
|
||||
class="jarmark-detail-button"
|
||||
disabled="@(product.StockQuantity <= 0)"
|
||||
@onclick="() => HandleAddToCart(product)">
|
||||
|
||||
@if (product.StockQuantity > 0)
|
||||
{
|
||||
<svg width="22"
|
||||
height="22"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.7"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
aria-hidden="true">
|
||||
|
||||
<path d="M3 3h2l3.5 13h10l3-10H6" />
|
||||
|
||||
<circle cx="10"
|
||||
cy="20"
|
||||
r="1" />
|
||||
|
||||
<circle cx="18"
|
||||
cy="20"
|
||||
r="1" />
|
||||
|
||||
</svg>
|
||||
|
||||
<span>Přidat do košíku</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>Vyprodáno</span>
|
||||
}
|
||||
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</article>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
/* ========================================
|
||||
PUBLIC PRODUCT DETAIL
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-detail {
|
||||
--detail-primary: #244b36;
|
||||
--detail-primary-hover: #193b29;
|
||||
--detail-secondary: #e6eddf;
|
||||
--detail-surface: #ffffff;
|
||||
--detail-text: #26372b;
|
||||
--detail-muted: #59665b;
|
||||
--detail-border: #dce3d9;
|
||||
width: 100%;
|
||||
max-width: 1200px;
|
||||
min-width: 0;
|
||||
margin: 0 auto;
|
||||
color: var(--detail-text);
|
||||
font-family: inherit;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
BACK LINK
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-back {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-height: 44px;
|
||||
margin: 0 0 20px;
|
||||
padding: 8px 0;
|
||||
color: var(--detail-primary);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-back svg {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-back:hover {
|
||||
color: var(--detail-primary-hover);
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 4px;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
PRODUCT CARD
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-card {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||
align-items: start;
|
||||
gap: 40px;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 32px;
|
||||
background: var(--detail-surface);
|
||||
border: 1px solid var(--detail-border);
|
||||
border-radius: 12px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
PRODUCT IMAGE
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-image {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
aspect-ratio: 1 / 1;
|
||||
background: #edf0e9;
|
||||
border: 1px solid var(--detail-border);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-image img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-width: 100%;
|
||||
padding: 20px;
|
||||
object-fit: contain;
|
||||
object-position: center;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
IMAGE PLACEHOLDER
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-placeholder {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 16px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 24px;
|
||||
background: var(--detail-secondary);
|
||||
color: #64815d;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-placeholder span {
|
||||
color: var(--detail-muted);
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
PRODUCT INFORMATION
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 12px 0;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-category {
|
||||
display: block;
|
||||
color: var(--detail-muted);
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
line-height: 1.5;
|
||||
letter-spacing: normal;
|
||||
text-transform: none;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-title {
|
||||
margin: 0;
|
||||
color: var(--detail-text);
|
||||
font-family: Georgia, "Times New Roman", serif;
|
||||
font-size: clamp(30px, 4vw, 44px);
|
||||
font-weight: 700;
|
||||
line-height: 1.2;
|
||||
letter-spacing: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-description {
|
||||
margin: 0;
|
||||
color: var(--detail-muted);
|
||||
font-size: 16px;
|
||||
line-height: 1.8;
|
||||
white-space: pre-line;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
STOCK AVAILABILITY
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-stock {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
align-self: flex-start;
|
||||
margin-top: 8px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-stock-dot {
|
||||
display: inline-block;
|
||||
flex-shrink: 0;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
background: currentColor;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .is-available {
|
||||
color: #34754b;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .is-unavailable {
|
||||
color: #93483e;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
PURCHASE SECTION
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-purchase {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
width: 100%;
|
||||
margin-top: 12px;
|
||||
padding-top: 24px;
|
||||
border-top: 1px solid var(--detail-border);
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-price-area {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-price-label {
|
||||
color: var(--detail-muted);
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-price {
|
||||
color: var(--detail-primary);
|
||||
font-size: clamp(32px, 4vw, 44px);
|
||||
font-weight: 750;
|
||||
line-height: 1.2;
|
||||
font-variant-numeric: tabular-nums;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
ADD TO CART BUTTON
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
min-height: 52px;
|
||||
margin: 0;
|
||||
padding: 12px 24px;
|
||||
background: var(--detail-primary);
|
||||
color: #ffffff;
|
||||
border: 1px solid var(--detail-primary);
|
||||
border-radius: 6px;
|
||||
font-family: inherit;
|
||||
font-size: 15px;
|
||||
font-weight: 650;
|
||||
line-height: 1.5;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
transition: background-color 150ms ease, border-color 150ms ease;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-button svg {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-button:not(:disabled):hover {
|
||||
background: var(--detail-primary-hover);
|
||||
border-color: var(--detail-primary-hover);
|
||||
color: #ffffff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-button:disabled {
|
||||
background: #e9ece7;
|
||||
color: #59665b;
|
||||
border-color: var(--detail-border);
|
||||
opacity: 1;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
EMPTY AND LOADING STATES
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 16px;
|
||||
min-height: 220px;
|
||||
padding: 32px;
|
||||
background: var(--detail-surface);
|
||||
border: 1px solid var(--detail-border);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-empty svg {
|
||||
color: #64815d;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-empty h2 {
|
||||
margin: 0;
|
||||
color: var(--detail-text);
|
||||
font-size: 28px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-empty p {
|
||||
margin: 0;
|
||||
color: var(--detail-muted);
|
||||
font-size: 15px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-empty .jarmark-detail-button {
|
||||
width: auto;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
CART NOTIFICATION
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-notification {
|
||||
position: fixed;
|
||||
top: 96px;
|
||||
right: 24px;
|
||||
z-index: 500;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
max-width: 420px;
|
||||
padding: 16px 20px;
|
||||
background: var(--detail-surface);
|
||||
color: var(--detail-text);
|
||||
border: 1px solid #c7d6c2;
|
||||
border-left: 4px solid var(--detail-primary);
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, .08);
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
line-height: 1.5;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-notification svg {
|
||||
flex-shrink: 0;
|
||||
color: var(--detail-primary);
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
KEYBOARD ACCESSIBILITY
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-back:focus-visible,
|
||||
.jarmark-product-detail .jarmark-detail-button:focus-visible {
|
||||
outline: 3px solid #527b49;
|
||||
outline-offset: 4px;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
TABLET
|
||||
======================================== */
|
||||
|
||||
@@media (max-width: 1024px) {
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-card {
|
||||
gap: 24px;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-title {
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-info {
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-description {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-image img {
|
||||
padding: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
MOBILE
|
||||
======================================== */
|
||||
|
||||
@@media (max-width: 768px) {
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-card {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 24px;
|
||||
padding: 16px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-back {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-image {
|
||||
aspect-ratio: 4 / 3;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-info {
|
||||
gap: 12px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-title {
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-description {
|
||||
font-size: 15px;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-purchase {
|
||||
gap: 16px;
|
||||
margin-top: 8px;
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-price {
|
||||
font-size: 34px;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-button {
|
||||
min-height: 52px;
|
||||
padding: 12px 16px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-notification {
|
||||
top: auto;
|
||||
right: 12px;
|
||||
bottom: 16px;
|
||||
left: 12px;
|
||||
max-width: none;
|
||||
padding: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
SMALL MOBILE
|
||||
======================================== */
|
||||
|
||||
@@media (max-width: 480px) {
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-card {
|
||||
gap: 20px;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-image {
|
||||
aspect-ratio: 1 / 1;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-image img {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-title {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-category {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-empty {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-empty h2 {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.jarmark-product-detail .jarmark-detail-empty .jarmark-detail-button {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
REDUCED MOTION
|
||||
======================================== */
|
||||
|
||||
@@media (prefers-reduced-motion: reduce) {
|
||||
|
||||
.jarmark-product-detail,
|
||||
.jarmark-product-detail * {
|
||||
animation: none !important;
|
||||
transition: none !important;
|
||||
scroll-behavior: auto !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public int Id { get; set; }
|
||||
|
||||
private Product? product;
|
||||
private bool loading = true;
|
||||
private string? cartToken;
|
||||
|
||||
private bool showNotification;
|
||||
private string notificationMessage = "";
|
||||
|
||||
private CancellationTokenSource? notificationCts;
|
||||
|
||||
private bool imageFailed;
|
||||
|
||||
|
||||
private void HandleImageError()
|
||||
{
|
||||
imageFailed = true;
|
||||
}
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (!ApplicationState.TryTakeFromJson<string>(
|
||||
"CartToken", out cartToken)
|
||||
|| string.IsNullOrWhiteSpace(cartToken))
|
||||
{
|
||||
var context = HttpContextAccessor.HttpContext;
|
||||
|
||||
cartToken = context?.Items["CartToken"] as string
|
||||
?? context?.Request.Cookies["CartToken"];
|
||||
}
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
loading = true;
|
||||
imageFailed = false;
|
||||
|
||||
product = await DbContext.Products
|
||||
.Include(p => p.Category)
|
||||
.FirstOrDefaultAsync(p => p.Id == Id);
|
||||
|
||||
loading = false;
|
||||
}
|
||||
|
||||
private async Task HandleAddToCart(Product product)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(cartToken))
|
||||
return;
|
||||
|
||||
var cart = await DbContext.Carts
|
||||
.FirstOrDefaultAsync(c => c.Token == cartToken);
|
||||
|
||||
if (cart == null)
|
||||
{
|
||||
cart = new Cart
|
||||
{
|
||||
Token = cartToken,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
UpdatedAt = DateTime.UtcNow
|
||||
};
|
||||
|
||||
DbContext.Carts.Add(cart);
|
||||
await DbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
var cartItem = await DbContext.CartItems
|
||||
.FirstOrDefaultAsync(ci =>
|
||||
ci.CartId == cart.Id &&
|
||||
ci.ProductId == product.Id);
|
||||
|
||||
if (cartItem != null)
|
||||
{
|
||||
cartItem.Quantity++;
|
||||
}
|
||||
else
|
||||
{
|
||||
cartItem = new CartItem
|
||||
{
|
||||
CartId = cart.Id,
|
||||
ProductId = product.Id,
|
||||
Quantity = 1
|
||||
};
|
||||
|
||||
DbContext.CartItems.Add(cartItem);
|
||||
}
|
||||
|
||||
cart.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
await DbContext.SaveChangesAsync();
|
||||
|
||||
await ShowCartNotification(product.Name);
|
||||
}
|
||||
|
||||
private async Task ShowCartNotification(string productName)
|
||||
{
|
||||
notificationCts?.Cancel();
|
||||
|
||||
var currentCts = new CancellationTokenSource();
|
||||
notificationCts = currentCts;
|
||||
|
||||
notificationMessage = $"{productName} byl přidán do košíku.";
|
||||
showNotification = true;
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
try
|
||||
{
|
||||
await Task.Delay(3500, currentCts.Token);
|
||||
|
||||
if (!currentCts.Token.IsCancellationRequested)
|
||||
{
|
||||
showNotification = false;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// Nové přidání produktu restartovalo čas notifikace.
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (ReferenceEquals(notificationCts, currentCts))
|
||||
{
|
||||
notificationCts = null;
|
||||
currentCts.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
notificationCts?.Cancel();
|
||||
notificationCts?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,39 +1,75 @@
|
||||
@using Web_Jarmark.Data.Models
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
<article class="jarmark-product-card">
|
||||
|
||||
<!-- FOTOGRAFIE PRODUKTU -->
|
||||
|
||||
<div class="jarmark-card-picture">
|
||||
|
||||
<article class="market-card">
|
||||
<div class="market-product-picture">
|
||||
@if (!string.IsNullOrWhiteSpace(Product.ImageUrl) && !imageFailed)
|
||||
{
|
||||
<img src="@Product.ImageUrl.Trim()"
|
||||
alt="@Product.Name"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
@onerror="HandleImageError" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="product-icon">@ProductIcon</span>
|
||||
<div class="jarmark-card-placeholder"
|
||||
aria-hidden="true">
|
||||
|
||||
<span>@ProductIcon</span>
|
||||
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- INFORMACE O PRODUKTU -->
|
||||
|
||||
<div class="jarmark-card-body">
|
||||
|
||||
@if (Product.Category is not null)
|
||||
{
|
||||
<span class="market-product-tag">
|
||||
@Product.Category.Name
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
<div class="jarmark-card-category">
|
||||
|
||||
<div class="market-card-content">
|
||||
<h3>@Product.Name</h3>
|
||||
@Product.Category.Name
|
||||
|
||||
</div>
|
||||
}
|
||||
|
||||
<h3 class="jarmark-card-title">
|
||||
|
||||
<a href="@($"/produkt/{Product.Id}")"
|
||||
class="jarmark-card-detail">
|
||||
|
||||
@Product.Name
|
||||
|
||||
</a>
|
||||
|
||||
</h3>
|
||||
|
||||
@if (!string.IsNullOrWhiteSpace(Product.Description))
|
||||
{
|
||||
<p class="market-description">
|
||||
<p class="jarmark-card-description">
|
||||
|
||||
@Product.Description
|
||||
|
||||
</p>
|
||||
}
|
||||
|
||||
<div class="market-stock">
|
||||
<span class="market-stock-dot @(Product.StockQuantity <= 0 ? "out-of-stock" : "")"></span>
|
||||
|
||||
<!-- DOSTUPNOST -->
|
||||
|
||||
<div class="jarmark-card-stock @(Product.StockQuantity <= 0 ? "is-unavailable" : "is-available")">
|
||||
|
||||
<span class="jarmark-stock-indicator"
|
||||
aria-hidden="true">
|
||||
</span>
|
||||
|
||||
@if (Product.StockQuantity > 0)
|
||||
{
|
||||
@@ -43,25 +79,488 @@
|
||||
{
|
||||
<span>Není skladem</span>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
<div class="market-card-bottom">
|
||||
<strong>@Product.Price.ToString("N0") Kč</strong>
|
||||
|
||||
<!-- CENA A AKCE -->
|
||||
|
||||
<div class="jarmark-card-actions">
|
||||
|
||||
<div class="jarmark-card-price">
|
||||
|
||||
<strong>@Product.Price.ToString("N0") Kč</strong>
|
||||
|
||||
</div>
|
||||
|
||||
@if (OnAddToCart.HasDelegate)
|
||||
{
|
||||
<button type="button"
|
||||
class="jarmark-card-cart"
|
||||
disabled="@(Product.StockQuantity <= 0)"
|
||||
aria-label="@($"Přidat do košíku: {Product.Name}")"
|
||||
@onclick="AddToCart"
|
||||
@onclick:stopPropagation="true">
|
||||
|
||||
@if (Product.StockQuantity > 0)
|
||||
{
|
||||
<svg width="20"
|
||||
height="20"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.7"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
aria-hidden="true">
|
||||
|
||||
<path d="M3 3h2l3.5 13h10l3-10H6" />
|
||||
|
||||
<circle cx="10"
|
||||
cy="20"
|
||||
r="1" />
|
||||
|
||||
<circle cx="18"
|
||||
cy="20"
|
||||
r="1" />
|
||||
|
||||
</svg>
|
||||
|
||||
<span>Do košíku</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>Vyprodáno</span>
|
||||
}
|
||||
|
||||
</button>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
@if (OnAddToCart.HasDelegate)
|
||||
{
|
||||
<button type="button"
|
||||
class="product-cart-button"
|
||||
disabled="@(Product.StockQuantity <= 0)"
|
||||
@onclick="AddToCart">
|
||||
🛒 Do košíku
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
|
||||
</article>
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
/* ========================================
|
||||
PUBLIC PRODUCT CARD
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-card {
|
||||
--card-primary: #244b36;
|
||||
--card-primary-hover: #193b29;
|
||||
--card-surface: #ffffff;
|
||||
--card-text: #26372b;
|
||||
--card-muted: #59665b;
|
||||
--card-border: #dce3d9;
|
||||
position: relative;
|
||||
isolation: isolate;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: var(--card-surface);
|
||||
color: var(--card-text);
|
||||
border: 1px solid var(--card-border);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
font-family: inherit;
|
||||
transition: border-color 150ms ease;
|
||||
}
|
||||
|
||||
.jarmark-product-card:hover {
|
||||
border-color: #9aad96;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
PRODUCT IMAGE
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-card .jarmark-card-picture {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
aspect-ratio: 4 / 3;
|
||||
overflow: hidden;
|
||||
background: #edf0e9;
|
||||
border-bottom: 1px solid var(--card-border);
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-picture img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-width: 100%;
|
||||
object-fit: contain;
|
||||
object-position: center;
|
||||
margin: 0;
|
||||
padding: 12px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
IMAGE FALLBACK
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-card .jarmark-card-placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 120px;
|
||||
background: #e6eddf;
|
||||
color: var(--card-primary);
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-placeholder span {
|
||||
display: block;
|
||||
font-size: 48px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
CARD CONTENT
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-card .jarmark-card-body {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
min-width: 0;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
CATEGORY
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-card .jarmark-card-category {
|
||||
margin: 0;
|
||||
color: var(--card-muted);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
letter-spacing: normal;
|
||||
text-transform: none;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
PRODUCT NAME AND DETAIL LINK
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-card .jarmark-card-title {
|
||||
margin: 0;
|
||||
color: var(--card-text);
|
||||
font-family: Georgia, "Times New Roman", serif;
|
||||
font-size: 21px;
|
||||
font-weight: 700;
|
||||
line-height: 1.3;
|
||||
letter-spacing: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-detail {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-detail:hover {
|
||||
color: var(--card-primary);
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 4px;
|
||||
}
|
||||
|
||||
/*
|
||||
Celá karta zůstává kliknutelná.
|
||||
Tlačítko košíku má vlastní vrstvu.
|
||||
*/
|
||||
|
||||
.jarmark-product-card .jarmark-card-detail::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 1;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-detail:focus-visible::after {
|
||||
outline: 3px solid #527b49;
|
||||
outline-offset: -3px;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
DESCRIPTION
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-card .jarmark-card-description {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 3;
|
||||
overflow: hidden;
|
||||
overflow-wrap: anywhere;
|
||||
margin: 0;
|
||||
color: var(--card-muted);
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
STOCK AVAILABILITY
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-card .jarmark-card-stock {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 4px 0 0;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-stock-indicator {
|
||||
display: inline-block;
|
||||
flex-shrink: 0;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
background: currentColor;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.jarmark-product-card .is-available {
|
||||
color: #34754b;
|
||||
}
|
||||
|
||||
.jarmark-product-card .is-unavailable {
|
||||
color: #93483e;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
PRICE AND ACTIONS
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-card .jarmark-card-actions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
margin-top: auto;
|
||||
padding-top: 12px;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-price {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
margin: 0;
|
||||
color: var(--card-primary);
|
||||
font-size: 26px;
|
||||
line-height: 1.2;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-price strong {
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
ADD TO CART BUTTON
|
||||
======================================== */
|
||||
|
||||
.jarmark-product-card .jarmark-card-cart {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
min-height: 48px;
|
||||
margin: 0;
|
||||
padding: 12px 16px;
|
||||
background: var(--card-primary);
|
||||
color: #ffffff;
|
||||
border: 1px solid var(--card-primary);
|
||||
border-radius: 6px;
|
||||
font-family: inherit;
|
||||
font-size: 14px;
|
||||
font-weight: 650;
|
||||
line-height: 1.4;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
transition: background-color 150ms ease, border-color 150ms ease;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-cart svg {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-cart:not(:disabled):hover {
|
||||
background: var(--card-primary-hover);
|
||||
border-color: var(--card-primary-hover);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-cart:disabled {
|
||||
background: #e9ece7;
|
||||
color: #59665b;
|
||||
border-color: #dce3d9;
|
||||
opacity: 1;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-cart:focus-visible {
|
||||
outline: 3px solid #527b49;
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
TABLET
|
||||
======================================== */
|
||||
|
||||
@@media (max-width: 1024px) {
|
||||
|
||||
.jarmark-product-card .jarmark-card-body {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-title {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-price {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
MOBILE
|
||||
======================================== */
|
||||
|
||||
@@media (max-width: 640px) {
|
||||
|
||||
.jarmark-product-card .jarmark-card-body {
|
||||
gap: 8px;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-title {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-category {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-description {
|
||||
font-size: 13px;
|
||||
-webkit-line-clamp: 2;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-stock {
|
||||
gap: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-price {
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-cart {
|
||||
min-height: 48px;
|
||||
padding: 12px 8px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-cart svg {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-placeholder span {
|
||||
font-size: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
SINGLE COLUMN MOBILE
|
||||
======================================== */
|
||||
|
||||
@@media (max-width: 480px) {
|
||||
|
||||
.jarmark-product-card .jarmark-card-body {
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-title {
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-description {
|
||||
font-size: 14px;
|
||||
-webkit-line-clamp: 3;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-category {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-stock {
|
||||
gap: 8px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-price {
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.jarmark-product-card .jarmark-card-cart {
|
||||
font-size: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ========================================
|
||||
REDUCED MOTION
|
||||
======================================== */
|
||||
|
||||
@@media (prefers-reduced-motion: reduce) {
|
||||
|
||||
.jarmark-product-card,
|
||||
.jarmark-product-card * {
|
||||
animation: none !important;
|
||||
transition: none !important;
|
||||
scroll-behavior: auto !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter, EditorRequired]
|
||||
public Product Product { get; set; } = default!;
|
||||
|
||||
@@ -70,30 +569,38 @@
|
||||
|
||||
private bool imageFailed;
|
||||
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
imageFailed = false;
|
||||
}
|
||||
|
||||
|
||||
private void HandleImageError()
|
||||
{
|
||||
imageFailed = true;
|
||||
}
|
||||
|
||||
|
||||
private string ProductIcon =>
|
||||
Product.Category?.Name.Contains(
|
||||
"med",
|
||||
StringComparison.OrdinalIgnoreCase) == true ? "🍯" :
|
||||
|
||||
Product.Category?.Name.Contains(
|
||||
"cuk",
|
||||
StringComparison.OrdinalIgnoreCase) == true ? "🍪" :
|
||||
|
||||
Product.Category?.Name.Contains(
|
||||
"dřev",
|
||||
StringComparison.OrdinalIgnoreCase) == true ? "🪵" :
|
||||
|
||||
"🎁";
|
||||
|
||||
|
||||
private async Task AddToCart()
|
||||
{
|
||||
await OnAddToCart.InvokeAsync(Product);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,39 +1,45 @@
|
||||
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Web_Jarmark.Data;
|
||||
using Web_Jarmark.Data.Models;
|
||||
|
||||
namespace Web_Jarmark.Data
|
||||
{
|
||||
public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : IdentityDbContext<ApplicationUser>(options)
|
||||
public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
|
||||
: IdentityDbContext<ApplicationUser>(options)
|
||||
{
|
||||
public DbSet<Category> Categories { get; set; }
|
||||
public DbSet<Product> Products { get; set; }
|
||||
public DbSet<Cart> Carts { get; set; }
|
||||
public DbSet<CartItem> CartItems { get; set; }
|
||||
|
||||
// Objednávky
|
||||
public DbSet<Order> Orders { get; set; }
|
||||
public DbSet<OrderItem> OrderItems { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
// Nastavení vazby 1:N mezi Category a Product
|
||||
// Kategorie a produkty
|
||||
modelBuilder.Entity<Category>()
|
||||
.HasMany(c => c.Products) // Jedna kategorie obsahuje mnoho produktů
|
||||
.WithOne(p => p.Category) // Každý produkt patří ke jedné kategorii
|
||||
.HasForeignKey(p => p.CategoryId); // Cizí klíč v tabulce Product
|
||||
.HasMany(c => c.Products)
|
||||
.WithOne(p => p.Category)
|
||||
.HasForeignKey(p => p.CategoryId);
|
||||
|
||||
// Jeden košík obsahuje více položek
|
||||
// Košík a položky košíku
|
||||
modelBuilder.Entity<Cart>()
|
||||
.HasMany(c => c.CartItems)
|
||||
.WithOne(ci => ci.Cart)
|
||||
.HasForeignKey(ci => ci.CartId);
|
||||
|
||||
// Každá položka odkazuje na jeden produkt
|
||||
// Položka košíku odkazuje na produkt
|
||||
modelBuilder.Entity<CartItem>()
|
||||
.HasOne(ci => ci.Product)
|
||||
.WithMany()
|
||||
.HasForeignKey(ci => ci.ProductId);
|
||||
|
||||
// Jeden produkt může být v košíku pouze jednou
|
||||
// Produkt může být v košíku pouze jednou
|
||||
modelBuilder.Entity<CartItem>()
|
||||
.HasIndex(ci => new { ci.CartId, ci.ProductId })
|
||||
.IsUnique();
|
||||
@@ -42,7 +48,25 @@ namespace Web_Jarmark.Data
|
||||
modelBuilder.Entity<Cart>()
|
||||
.HasIndex(c => c.Token)
|
||||
.IsUnique();
|
||||
|
||||
// Zachování původních názvů tabulek objednávek
|
||||
modelBuilder.Entity<Order>()
|
||||
.ToTable("Order");
|
||||
|
||||
modelBuilder.Entity<OrderItem>()
|
||||
.ToTable("OrderItem");
|
||||
|
||||
// Objednávka a její položky
|
||||
modelBuilder.Entity<Order>()
|
||||
.HasMany(o => o.OrderItems)
|
||||
.WithOne(oi => oi.Order)
|
||||
.HasForeignKey(oi => oi.OrderId);
|
||||
|
||||
// Položka objednávky odkazuje na produkt
|
||||
modelBuilder.Entity<OrderItem>()
|
||||
.HasOne(oi => oi.Product)
|
||||
.WithMany(p => p.OrderItems)
|
||||
.HasForeignKey(oi => oi.ProductId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace Web_Jarmark.Data
|
||||
{
|
||||
// Add profile data for application users by adding properties to the ApplicationUser class
|
||||
public class ApplicationUser : IdentityUser
|
||||
{
|
||||
}
|
||||
// Jméno uživatele
|
||||
public string? FirstName { get; set; }
|
||||
|
||||
// Příjmení uživatele
|
||||
public string? LastName { get; set; }
|
||||
|
||||
// Datum registrace
|
||||
public DateTime? CreatedAt { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
namespace Web_Jarmark.Data.Models
|
||||
|
||||
namespace Web_Jarmark.Data.Models
|
||||
{
|
||||
public enum OrderStatus
|
||||
{
|
||||
@@ -8,6 +9,7 @@
|
||||
Delivered,
|
||||
Cancelled
|
||||
}
|
||||
|
||||
public enum PaymentMethod
|
||||
{
|
||||
CreditCard,
|
||||
@@ -19,23 +21,36 @@
|
||||
public class Order
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Code { get; set; }
|
||||
public OrderStatus Status { get; set; }
|
||||
public string CustomerName { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public string Note { get; set; }
|
||||
|
||||
public string Code { get; set; } =
|
||||
Guid.NewGuid().ToString("N")[..8].ToUpper();
|
||||
|
||||
// Bezpečný přístup k detailu objednávky
|
||||
public string AccessTokenHash { get; set; } = string.Empty;
|
||||
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Pending;
|
||||
|
||||
// Původní údaje zachované kvůli databázi
|
||||
public string CustomerName { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
public string Note { get; set; } = string.Empty;
|
||||
|
||||
public PaymentMethod PreferredPayment { get; set; }
|
||||
public string PaymentReference { get; set; }
|
||||
|
||||
public string PaymentReference { get; set; } = string.Empty;
|
||||
|
||||
public decimal TotalAmount { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public DateTime? ExpiresAt { get; set; }
|
||||
public DateTime? PaidAt { get; set; }
|
||||
public DateTime? IssuedAt { get; set; }
|
||||
public string IssuedByUserId { get; set; }
|
||||
public string IssuedByUserId { get; set; } = string.Empty;
|
||||
public DateTime? CancelledAt { get; set; }
|
||||
|
||||
// Navigační vlastnost pro objednávací položky
|
||||
public ICollection<OrderItem> OrderItems { get; set; } = new List<OrderItem>();
|
||||
public ICollection<OrderItem> OrderItems { get; set; }
|
||||
= new List<OrderItem>();
|
||||
}
|
||||
}
|
||||
|
||||
624
Web-Jarmark/Web-Jarmark/Migrations/20261104173931_AddCreatedAtToUsers.Designer.cs
generated
Normal file
624
Web-Jarmark/Web-Jarmark/Migrations/20261104173931_AddCreatedAtToUsers.Designer.cs
generated
Normal file
@@ -0,0 +1,624 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Web_Jarmark.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Web_Jarmark.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20261104173931_AddCreatedAtToUsers")]
|
||||
partial class AddCreatedAtToUsers
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "10.0.13");
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("NormalizedName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("RoleNameIndex");
|
||||
|
||||
b.ToTable("AspNetRoles", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("RoleId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetRoleClaims", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserClaims", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||
{
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ProviderKey")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ProviderDisplayName")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("LoginProvider", "ProviderKey");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserLogins", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserPasskey<string>", b =>
|
||||
{
|
||||
b.Property<byte[]>("CredentialId")
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("BLOB");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("CredentialId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserPasskeys", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("RoleId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("UserId", "RoleId");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetUserRoles", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("UserId", "LoginProvider", "Name");
|
||||
|
||||
b.ToTable("AspNetUserTokens", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.ApplicationUser", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("AccessFailedCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("EmailConfirmed")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("LockoutEnabled")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("NormalizedEmail")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("NormalizedUserName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("PhoneNumberConfirmed")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("SecurityStamp")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("TwoFactorEnabled")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("UserName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedEmail")
|
||||
.HasDatabaseName("EmailIndex");
|
||||
|
||||
b.HasIndex("NormalizedUserName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("UserNameIndex");
|
||||
|
||||
b.ToTable("AspNetUsers", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Cart", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Token")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Token")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Carts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.CartItem", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("CartId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Quantity")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("CartId", "ProductId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("CartItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Category", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Slug")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Categories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime?>("CancelledAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Code")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("CustomerName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("ExpiresAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("IssuedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("IssuedByUserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("PaidAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("PaymentReference")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("PreferredPayment")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<decimal>("TotalAmount")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Order");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.OrderItem", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ProductName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Quantity")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<decimal>("UnitPrice")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("OrderItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Product", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("CategoryId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ImageUrl")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("IsVisible")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("StockQuantity")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CategoryId");
|
||||
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserPasskey<string>", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.OwnsOne("Microsoft.AspNetCore.Identity.IdentityPasskeyData", "Data", b1 =>
|
||||
{
|
||||
b1.Property<byte[]>("IdentityUserPasskeyCredentialId");
|
||||
|
||||
b1.Property<byte[]>("AttestationObject")
|
||||
.IsRequired();
|
||||
|
||||
b1.Property<byte[]>("ClientDataJson")
|
||||
.IsRequired();
|
||||
|
||||
b1.Property<DateTimeOffset>("CreatedAt");
|
||||
|
||||
b1.Property<bool>("IsBackedUp");
|
||||
|
||||
b1.Property<bool>("IsBackupEligible");
|
||||
|
||||
b1.Property<bool>("IsUserVerified");
|
||||
|
||||
b1.Property<string>("Name");
|
||||
|
||||
b1.Property<byte[]>("PublicKey")
|
||||
.IsRequired();
|
||||
|
||||
b1.Property<uint>("SignCount");
|
||||
|
||||
b1.PrimitiveCollection<string>("Transports");
|
||||
|
||||
b1.HasKey("IdentityUserPasskeyCredentialId");
|
||||
|
||||
b1.ToTable("AspNetUserPasskeys");
|
||||
|
||||
b1
|
||||
.ToJson("Data")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("IdentityUserPasskeyCredentialId");
|
||||
});
|
||||
|
||||
b.Navigation("Data")
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Web_Jarmark.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.CartItem", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.Models.Cart", "Cart")
|
||||
.WithMany("CartItems")
|
||||
.HasForeignKey("CartId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Web_Jarmark.Data.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cart");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.OrderItem", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.Models.Order", "Order")
|
||||
.WithMany("OrderItems")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Web_Jarmark.Data.Models.Product", "Product")
|
||||
.WithMany("OrderItems")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Order");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Product", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.Models.Category", "Category")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("CategoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Category");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Cart", b =>
|
||||
{
|
||||
b.Navigation("CartItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Category", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Order", b =>
|
||||
{
|
||||
b.Navigation("OrderItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Product", b =>
|
||||
{
|
||||
b.Navigation("OrderItems");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Web_Jarmark.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddCreatedAtToUsers : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "CreatedAt",
|
||||
table: "AspNetUsers",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "FirstName",
|
||||
table: "AspNetUsers",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "LastName",
|
||||
table: "AspNetUsers",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CreatedAt",
|
||||
table: "AspNetUsers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "FirstName",
|
||||
table: "AspNetUsers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "LastName",
|
||||
table: "AspNetUsers");
|
||||
}
|
||||
}
|
||||
}
|
||||
628
Web-Jarmark/Web-Jarmark/Migrations/20261106180726_AddOrderAccessTokenHash.Designer.cs
generated
Normal file
628
Web-Jarmark/Web-Jarmark/Migrations/20261106180726_AddOrderAccessTokenHash.Designer.cs
generated
Normal file
@@ -0,0 +1,628 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Web_Jarmark.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Web_Jarmark.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20261106180726_AddOrderAccessTokenHash")]
|
||||
partial class AddOrderAccessTokenHash
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "10.0.13");
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("NormalizedName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("RoleNameIndex");
|
||||
|
||||
b.ToTable("AspNetRoles", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("RoleId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetRoleClaims", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserClaims", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||
{
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ProviderKey")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ProviderDisplayName")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("LoginProvider", "ProviderKey");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserLogins", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserPasskey<string>", b =>
|
||||
{
|
||||
b.Property<byte[]>("CredentialId")
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("BLOB");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("CredentialId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserPasskeys", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("RoleId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("UserId", "RoleId");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetUserRoles", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("UserId", "LoginProvider", "Name");
|
||||
|
||||
b.ToTable("AspNetUserTokens", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.ApplicationUser", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("AccessFailedCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("EmailConfirmed")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("LockoutEnabled")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("NormalizedEmail")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("NormalizedUserName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("PhoneNumberConfirmed")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("SecurityStamp")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("TwoFactorEnabled")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("UserName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedEmail")
|
||||
.HasDatabaseName("EmailIndex");
|
||||
|
||||
b.HasIndex("NormalizedUserName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("UserNameIndex");
|
||||
|
||||
b.ToTable("AspNetUsers", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Cart", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Token")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Token")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Carts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.CartItem", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("CartId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Quantity")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.HasIndex("CartId", "ProductId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("CartItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Category", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Slug")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Categories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("AccessTokenHash")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("CancelledAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Code")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("CustomerName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("ExpiresAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("IssuedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("IssuedByUserId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("PaidAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("PaymentReference")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("PreferredPayment")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<decimal>("TotalAmount")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Order", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.OrderItem", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ProductName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Quantity")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<decimal>("UnitPrice")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("OrderItem", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Product", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("CategoryId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ImageUrl")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("IsVisible")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("StockQuantity")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CategoryId");
|
||||
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserPasskey<string>", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.OwnsOne("Microsoft.AspNetCore.Identity.IdentityPasskeyData", "Data", b1 =>
|
||||
{
|
||||
b1.Property<byte[]>("IdentityUserPasskeyCredentialId");
|
||||
|
||||
b1.Property<byte[]>("AttestationObject")
|
||||
.IsRequired();
|
||||
|
||||
b1.Property<byte[]>("ClientDataJson")
|
||||
.IsRequired();
|
||||
|
||||
b1.Property<DateTimeOffset>("CreatedAt");
|
||||
|
||||
b1.Property<bool>("IsBackedUp");
|
||||
|
||||
b1.Property<bool>("IsBackupEligible");
|
||||
|
||||
b1.Property<bool>("IsUserVerified");
|
||||
|
||||
b1.Property<string>("Name");
|
||||
|
||||
b1.Property<byte[]>("PublicKey")
|
||||
.IsRequired();
|
||||
|
||||
b1.Property<uint>("SignCount");
|
||||
|
||||
b1.PrimitiveCollection<string>("Transports");
|
||||
|
||||
b1.HasKey("IdentityUserPasskeyCredentialId");
|
||||
|
||||
b1.ToTable("AspNetUserPasskeys");
|
||||
|
||||
b1
|
||||
.ToJson("Data")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("IdentityUserPasskeyCredentialId");
|
||||
});
|
||||
|
||||
b.Navigation("Data")
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Web_Jarmark.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.ApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.CartItem", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.Models.Cart", "Cart")
|
||||
.WithMany("CartItems")
|
||||
.HasForeignKey("CartId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Web_Jarmark.Data.Models.Product", "Product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cart");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.OrderItem", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.Models.Order", "Order")
|
||||
.WithMany("OrderItems")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Web_Jarmark.Data.Models.Product", "Product")
|
||||
.WithMany("OrderItems")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Order");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Product", b =>
|
||||
{
|
||||
b.HasOne("Web_Jarmark.Data.Models.Category", "Category")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("CategoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Category");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Cart", b =>
|
||||
{
|
||||
b.Navigation("CartItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Category", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Order", b =>
|
||||
{
|
||||
b.Navigation("OrderItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Product", b =>
|
||||
{
|
||||
b.Navigation("OrderItems");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Web_Jarmark.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddOrderAccessTokenHash : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "AccessTokenHash",
|
||||
table: "Order",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AccessTokenHash",
|
||||
table: "Order");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,6 +178,9 @@ namespace Web_Jarmark.Migrations
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
@@ -185,6 +188,12 @@ namespace Web_Jarmark.Migrations
|
||||
b.Property<bool>("EmailConfirmed")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("LockoutEnabled")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
@@ -308,6 +317,10 @@ namespace Web_Jarmark.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("AccessTokenHash")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("CancelledAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
@@ -362,7 +375,7 @@ namespace Web_Jarmark.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Order");
|
||||
b.ToTable("Order", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.OrderItem", b =>
|
||||
@@ -393,7 +406,7 @@ namespace Web_Jarmark.Migrations
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("OrderItem");
|
||||
b.ToTable("OrderItem", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Web_Jarmark.Data.Models.Product", b =>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -7,40 +8,64 @@ using Web_Jarmark.Data;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddRazorComponents()
|
||||
.AddInteractiveServerComponents();
|
||||
|
||||
builder.Services.AddAuthorization();
|
||||
builder.Services.AddCascadingAuthenticationState();
|
||||
|
||||
builder.Services.AddScoped<IdentityRedirectManager>();
|
||||
builder.Services.AddScoped<AuthenticationStateProvider, IdentityRevalidatingAuthenticationStateProvider>();
|
||||
|
||||
builder.Services.AddAuthentication(options =>
|
||||
{
|
||||
options.DefaultScheme = IdentityConstants.ApplicationScheme;
|
||||
options.DefaultSignInScheme = IdentityConstants.ExternalScheme;
|
||||
})
|
||||
.AddIdentityCookies();
|
||||
{
|
||||
options.DefaultScheme = IdentityConstants.ApplicationScheme;
|
||||
options.DefaultSignInScheme = IdentityConstants.ExternalScheme;
|
||||
})
|
||||
.AddIdentityCookies();
|
||||
|
||||
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection")
|
||||
?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
|
||||
|
||||
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
|
||||
builder.Services.AddDbContext<ApplicationDbContext>(options =>
|
||||
options.UseSqlite(connectionString));
|
||||
|
||||
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
||||
|
||||
builder.Services.AddIdentityCore<ApplicationUser>(options =>
|
||||
{
|
||||
options.SignIn.RequireConfirmedAccount = true;
|
||||
options.Stores.SchemaVersion = IdentitySchemaVersions.Version3;
|
||||
})
|
||||
{
|
||||
options.SignIn.RequireConfirmedAccount = true;
|
||||
options.Stores.SchemaVersion = IdentitySchemaVersions.Version3;
|
||||
})
|
||||
.AddRoles<IdentityRole>()
|
||||
.AddEntityFrameworkStores<ApplicationDbContext>()
|
||||
.AddSignInManager()
|
||||
.AddDefaultTokenProviders();
|
||||
|
||||
builder.Services.AddSingleton<IEmailSender<ApplicationUser>, IdentityNoOpEmailSender>();
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
// Vytvoření role Admin, pokud ještě neexistuje
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var roleManager = scope.ServiceProvider
|
||||
.GetRequiredService<RoleManager<IdentityRole>>();
|
||||
|
||||
if (!await roleManager.RoleExistsAsync("Admin"))
|
||||
{
|
||||
var result = await roleManager.CreateAsync(new IdentityRole("Admin"));
|
||||
|
||||
if (!result.Succeeded)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Nepodařilo se vytvořit roli Admin: "
|
||||
+ string.Join(", ", result.Errors.Select(e => e.Description)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseMigrationsEndPoint();
|
||||
@@ -48,12 +73,15 @@ if (app.Environment.IsDevelopment())
|
||||
else
|
||||
{
|
||||
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
const string cookieName = "CartToken";
|
||||
@@ -73,16 +101,18 @@ app.Use(async (context, next) =>
|
||||
});
|
||||
}
|
||||
|
||||
context.Items["CartToken"] = token;
|
||||
|
||||
await next();
|
||||
});
|
||||
|
||||
app.UseAntiforgery();
|
||||
|
||||
app.MapStaticAssets();
|
||||
|
||||
app.MapRazorComponents<App>()
|
||||
.AddInteractiveServerRenderMode();
|
||||
|
||||
// Add additional endpoints required by the Identity /Account Razor components.
|
||||
app.MapAdditionalIdentityEndpoints();
|
||||
|
||||
app.Run();
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user