2026-03-19 13:50:20 +01:00
|
|
|
import { A, useSearchParams } from '@solidjs/router';
|
2026-03-20 16:09:21 +01:00
|
|
|
import { createMemo, createResource, Show } from 'solid-js';
|
2026-03-16 23:30:37 +01:00
|
|
|
import AdminShell from '~/components/AdminShell';
|
2026-03-19 15:29:22 +01:00
|
|
|
import ExternalRoleTabs from '~/components/admin/ExternalRoleTabs';
|
2026-03-16 23:30:37 +01:00
|
|
|
|
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
|
|
|
const API = '/api/gateway';
|
2026-03-16 23:30:37 +01:00
|
|
|
|
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
|
|
|
type ExternalRole = {
|
|
|
|
|
id: string;
|
|
|
|
|
roleKey: string;
|
|
|
|
|
displayName: string;
|
|
|
|
|
vertical: string;
|
|
|
|
|
enabledModules: string[];
|
|
|
|
|
onboardingSchemaId: string;
|
|
|
|
|
isActive: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
async function loadExternalRoles(): Promise<ExternalRole[]> {
|
|
|
|
|
try {
|
|
|
|
|
const res = await fetch(`${API}/api/admin/roles?audience=EXTERNAL`);
|
|
|
|
|
if (!res.ok) throw new Error('Failed to load');
|
|
|
|
|
const data = await res.json();
|
2026-03-23 21:13:42 +01:00
|
|
|
const rows = (Array.isArray(data) ? data : (data.roles || []))
|
|
|
|
|
.filter((item: any) => String(item?.audience || '').toUpperCase() === 'EXTERNAL');
|
|
|
|
|
return await Promise.all(
|
|
|
|
|
rows.map(async (r: any) => {
|
|
|
|
|
const roleId = String(r.id || '');
|
|
|
|
|
const roleKey = String(r.key || r.role_key || r.roleKey || '');
|
|
|
|
|
const cfg = r.config_json || {};
|
|
|
|
|
|
|
|
|
|
let enabledModules = Array.isArray(cfg?.enabledModules) ? cfg.enabledModules : [];
|
|
|
|
|
let onboardingSchemaId = String(cfg?.onboardingSchemaId || r.onboarding_schema_id || '');
|
|
|
|
|
|
|
|
|
|
if (roleId) {
|
|
|
|
|
try {
|
|
|
|
|
const dashboardRes = await fetch(`${API}/api/admin/dashboard-config/${roleId}?audience=EXTERNAL`);
|
|
|
|
|
if (dashboardRes.ok) {
|
|
|
|
|
const detail = await dashboardRes.json();
|
|
|
|
|
const json = detail?.config_json || {};
|
|
|
|
|
const byEnabled = Array.isArray(json?.enabled_modules) ? json.enabled_modules : [];
|
|
|
|
|
const byNav = Array.isArray(json?.nav) ? json.nav.map((item: any) => String(item?.key || '').trim()).filter(Boolean) : [];
|
|
|
|
|
if (enabledModules.length === 0) {
|
|
|
|
|
enabledModules = byEnabled.length > 0 ? byEnabled : byNav;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch {}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const onboardingRes = await fetch(`${API}/api/admin/onboarding-config/${roleId}`);
|
|
|
|
|
if (onboardingRes.ok) {
|
|
|
|
|
const onboarding = await onboardingRes.json();
|
|
|
|
|
if (!onboardingSchemaId) onboardingSchemaId = String(onboarding?.id || '');
|
|
|
|
|
}
|
|
|
|
|
} catch {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
id: roleId,
|
|
|
|
|
roleKey,
|
|
|
|
|
displayName: r.name || r.displayName || r.display_name || roleKey,
|
|
|
|
|
vertical: cfg?.vertical || r.vertical || '',
|
|
|
|
|
enabledModules,
|
|
|
|
|
onboardingSchemaId,
|
|
|
|
|
isActive: r.is_active !== false,
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
|
);
|
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
|
|
|
} catch {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function RuntimeRolesPage() {
|
2026-03-19 13:50:20 +01:00
|
|
|
const [searchParams] = useSearchParams();
|
2026-03-20 16:09:21 +01:00
|
|
|
const [roles] = createResource(loadExternalRoles);
|
2026-03-19 13:50:20 +01:00
|
|
|
const selectedRoleKey = createMemo(() => (searchParams.roleKey || '').toLowerCase());
|
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-16 23:30:37 +01:00
|
|
|
return (
|
|
|
|
|
<AdminShell>
|
2026-03-19 15:29:22 +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">External Role Management</h1>
|
2026-03-19 15:29:22 +01:00
|
|
|
<p class="page-subtitle">Manage canonical external runtime roles, enabled modules, onboarding assignment, approval gates, and default runtime destinations from one place.</p>
|
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>
|
2026-03-19 15:29:22 +01:00
|
|
|
<div class="page-actions-right">
|
2026-03-19 13:50:20 +01:00
|
|
|
<A class="btn" href="/admin/role-ui-configs">Inspector</A>
|
|
|
|
|
<A class="btn navy" href="/admin/runtime-roles/new">Create External Role</A>
|
|
|
|
|
</div>
|
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>
|
|
|
|
|
|
2026-03-19 15:29:22 +01:00
|
|
|
<ExternalRoleTabs />
|
2026-03-19 13:50:20 +01:00
|
|
|
|
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
|
|
|
<section class="card" style="padding: 0; overflow: hidden;">
|
|
|
|
|
<div style="display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid #e2e8f0">
|
|
|
|
|
<div>
|
|
|
|
|
<h2 style="margin:0;font-size:17px;font-weight:700">Published External Roles</h2>
|
2026-03-19 15:29:22 +01:00
|
|
|
<p style="margin:4px 0 0;font-size:12px;color:#64748b">Only canonical external runtime roles are shown here. Legacy or malformed role rows are hidden from this management surface.</p>
|
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>
|
|
|
|
|
<Show when={!roles.loading}>
|
|
|
|
|
<span style="font-size:13px;color:#64748b">{roles()?.length || 0} roles</span>
|
|
|
|
|
</Show>
|
2026-03-16 23:30:37 +01:00
|
|
|
</div>
|
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 class="table-wrap">
|
|
|
|
|
<table class="list-table">
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>Role</th>
|
|
|
|
|
<th>Type</th>
|
|
|
|
|
<th>Modules</th>
|
|
|
|
|
<th>Schema</th>
|
|
|
|
|
<th>Status</th>
|
|
|
|
|
<th class="align-right">Actions</th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
|
|
|
|
<Show when={roles.loading}>
|
|
|
|
|
<tr><td colspan="6" style="text-align:center;padding:32px;color:#64748b">Loading external roles...</td></tr>
|
|
|
|
|
</Show>
|
|
|
|
|
<Show when={!roles.loading && roles.error}>
|
|
|
|
|
<tr><td colspan="6" style="text-align:center;padding:32px;color:#b91c1c">Failed to load external roles. Is the backend running?</td></tr>
|
|
|
|
|
</Show>
|
|
|
|
|
<Show when={!roles.loading && !roles.error && roles()?.length === 0}>
|
|
|
|
|
<tr><td colspan="6" style="text-align:center;padding:32px;color:#94a3b8">No external roles configured yet.</td></tr>
|
|
|
|
|
</Show>
|
|
|
|
|
<Show when={!roles.loading && !roles.error && (roles()?.length ?? 0) > 0}>
|
|
|
|
|
{roles()!.map((role) => (
|
2026-03-19 13:50:20 +01:00
|
|
|
<tr class={selectedRoleKey() === role.roleKey.toLowerCase() ? 'row-selected' : ''}>
|
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
|
|
|
<td>
|
|
|
|
|
<div>
|
|
|
|
|
<p style="margin:0;font-weight:600;color:#0f172a">{role.displayName}</p>
|
|
|
|
|
<p style="margin:2px 0 0;font-size:11px;color:#94a3b8">{role.roleKey}</p>
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
<td style="color:#475569">{role.vertical || '—'}</td>
|
|
|
|
|
<td style="color:#475569">{role.enabledModules.length}</td>
|
|
|
|
|
<td style="color:#475569;font-size:12px">{role.onboardingSchemaId || '—'}</td>
|
|
|
|
|
<td>
|
|
|
|
|
<span class={`status-chip ${role.isActive ? 'active' : ''}`}>
|
|
|
|
|
{role.isActive ? 'Active' : 'Inactive'}
|
|
|
|
|
</span>
|
|
|
|
|
</td>
|
2026-03-19 03:36:46 +01:00
|
|
|
<td>
|
|
|
|
|
<div class="table-actions">
|
2026-03-19 13:50:20 +01:00
|
|
|
<A class="action-icon-btn" href={`/admin/runtime-roles/${encodeURIComponent(role.roleKey)}`} target="_blank" rel="noreferrer" title="View External Role">👁</A>
|
|
|
|
|
<A class="action-icon-btn" href={`/admin/runtime-roles/${encodeURIComponent(role.roleKey)}`} title="Edit External Role">✎</A>
|
2026-03-19 03:36:46 +01:00
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
))}
|
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>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
2026-03-16 23:30:37 +01:00
|
|
|
</section>
|
|
|
|
|
</AdminShell>
|
|
|
|
|
);
|
|
|
|
|
}
|