import { HttpInterceptorFn } from '@angular/common/http';
import { currentRole } from './role';

/**
 * Dev-only: stamps brief requests with the current `?role=` as an `X-Role` header so
 * the backend can enforce the drafter/approver rules. Only brief endpoints carry it;
 * everything else is untouched.
 */
export const roleInterceptor: HttpInterceptorFn = (req, next) => {
  if (!req.url.includes('/api/v1/brief')) return next(req);
  return next(req.clone({ setHeaders: { 'X-Role': currentRole() } }));
};
