init
This commit is contained in:
commit
ef105e1cac
22 changed files with 3001 additions and 0 deletions
430
web/static/app.css
Normal file
430
web/static/app.css
Normal file
|
|
@ -0,0 +1,430 @@
|
|||
:root {
|
||||
color-scheme: light;
|
||||
--bg: #f4f7fb;
|
||||
--panel: #ffffff;
|
||||
--text: #18202a;
|
||||
--muted: #667487;
|
||||
--line: #d9e1ec;
|
||||
--primary: #1540d1;
|
||||
--primary-strong: #102ea0;
|
||||
--accent: #dfe8ff;
|
||||
--success: #0b7a45;
|
||||
--danger: #b42318;
|
||||
--shadow: 0 18px 45px rgba(21, 32, 56, 0.08);
|
||||
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.shell {
|
||||
width: min(1120px, calc(100% - 32px));
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.site-header {
|
||||
border-bottom: 1px solid rgba(217, 225, 236, 0.7);
|
||||
background: rgba(255, 255, 255, 0.86);
|
||||
backdrop-filter: blur(10px);
|
||||
position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.header-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
min-height: 72px;
|
||||
}
|
||||
|
||||
.brand {
|
||||
font-weight: 800;
|
||||
font-size: 1.2rem;
|
||||
letter-spacing: -0.03em;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.nav {
|
||||
display: flex;
|
||||
gap: 18px;
|
||||
}
|
||||
|
||||
.nav a {
|
||||
text-decoration: none;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.main-content {
|
||||
padding: 48px 0 72px;
|
||||
}
|
||||
|
||||
.hero {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.9fr);
|
||||
gap: 28px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.eyebrow {
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.16em;
|
||||
font-size: 0.78rem;
|
||||
color: var(--primary);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: clamp(2.4rem, 5vw, 4.5rem);
|
||||
line-height: 0.98;
|
||||
margin: 10px 0 20px;
|
||||
letter-spacing: -0.05em;
|
||||
max-width: 12ch;
|
||||
}
|
||||
|
||||
.lede {
|
||||
color: var(--muted);
|
||||
font-size: 1.05rem;
|
||||
line-height: 1.7;
|
||||
max-width: 64ch;
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
margin-top: 28px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 13px 18px;
|
||||
border-radius: 12px;
|
||||
text-decoration: none;
|
||||
border: 1px solid transparent;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.button.primary {
|
||||
background: var(--primary);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.button.primary:hover {
|
||||
background: var(--primary-strong);
|
||||
}
|
||||
|
||||
.button.secondary {
|
||||
background: var(--panel);
|
||||
border-color: var(--line);
|
||||
}
|
||||
|
||||
.card {
|
||||
background: var(--panel);
|
||||
border: 1px solid rgba(217, 225, 236, 0.95);
|
||||
border-radius: 24px;
|
||||
padding: 24px;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.panel {
|
||||
background: var(--panel);
|
||||
border: 1px solid rgba(217, 225, 236, 0.95);
|
||||
border-radius: 24px;
|
||||
padding: 28px;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.narrow {
|
||||
max-width: 540px;
|
||||
}
|
||||
|
||||
.medium {
|
||||
max-width: 680px;
|
||||
}
|
||||
|
||||
.wide {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.stack-form {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.stack-form label {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.stack-form input,
|
||||
.stack-form select,
|
||||
.search-form input {
|
||||
width: 100%;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 12px;
|
||||
padding: 13px 14px;
|
||||
background: #fff;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.flash {
|
||||
padding: 14px 16px;
|
||||
border-radius: 16px;
|
||||
margin-bottom: 18px;
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.flash.success {
|
||||
background: #eaf8f0;
|
||||
color: var(--success);
|
||||
border-color: #b7e3c8;
|
||||
}
|
||||
|
||||
.flash.error {
|
||||
background: #fff2f1;
|
||||
color: var(--danger);
|
||||
border-color: #f3c7c2;
|
||||
}
|
||||
|
||||
.inline-form {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.nav-button {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--muted);
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.muted,
|
||||
.subtle,
|
||||
.meta-line {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.page-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.balance-card {
|
||||
background: linear-gradient(150deg, #0e1b4f 0%, #1540d1 100%);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.compact-balance-card {
|
||||
max-width: 640px;
|
||||
}
|
||||
|
||||
.balance-card .eyebrow,
|
||||
.balance-card .meta-line {
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
.balance-value {
|
||||
max-width: none;
|
||||
margin: 12px 0 20px;
|
||||
}
|
||||
|
||||
.toolbar,
|
||||
.search-form,
|
||||
.stats-row {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.search-form {
|
||||
min-width: min(100%, 360px);
|
||||
}
|
||||
|
||||
.stats-row {
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.stat-box {
|
||||
flex: 1 1 180px;
|
||||
}
|
||||
|
||||
.stat-box span {
|
||||
display: block;
|
||||
color: var(--muted);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.stat-box strong,
|
||||
.stats-grid dd {
|
||||
font-size: 2rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.04em;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin: 0 0 20px;
|
||||
}
|
||||
|
||||
.stats-grid dt {
|
||||
color: var(--muted);
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.stats-grid dd {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.table-wrap {
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.transaction-table {
|
||||
min-width: 980px;
|
||||
}
|
||||
|
||||
.transaction-table th,
|
||||
.transaction-table td {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.transaction-table th:last-child,
|
||||
.transaction-table td:last-child {
|
||||
white-space: normal;
|
||||
min-width: 220px;
|
||||
}
|
||||
|
||||
.transaction-table th:first-child,
|
||||
.transaction-table td:first-child {
|
||||
min-width: 140px;
|
||||
}
|
||||
|
||||
.transaction-table th:nth-child(4),
|
||||
.transaction-table td:nth-child(4),
|
||||
.transaction-table th:nth-child(5),
|
||||
.transaction-table td:nth-child(5) {
|
||||
min-width: 130px;
|
||||
}
|
||||
|
||||
.transaction-table th:nth-child(6),
|
||||
.transaction-table td:nth-child(6) {
|
||||
min-width: 120px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
text-align: left;
|
||||
padding: 12px 10px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.table th {
|
||||
color: var(--muted);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.leaderboard-note {
|
||||
color: var(--muted);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.rank-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 999px;
|
||||
background: var(--accent);
|
||||
color: var(--primary-strong);
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.leaderboard-table td:last-child {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.stack-section {
|
||||
display: grid;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.button.danger {
|
||||
background: var(--danger);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.stats-card h2 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 14px;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.clean-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.clean-list li {
|
||||
color: var(--muted);
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.clean-list li:last-child {
|
||||
border-bottom: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 800px) {
|
||||
.hero {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.page-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.header-row {
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
padding: 12px 0;
|
||||
}
|
||||
|
||||
.nav {
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
78
web/templates/layouts/base.gohtml
Normal file
78
web/templates/layouts/base.gohtml
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
{{ define "layouts/base" }}
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{{ .Title }}</title>
|
||||
<link rel="stylesheet" href="/static/app.css">
|
||||
</head>
|
||||
<body>
|
||||
<header class="site-header">
|
||||
<div class="shell header-row">
|
||||
<a class="brand" href="/">Superbanka</a>
|
||||
<nav class="nav">
|
||||
{{ if .Admin }}
|
||||
<a href="/admin">Dashboard</a>
|
||||
<a href="/leaderboard">Leaderboard</a>
|
||||
<a href="/admin/users">Users</a>
|
||||
<a href="/admin/audit-logs">Audit logs</a>
|
||||
<form method="post" action="/admin/logout" class="inline-form">
|
||||
<input type="hidden" name="csrf_token" value="{{ .CSRFToken }}">
|
||||
<button class="nav-button" type="submit">Admin logout</button>
|
||||
</form>
|
||||
{{ else if .User }}
|
||||
<a href="/app">Dashboard</a>
|
||||
<a href="/leaderboard">Leaderboard</a>
|
||||
<a href="/app/transfer">Transfer</a>
|
||||
<a href="/app/transactions">Transactions</a>
|
||||
<form method="post" action="/logout" class="inline-form">
|
||||
<input type="hidden" name="csrf_token" value="{{ .CSRFToken }}">
|
||||
<button class="nav-button" type="submit">Logout</button>
|
||||
</form>
|
||||
{{ else }}
|
||||
<a href="/leaderboard">Leaderboard</a>
|
||||
<a href="/register">Register</a>
|
||||
<a href="/login">Login</a>
|
||||
<a href="/admin/login">Admin</a>
|
||||
{{ end }}
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="shell main-content">
|
||||
{{ if .Flash }}
|
||||
<div class="flash success">{{ .Flash }}</div>
|
||||
{{ end }}
|
||||
{{ if .Error }}
|
||||
<div class="flash error">{{ .Error }}</div>
|
||||
{{ end }}
|
||||
{{ if eq .Page "home" }}
|
||||
{{ template "home" . }}
|
||||
{{ else if eq .Page "register" }}
|
||||
{{ template "register" . }}
|
||||
{{ else if eq .Page "login" }}
|
||||
{{ template "login" . }}
|
||||
{{ else if eq .Page "admin_login" }}
|
||||
{{ template "admin_login" . }}
|
||||
{{ else if eq .Page "dashboard" }}
|
||||
{{ template "dashboard" . }}
|
||||
{{ else if eq .Page "leaderboard" }}
|
||||
{{ template "leaderboard" . }}
|
||||
{{ else if eq .Page "transfer" }}
|
||||
{{ template "transfer" . }}
|
||||
{{ else if eq .Page "transactions" }}
|
||||
{{ template "transactions" . }}
|
||||
{{ else if eq .Page "admin_dashboard" }}
|
||||
{{ template "admin_dashboard" . }}
|
||||
{{ else if eq .Page "admin_users" }}
|
||||
{{ template "admin_users" . }}
|
||||
{{ else if eq .Page "admin_user_detail" }}
|
||||
{{ template "admin_user_detail" . }}
|
||||
{{ else if eq .Page "admin_audit_logs" }}
|
||||
{{ template "admin_audit_logs" . }}
|
||||
{{ end }}
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
300
web/templates/pages/home.gohtml
Normal file
300
web/templates/pages/home.gohtml
Normal file
|
|
@ -0,0 +1,300 @@
|
|||
{{ define "home" }}
|
||||
{{ $stats := .Data }}
|
||||
<section class="hero">
|
||||
<div>
|
||||
<p class="eyebrow">Fast SSR banking demo</p>
|
||||
<h1>Transfer money by account number with real ledger rules.</h1>
|
||||
<p class="lede">Each new user receives a generated CZK account number and a 10 000,00 CZK signup bonus. Admins use a separate login and every privileged action is audited.</p>
|
||||
<div class="actions">
|
||||
<a class="button primary" href="/register">Create account</a>
|
||||
<a class="button secondary" href="/login">User login</a>
|
||||
</div>
|
||||
</div>
|
||||
<aside class="card stats-card">
|
||||
<h2>System snapshot</h2>
|
||||
<dl class="stats-grid">
|
||||
<div>
|
||||
<dt>Registered users</dt>
|
||||
<dd>{{ $stats.UserCount }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Transactions</dt>
|
||||
<dd>{{ $stats.TransactionCount }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<ul class="clean-list">
|
||||
<li>Internal transfers by account number</li>
|
||||
<li>Separate admin authentication</li>
|
||||
<li>Signup bonus on registration</li>
|
||||
<li>Admin freeze, unfreeze, and adjustments</li>
|
||||
</ul>
|
||||
</aside>
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
{{ define "register" }}
|
||||
<section class="panel narrow">
|
||||
<h1>Create user account</h1>
|
||||
<p class="muted">Every signup gets a new account number and 10 000,00 CZK.</p>
|
||||
<form method="post" action="/register" class="stack-form">
|
||||
<input type="hidden" name="csrf_token" value="{{ .CSRFToken }}">
|
||||
<label>Email<input type="email" name="email" required></label>
|
||||
<label>Username<input type="text" name="username" required></label>
|
||||
<label>Password<input type="password" name="password" minlength="8" required></label>
|
||||
<button class="button primary" type="submit">Create account</button>
|
||||
</form>
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
{{ define "login" }}
|
||||
<section class="panel narrow">
|
||||
<h1>User login</h1>
|
||||
<form method="post" action="/login" class="stack-form">
|
||||
<input type="hidden" name="csrf_token" value="{{ .CSRFToken }}">
|
||||
<label>Email<input type="email" name="email" required></label>
|
||||
<label>Password<input type="password" name="password" required></label>
|
||||
<button class="button primary" type="submit">Sign in</button>
|
||||
</form>
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
{{ define "admin_login" }}
|
||||
<section class="panel narrow">
|
||||
<h1>Admin login</h1>
|
||||
<p class="muted">Separate authentication from customer accounts.</p>
|
||||
<form method="post" action="/admin/login" class="stack-form">
|
||||
<input type="hidden" name="csrf_token" value="{{ .CSRFToken }}">
|
||||
<label>Email<input type="email" name="email" required></label>
|
||||
<label>Password<input type="password" name="password" required></label>
|
||||
<button class="button primary" type="submit">Admin sign in</button>
|
||||
</form>
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
{{ define "dashboard" }}
|
||||
{{ $page := .Data }}
|
||||
<section class="stack-section">
|
||||
<div class="card balance-card compact-balance-card">
|
||||
<p class="eyebrow">Current balance</p>
|
||||
<h1 class="balance-value">{{ money $page.User.BalanceMinor }}</h1>
|
||||
<p class="meta-line">Account number: <strong>{{ $page.User.AccountNumber }}</strong></p>
|
||||
<p class="meta-line">User: {{ $page.User.Username }}</p>
|
||||
<div class="actions">
|
||||
<a class="button primary" href="/app/transfer">Send money</a>
|
||||
<a class="button secondary" href="/app/transactions">Full history</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Recent activity</h2>
|
||||
{{ template "transaction_table" $page.Transactions }}
|
||||
</div>
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
{{ define "leaderboard" }}
|
||||
{{ $page := .Data }}
|
||||
<section class="panel wide">
|
||||
<div class="toolbar">
|
||||
<div>
|
||||
<h1>Leaderboard</h1>
|
||||
<p class="muted">All active users ranked by current account balance.</p>
|
||||
</div>
|
||||
<div class="leaderboard-note">Ordered highest to lowest balance.</div>
|
||||
</div>
|
||||
<table class="table leaderboard-table">
|
||||
<thead><tr><th>#</th><th>User</th><th>Account</th><th>Balance</th></tr></thead>
|
||||
<tbody>
|
||||
{{ range $page.Entries }}
|
||||
<tr>
|
||||
<td><span class="rank-pill">{{ .Rank }}</span></td>
|
||||
<td>{{ .Username }}</td>
|
||||
<td>{{ .AccountNumber }}</td>
|
||||
<td>{{ money .BalanceMinor }}</td>
|
||||
</tr>
|
||||
{{ else }}
|
||||
<tr><td colspan="4" class="muted">No users available yet.</td></tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
{{ define "transfer" }}
|
||||
<section class="panel medium">
|
||||
<h1>Send money</h1>
|
||||
<form method="post" action="/app/transfer" class="stack-form">
|
||||
<input type="hidden" name="csrf_token" value="{{ .CSRFToken }}">
|
||||
<label>Destination account number<input type="text" name="account_number" inputmode="numeric" required></label>
|
||||
<label>Amount in CZK<input type="text" name="amount" placeholder="250,00" required></label>
|
||||
<label>Reference note<input type="text" name="description" maxlength="120"></label>
|
||||
<button class="button primary" type="submit">Send transfer</button>
|
||||
</form>
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
{{ define "transactions" }}
|
||||
{{ $page := .Data }}
|
||||
<section class="panel wide">
|
||||
<h1>Transaction history</h1>
|
||||
{{ template "transaction_table" $page.Transactions }}
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
{{ define "admin_dashboard" }}
|
||||
{{ $page := .Data }}
|
||||
<section class="stack-section">
|
||||
<div class="stats-row">
|
||||
<article class="card stat-box"><span>Users</span><strong>{{ $page.Dashboard.UserCount }}</strong></article>
|
||||
<article class="card stat-box"><span>Accounts</span><strong>{{ $page.Dashboard.AccountCount }}</strong></article>
|
||||
<article class="card stat-box"><span>Transactions</span><strong>{{ $page.Dashboard.TransactionCount }}</strong></article>
|
||||
<article class="card stat-box"><span>Frozen users</span><strong>{{ $page.Dashboard.FrozenUserCount }}</strong></article>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Recent transactions</h2>
|
||||
{{ template "transaction_table" $page.Dashboard.RecentTransactions }}
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Recent audit activity</h2>
|
||||
<div class="table-wrap">
|
||||
<table class="table">
|
||||
<thead><tr><th>When</th><th>Admin</th><th>Action</th><th>Target</th></tr></thead>
|
||||
<tbody>
|
||||
{{ range $page.Dashboard.RecentAuditActivity }}
|
||||
<tr><td>{{ dt .CreatedAt }}</td><td>{{ .AdminEmail }}</td><td>{{ .Action }}</td><td>{{ .TargetType }} / {{ .TargetID }}</td></tr>
|
||||
{{ else }}
|
||||
<tr><td colspan="4" class="muted">No audit activity yet.</td></tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
{{ define "admin_users" }}
|
||||
{{ $page := .Data }}
|
||||
<section class="panel wide">
|
||||
<div class="toolbar">
|
||||
<div>
|
||||
<h1>Users</h1>
|
||||
<p class="muted">Search by email, username, or account number.</p>
|
||||
</div>
|
||||
<form method="get" action="/admin/users" class="search-form">
|
||||
<input type="text" name="q" value="{{ $page.Search }}" placeholder="Search users">
|
||||
<button class="button secondary" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="table-wrap">
|
||||
<table class="table">
|
||||
<thead><tr><th>User</th><th>Account</th><th>Status</th><th>Balance</th><th>Created</th></tr></thead>
|
||||
<tbody>
|
||||
{{ range $page.Users }}
|
||||
<tr>
|
||||
<td><a href="/admin/users/{{ .ID }}">{{ .Username }}</a><div class="subtle">{{ .Email }}</div></td>
|
||||
<td>{{ .AccountNumber }}</td>
|
||||
<td>{{ .Status }}</td>
|
||||
<td>{{ money .BalanceMinor }}</td>
|
||||
<td>{{ dt .CreatedAt }}</td>
|
||||
</tr>
|
||||
{{ else }}
|
||||
<tr><td colspan="5" class="muted">No users found.</td></tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
{{ define "admin_user_detail" }}
|
||||
{{ $page := .Data }}
|
||||
<section class="stack-section">
|
||||
<div class="page-grid">
|
||||
<div class="card">
|
||||
<h1>{{ $page.User.Username }}</h1>
|
||||
<p class="meta-line">{{ $page.User.Email }}</p>
|
||||
<p class="meta-line">Account number: <strong>{{ $page.User.AccountNumber }}</strong></p>
|
||||
<p class="meta-line">Balance: <strong>{{ money $page.User.BalanceMinor }}</strong></p>
|
||||
<p class="meta-line">Status: <strong>{{ $page.User.Status }}</strong></p>
|
||||
<div class="actions">
|
||||
{{ if eq $page.User.Status "active" }}
|
||||
<form method="post" action="/admin/users/{{ $page.User.ID }}/freeze" class="inline-form">
|
||||
<input type="hidden" name="csrf_token" value="{{ $.CSRFToken }}">
|
||||
<button class="button danger" type="submit">Freeze user</button>
|
||||
</form>
|
||||
{{ else }}
|
||||
<form method="post" action="/admin/users/{{ $page.User.ID }}/unfreeze" class="inline-form">
|
||||
<input type="hidden" name="csrf_token" value="{{ $.CSRFToken }}">
|
||||
<button class="button secondary" type="submit">Unfreeze user</button>
|
||||
</form>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Adjust balance</h2>
|
||||
<form method="post" action="/admin/accounts/{{ $page.User.AccountID }}/adjust" class="stack-form">
|
||||
<input type="hidden" name="csrf_token" value="{{ $.CSRFToken }}">
|
||||
<label>Direction
|
||||
<select name="direction">
|
||||
<option value="credit">Credit</option>
|
||||
<option value="debit">Debit</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>Amount<input type="text" name="amount" placeholder="500,00" required></label>
|
||||
<label>Reason<input type="text" name="reason" maxlength="150" required></label>
|
||||
<button class="button primary" type="submit">Apply adjustment</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2>Recent transactions</h2>
|
||||
{{ template "transaction_table" $page.Transactions }}
|
||||
</div>
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
{{ define "admin_audit_logs" }}
|
||||
<section class="panel wide">
|
||||
<h1>Audit logs</h1>
|
||||
<div class="table-wrap">
|
||||
<table class="table">
|
||||
<thead><tr><th>When</th><th>Admin</th><th>Action</th><th>Target</th><th>Metadata</th></tr></thead>
|
||||
<tbody>
|
||||
{{ range .Data }}
|
||||
<tr>
|
||||
<td>{{ dt .CreatedAt }}</td>
|
||||
<td>{{ .AdminEmail }}</td>
|
||||
<td>{{ .Action }}</td>
|
||||
<td>{{ .TargetType }} / {{ .TargetID }}</td>
|
||||
<td><code>{{ .Metadata }}</code></td>
|
||||
</tr>
|
||||
{{ else }}
|
||||
<tr><td colspan="5" class="muted">No audit logs yet.</td></tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
{{ define "transaction_table" }}
|
||||
<div class="table-wrap">
|
||||
<table class="table transaction-table">
|
||||
<thead><tr><th>When</th><th>Type</th><th>Direction</th><th>Sender</th><th>Recipient</th><th>Amount</th><th>Description</th></tr></thead>
|
||||
<tbody>
|
||||
{{ range . }}
|
||||
<tr>
|
||||
<td>{{ dt .CreatedAt }}</td>
|
||||
<td>{{ .Type }}</td>
|
||||
<td>{{ .Direction }}</td>
|
||||
<td>{{ if .SenderAccount }}{{ .SenderAccount }}{{ else }}-{{ end }}</td>
|
||||
<td>{{ if .RecipientAccount }}{{ .RecipientAccount }}{{ else }}-{{ end }}</td>
|
||||
<td>{{ money .AmountMinor }}</td>
|
||||
<td>{{ .Description }}</td>
|
||||
</tr>
|
||||
{{ else }}
|
||||
<tr><td colspan="7" class="muted">No transactions yet.</td></tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{ end }}
|
||||
Loading…
Add table
Add a link
Reference in a new issue