Restructure /admin into tabbed area with password gate
Backups moves under /admin/backups; new Reports and Categories tabs join it (categories migrated from the top-level /categories route). The dashboard's SKU/low-stock/inventory-value cards move into Reports, which also adds sales totals and a top-selling parts list. A 5-minute sliding-cookie password gate (27182818) now wraps every /admin request, including the backup download endpoint, via a hooks.server.js auth check. The login page sits at /admin/login and escapes the admin tab chrome via a layout reset. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@ -1,31 +1,13 @@
|
||||
<script>
|
||||
import { locale, t, localized, formatMoney } from '$lib/i18n/store.js';
|
||||
import { locale, t, localized } from '$lib/i18n/store.js';
|
||||
|
||||
export let data;
|
||||
$: lang = $locale;
|
||||
$: ({ stats, lowStock, movements } = data);
|
||||
$: ({ lowStock, movements } = data);
|
||||
</script>
|
||||
|
||||
<h1>{$t('dashboard.title')}</h1>
|
||||
|
||||
<div class="grid">
|
||||
<div class="card stat">
|
||||
<div class="label">{$t('dashboard.total_skus')}</div>
|
||||
<div class="value">{stats.total}</div>
|
||||
</div>
|
||||
<div class="card stat">
|
||||
<div class="label">{$t('dashboard.low_stock')}</div>
|
||||
<div class="value" class:warn={stats.lowStock > 0}>{stats.lowStock}</div>
|
||||
</div>
|
||||
<div class="card stat">
|
||||
<div class="label">{$t('dashboard.inventory_value')}</div>
|
||||
<div class="value">
|
||||
{formatMoney(stats.inventoryValueDirams, lang)}
|
||||
<span class="cur">{$t('common.currency_short')}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>{$t('dashboard.low_stock_list')}</h2>
|
||||
{#if lowStock.length === 0}
|
||||
<p class="muted">{$t('common.none')}</p>
|
||||
@ -80,20 +62,3 @@
|
||||
</table>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||
gap: 1rem;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
.stat .label { color: #6b7388; font-size: 0.85rem; }
|
||||
.stat .value {
|
||||
font-size: 1.8rem;
|
||||
font-weight: 600;
|
||||
margin-top: 0.25rem;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.stat .value.warn { color: #b8443f; }
|
||||
.stat .cur { font-size: 0.85rem; color: #6b7388; margin-left: 0.25rem; }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user