- Install Tailwind CSS v4 via @tailwindcss/vite; configure vite.config.ts - Rewrite app.css: Tailwind base, Exo 2 font, brand tokens (orange #fd6216, navy #050026), scrollbar utility; fix @import order - Rewrite AdminShell.tsx: fixed header, fixed inset body grid (sidebar + main), session check, sub-tab system, logout, admin avatar/name/role - Rewrite AdminSidebar.tsx: collapsible w-64/w-20, orange active rail + badge/dot, CSS filter for SVG icon tinting, min-h-0 flex fix - Replace 84 route stub CSS classes (page-title, card, btn, table-wrap, etc.) with Tailwind equivalents via safe class-attr-only regex script - Rewrite admin dashboard: Lucide icons in colored chip backgrounds, 4-col KPI grid, Control Plane 6-module grid, hover lift animations - Disable SSR (ssr: false) to fix Vinxi dev manifest error; clear stale .vinxi cache - Add lucide-solid icon library - Add scripts/cleanup-css.mjs for class migration Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
124 lines
5.5 KiB
TypeScript
124 lines
5.5 KiB
TypeScript
import { A } from '@solidjs/router';
|
|
import { createMemo, createResource, createSignal, For, Show } from 'solid-js';
|
|
import AdminShell from '~/components/AdminShell';
|
|
|
|
const API = '/api/gateway';
|
|
|
|
async function fetchUsers(): Promise<any[]> {
|
|
try {
|
|
const res = await fetch(`${API}/api/admin/users?role=video_editor`);
|
|
if (!res.ok) throw new Error('Failed to load');
|
|
const data = await res.json();
|
|
return Array.isArray(data) ? data : (data.users || []);
|
|
} catch {
|
|
return [];
|
|
}
|
|
}
|
|
|
|
export default function VideoEditorsPage() {
|
|
const [users] = createResource(fetchUsers);
|
|
const [search, setSearch] = createSignal('');
|
|
const [statusFilter, setStatusFilter] = createSignal('');
|
|
|
|
const filtered = createMemo(() => {
|
|
const list = users() ?? [];
|
|
const q = search().toLowerCase();
|
|
const s = statusFilter();
|
|
return list.filter((u) => {
|
|
const matchSearch =
|
|
!q ||
|
|
(u.name || u.full_name || '').toLowerCase().includes(q) ||
|
|
(u.email || '').toLowerCase().includes(q);
|
|
const matchStatus = !s || (u.status || '').toUpperCase() === s;
|
|
return matchSearch && matchStatus;
|
|
});
|
|
});
|
|
|
|
return (
|
|
<AdminShell>
|
|
<div class="mb-6 flex items-start justify-between gap-4">
|
|
<div>
|
|
<h1 class="text-2xl font-bold text-gray-900">Video Editor Management</h1>
|
|
<p class="mt-1 text-sm text-gray-500">Manage all video editor accounts on the platform.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<section class="rounded-xl border border-gray-200 bg-white shadow-sm" style="padding: 0; overflow: hidden;">
|
|
<div style="display:flex;gap:12px;padding:16px;border-bottom:1px solid #e2e8f0;flex-wrap:wrap;">
|
|
<input
|
|
type="text"
|
|
placeholder="Search by name or email..."
|
|
value={search()}
|
|
onInput={(e) => setSearch(e.currentTarget.value)}
|
|
style="border:1px solid #cbd5e1;border-radius:6px;padding:8px 12px;font-size:14px;width:260px;"
|
|
/>
|
|
<select
|
|
value={statusFilter()}
|
|
onChange={(e) => setStatusFilter(e.currentTarget.value)}
|
|
style="border:1px solid #cbd5e1;border-radius:6px;padding:8px 12px;font-size:14px;"
|
|
>
|
|
<option value="">All Status</option>
|
|
<option value="ACTIVE">ACTIVE</option>
|
|
<option value="INACTIVE">INACTIVE</option>
|
|
<option value="PENDING">PENDING</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="overflow-x-auto">
|
|
<table class="w-full text-sm">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Email</th>
|
|
<th>Status</th>
|
|
<th>Registered</th>
|
|
<th class="text-right">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<Show when={users.loading}>
|
|
<tr><td colspan="5" style="text-align:center;padding:32px;color:#64748b">Loading...</td></tr>
|
|
</Show>
|
|
<Show when={!users.loading && users.error}>
|
|
<tr><td colspan="5" style="text-align:center;padding:32px;color:#b91c1c">Failed to load. Is the backend running?</td></tr>
|
|
</Show>
|
|
<Show when={!users.loading && !users.error && filtered().length === 0}>
|
|
<tr><td colspan="5" style="text-align:center;padding:32px;color:#94a3b8">No video editor users found.</td></tr>
|
|
</Show>
|
|
<Show when={!users.loading && !users.error && filtered().length > 0}>
|
|
<For each={filtered()}>
|
|
{(item) => (
|
|
<tr>
|
|
<td style="font-weight:600;color:#0f172a">{item.name || item.full_name || '—'}</td>
|
|
<td style="color:#475569">{item.email}</td>
|
|
<td>
|
|
{item.status?.toUpperCase() === 'ACTIVE' && (
|
|
<span class="inline-flex items-center rounded-full bg-green-100 px-2.5 py-0.5 text-xs font-medium text-green-700">ACTIVE</span>
|
|
)}
|
|
{item.status?.toUpperCase() === 'INACTIVE' && (
|
|
<span class="inline-flex items-center rounded-full bg-gray-100 px-2.5 py-0.5 text-xs font-medium text-gray-600">INACTIVE</span>
|
|
)}
|
|
{item.status?.toUpperCase() === 'PENDING' && (
|
|
<span class="inline-flex items-center rounded-full bg-gray-100 px-2.5 py-0.5 text-xs font-medium text-gray-600" style="background:#fff7ed;color:#c2410c;border-color:#fed7aa;">PENDING</span>
|
|
)}
|
|
{!item.status && <span class="inline-flex items-center rounded-full bg-gray-100 px-2.5 py-0.5 text-xs font-medium text-gray-600">—</span>}
|
|
</td>
|
|
<td style="color:#475569">
|
|
{item.created_at ? new Date(item.created_at).toLocaleDateString() : '—'}
|
|
</td>
|
|
<td>
|
|
<div class="flex items-center justify-end gap-1">
|
|
<A class="inline-flex items-center rounded-lg border border-gray-200 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 transition-colors" href={`/admin/users/${item.id}`}>View</A>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
)}
|
|
</For>
|
|
</Show>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
</AdminShell>
|
|
);
|
|
}
|