export type DetailViewerRole = 'staff' | 'supervisor';

export interface DetailOperator {
  id: string;
  name: string;
  role: DetailViewerRole;
}

const STAFF_OPERATOR: DetailOperator = {
  id: 'staff-001',
  name: '刘念念',
  role: 'staff',
};

const SUPERVISOR_OPERATOR: DetailOperator = {
  id: 'supervisor-001',
  name: '王主管',
  role: 'supervisor',
};

/** 原型默认业管人员；主管预览 URL 追加 ?role=supervisor */
export function resolveDetailOperator(): DetailOperator {
  if (typeof window === 'undefined') return STAFF_OPERATOR;
  const params = new URLSearchParams(window.location.search);
  const role = params.get('role');
  if (role === 'supervisor' || role === 'manager') return SUPERVISOR_OPERATOR;
  return STAFF_OPERATOR;
}

export function isDetailSupervisor(operator: DetailOperator): boolean {
  return operator.role === 'supervisor';
}
