---
/* ---------------------------------------------------------------------------
 * /admin — redirect to the first registered resource.
 *
 * Auth-gated like every other admin page. Members hitting /admin without
 * the fenja role land on /; admins land on the dispatches list view (the
 * default Backstage home).
 * ------------------------------------------------------------------------- */

import { groups } from '../../admin/resources';

const user = Astro.locals.user;
if (user.role !== 'fenja') return Astro.redirect('/');

const first = groups.flatMap((g) => g.resources)[0];
return Astro.redirect(first ? `/admin/${first.key}` : '/');
---
