import { Role } from '@shared/domain/role';

/**
 * Dev-only role stand-in (the reading MECHANISM; the `Role` type is domain). This
 * POC has one faked self-service user and no real identities, so the two-person
 * letter workflow (drafter vs approver) is driven by a `?role=` query param —
 * exactly the pattern of the `?scenario=` toggle. The backend receives it as an
 * `X-Role` header (see role.interceptor), resolves it into a `Principal`
 * server-side, and is the sole authority on what that principal may do (PRD-0002
 * phase P1, `Authz.Can`) — the FE only renders the resulting decision flags, it no
 * longer derives permission from this value itself.
 */
export function currentRole(): Role {
  const role = new URLSearchParams(window.location.search).get('role');
  return role === 'approver' || role === 'admin' ? role : 'drafter';
}
