2026-03-19 13:50:20 +01:00
|
|
|
import { A } from '@solidjs/router';
|
feat(admin): build complete admin panel with UI parity and search/filter
- Implement all admin management pages (employees, users, jobs, leads, orders, companies, customers, candidates, approval, invoices, reviews, support, KB, pricing, coupons, credits, discounts, tax, reports, ledger)
- Implement 9 professional vertical pages (developers, designers, tutors, video editors, photographers, makeup artists, graphic designers, social media managers, fitness trainers)
- Implement internal/external dashboard and role management with builder UI
- Fix tab styling: replace inline border-bottom styles with admin-tab CSS class across 8+ pages
- Add search/filter functionality to invoice and review pages
- Add toggle status (activate/deactivate) to employees page with PATCH /api/admin/employees/{id}
- Align UI styling with NextJS admin panel for visual parity
- Add stat cards to approval page showing counts by status
- Implement graceful empty states for all list views
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-19 13:04:10 +01:00
|
|
|
import { createResource, createSignal, Show } from 'solid-js';
|
|
|
|
|
import AdminShell from '~/components/AdminShell';
|
|
|
|
|
|
|
|
|
|
const API = '/api/gateway';
|
|
|
|
|
|
|
|
|
|
type Role = {
|
|
|
|
|
id: string;
|
|
|
|
|
name: string;
|
|
|
|
|
description?: string;
|
|
|
|
|
code?: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
async function loadInternalRoles(): Promise<Role[]> {
|
|
|
|
|
try {
|
|
|
|
|
const res = await fetch(`${API}/api/admin/roles?audience=INTERNAL`);
|
|
|
|
|
if (!res.ok) throw new Error('Failed to load');
|
|
|
|
|
const data = await res.json();
|
|
|
|
|
const rows = Array.isArray(data) ? data : (data.roles || []);
|
|
|
|
|
return rows.map((r: any) => ({
|
|
|
|
|
id: r.id,
|
|
|
|
|
name: r.name,
|
|
|
|
|
description: r.description || '',
|
|
|
|
|
code: r.code || r.key || '',
|
|
|
|
|
}));
|
|
|
|
|
} catch {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function InternalRolesPage() {
|
|
|
|
|
const [roles, { refetch }] = createResource(loadInternalRoles);
|
|
|
|
|
const [deleting, setDeleting] = createSignal('');
|
|
|
|
|
const [deleteError, setDeleteError] = createSignal('');
|
|
|
|
|
|
|
|
|
|
const handleDelete = async (id: string, name: string) => {
|
|
|
|
|
if (!confirm(`Delete role "${name}"? This cannot be undone.`)) return;
|
|
|
|
|
try {
|
|
|
|
|
setDeleting(id);
|
|
|
|
|
setDeleteError('');
|
|
|
|
|
const res = await fetch(`${API}/api/admin/roles/${id}`, { method: 'DELETE' });
|
|
|
|
|
if (!res.ok) throw new Error('Failed to delete role');
|
|
|
|
|
refetch();
|
|
|
|
|
} catch (err: any) {
|
|
|
|
|
setDeleteError(err.message || 'Failed to delete role');
|
|
|
|
|
} finally {
|
|
|
|
|
setDeleting('');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<AdminShell>
|
2026-03-19 13:50:20 +01:00
|
|
|
<div class="page-hero-card page-actions">
|
feat(admin): build complete admin panel with UI parity and search/filter
- Implement all admin management pages (employees, users, jobs, leads, orders, companies, customers, candidates, approval, invoices, reviews, support, KB, pricing, coupons, credits, discounts, tax, reports, ledger)
- Implement 9 professional vertical pages (developers, designers, tutors, video editors, photographers, makeup artists, graphic designers, social media managers, fitness trainers)
- Implement internal/external dashboard and role management with builder UI
- Fix tab styling: replace inline border-bottom styles with admin-tab CSS class across 8+ pages
- Add search/filter functionality to invoice and review pages
- Add toggle status (activate/deactivate) to employees page with PATCH /api/admin/employees/{id}
- Align UI styling with NextJS admin panel for visual parity
- Add stat cards to approval page showing counts by status
- Implement graceful empty states for all list views
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-19 13:04:10 +01:00
|
|
|
<div>
|
|
|
|
|
<h1 class="page-title">Internal Role Management</h1>
|
|
|
|
|
<p class="page-subtitle">Manage internal employee roles and permissions from one clean list.</p>
|
|
|
|
|
</div>
|
|
|
|
|
<A class="btn navy" href="/admin/roles/create">Create Internal Role</A>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-03-19 13:50:20 +01:00
|
|
|
<nav class="admin-link-tabs" aria-label="Role Management Navigation">
|
|
|
|
|
<A class="admin-link-tab active" href="/admin/roles">Internal Roles</A>
|
|
|
|
|
<A class="admin-link-tab" href="/admin/runtime-roles">External Runtime Roles</A>
|
|
|
|
|
<A class="admin-link-tab" href="/admin/onboarding-schemas">Onboarding Schemas</A>
|
|
|
|
|
</nav>
|
|
|
|
|
|
feat(admin): build complete admin panel with UI parity and search/filter
- Implement all admin management pages (employees, users, jobs, leads, orders, companies, customers, candidates, approval, invoices, reviews, support, KB, pricing, coupons, credits, discounts, tax, reports, ledger)
- Implement 9 professional vertical pages (developers, designers, tutors, video editors, photographers, makeup artists, graphic designers, social media managers, fitness trainers)
- Implement internal/external dashboard and role management with builder UI
- Fix tab styling: replace inline border-bottom styles with admin-tab CSS class across 8+ pages
- Add search/filter functionality to invoice and review pages
- Add toggle status (activate/deactivate) to employees page with PATCH /api/admin/employees/{id}
- Align UI styling with NextJS admin panel for visual parity
- Add stat cards to approval page showing counts by status
- Implement graceful empty states for all list views
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-19 13:04:10 +01:00
|
|
|
<Show when={deleteError()}>
|
|
|
|
|
<div class="error-box">{deleteError()}</div>
|
|
|
|
|
</Show>
|
|
|
|
|
|
|
|
|
|
<section class="card" style="padding: 0; overflow: hidden;">
|
|
|
|
|
<div class="table-wrap">
|
|
|
|
|
<table class="list-table">
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>Name</th>
|
|
|
|
|
<th>Description</th>
|
|
|
|
|
<th class="align-right">Actions</th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
|
|
|
|
<Show when={roles.loading}>
|
|
|
|
|
<tr>
|
|
|
|
|
<td colspan="3" style="text-align:center;padding:32px;color:#64748b;">Loading internal roles...</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</Show>
|
|
|
|
|
<Show when={!roles.loading && roles.error}>
|
|
|
|
|
<tr>
|
|
|
|
|
<td colspan="3" style="text-align:center;padding:32px;color:#b91c1c;">Failed to load roles. Is the backend running?</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</Show>
|
|
|
|
|
<Show when={!roles.loading && !roles.error && roles()?.length === 0}>
|
|
|
|
|
<tr>
|
|
|
|
|
<td colspan="3" style="text-align:center;padding:32px;color:#94a3b8;">No internal roles found. Create your first role.</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</Show>
|
|
|
|
|
<Show when={!roles.loading && !roles.error && (roles()?.length ?? 0) > 0}>
|
|
|
|
|
{roles()!.map((role) => (
|
|
|
|
|
<tr>
|
|
|
|
|
<td>
|
|
|
|
|
<div>
|
|
|
|
|
<p style="margin:0;font-weight:600;color:#0f172a;">{role.name}</p>
|
|
|
|
|
<p style="margin:2px 0 0;font-size:11px;color:#94a3b8;">{role.code || role.id?.slice(0, 8)}</p>
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
<td style="color:#475569;">{role.description || 'No description added yet.'}</td>
|
|
|
|
|
<td>
|
|
|
|
|
<div class="table-actions">
|
2026-03-19 13:50:20 +01:00
|
|
|
<A class="action-icon-btn" href={`/admin/roles/${role.id}`} title="View Role">👁</A>
|
|
|
|
|
<A class="action-icon-btn" href={`/admin/roles/${role.id}/edit`} title="Edit Role">✎</A>
|
feat(admin): build complete admin panel with UI parity and search/filter
- Implement all admin management pages (employees, users, jobs, leads, orders, companies, customers, candidates, approval, invoices, reviews, support, KB, pricing, coupons, credits, discounts, tax, reports, ledger)
- Implement 9 professional vertical pages (developers, designers, tutors, video editors, photographers, makeup artists, graphic designers, social media managers, fitness trainers)
- Implement internal/external dashboard and role management with builder UI
- Fix tab styling: replace inline border-bottom styles with admin-tab CSS class across 8+ pages
- Add search/filter functionality to invoice and review pages
- Add toggle status (activate/deactivate) to employees page with PATCH /api/admin/employees/{id}
- Align UI styling with NextJS admin panel for visual parity
- Add stat cards to approval page showing counts by status
- Implement graceful empty states for all list views
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-19 13:04:10 +01:00
|
|
|
<button
|
2026-03-19 13:50:20 +01:00
|
|
|
class="action-icon-btn danger"
|
feat(admin): build complete admin panel with UI parity and search/filter
- Implement all admin management pages (employees, users, jobs, leads, orders, companies, customers, candidates, approval, invoices, reviews, support, KB, pricing, coupons, credits, discounts, tax, reports, ledger)
- Implement 9 professional vertical pages (developers, designers, tutors, video editors, photographers, makeup artists, graphic designers, social media managers, fitness trainers)
- Implement internal/external dashboard and role management with builder UI
- Fix tab styling: replace inline border-bottom styles with admin-tab CSS class across 8+ pages
- Add search/filter functionality to invoice and review pages
- Add toggle status (activate/deactivate) to employees page with PATCH /api/admin/employees/{id}
- Align UI styling with NextJS admin panel for visual parity
- Add stat cards to approval page showing counts by status
- Implement graceful empty states for all list views
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-19 13:04:10 +01:00
|
|
|
disabled={deleting() === role.id}
|
|
|
|
|
onClick={() => handleDelete(role.id, role.name)}
|
2026-03-19 13:50:20 +01:00
|
|
|
title="Delete Role"
|
feat(admin): build complete admin panel with UI parity and search/filter
- Implement all admin management pages (employees, users, jobs, leads, orders, companies, customers, candidates, approval, invoices, reviews, support, KB, pricing, coupons, credits, discounts, tax, reports, ledger)
- Implement 9 professional vertical pages (developers, designers, tutors, video editors, photographers, makeup artists, graphic designers, social media managers, fitness trainers)
- Implement internal/external dashboard and role management with builder UI
- Fix tab styling: replace inline border-bottom styles with admin-tab CSS class across 8+ pages
- Add search/filter functionality to invoice and review pages
- Add toggle status (activate/deactivate) to employees page with PATCH /api/admin/employees/{id}
- Align UI styling with NextJS admin panel for visual parity
- Add stat cards to approval page showing counts by status
- Implement graceful empty states for all list views
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-19 13:04:10 +01:00
|
|
|
>
|
2026-03-19 13:50:20 +01:00
|
|
|
{deleting() === role.id ? '...' : '🗑'}
|
feat(admin): build complete admin panel with UI parity and search/filter
- Implement all admin management pages (employees, users, jobs, leads, orders, companies, customers, candidates, approval, invoices, reviews, support, KB, pricing, coupons, credits, discounts, tax, reports, ledger)
- Implement 9 professional vertical pages (developers, designers, tutors, video editors, photographers, makeup artists, graphic designers, social media managers, fitness trainers)
- Implement internal/external dashboard and role management with builder UI
- Fix tab styling: replace inline border-bottom styles with admin-tab CSS class across 8+ pages
- Add search/filter functionality to invoice and review pages
- Add toggle status (activate/deactivate) to employees page with PATCH /api/admin/employees/{id}
- Align UI styling with NextJS admin panel for visual parity
- Add stat cards to approval page showing counts by status
- Implement graceful empty states for all list views
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-19 13:04:10 +01:00
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
))}
|
|
|
|
|
</Show>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</AdminShell>
|
|
|
|
|
);
|
|
|
|
|
}
|