/**
 * Maps sidebar / activePage keys → default role + workflow bucket on Assignments.
 * Keys are used in App.jsx (executor role) only.
 */
export const ASSIGNMENT_ROUTE_MAP = {
  'executor-assignments': { view: 'executor', category: 'all' },
  'executor-assignments-not-started': { view: 'executor', category: 'not_started' },
  /** Legacy route: “In process” bucket removed for executor — open All. */
  'executor-assignments-in-process': { view: 'executor', category: 'all' },
  'executor-assignments-verification-required': { view: 'executor', category: 'verification_required' },
  'executor-assignments-returned': { view: 'executor', category: 'returned' },
  'executor-assignments-done': { view: 'executor', category: 'done' },
  'verifier-assignments': { view: 'verifier', category: 'all' },
  'verifier-assignments-not-started': { view: 'verifier', category: 'not_started' },
  'verifier-assignments-in-process': { view: 'verifier', category: 'in_process' },
  /** Legacy: “Verification required” bucket removed for verifier — open All. */
  'verifier-assignments-verification-required': { view: 'verifier', category: 'all' },
  'verifier-assignments-returned': { view: 'verifier', category: 'returned' },
  'verifier-assignments-done': { view: 'verifier', category: 'done' }
};

/** Allowed `activePage` values for executor / verifier shell (sidebar + route guard). */
export const EXECUTOR_SHELL_PAGE_KEYS = new Set([
  'dashboard',
  'upload',
  'executor-videos',
  'verifier-videos',
  ...Object.keys(ASSIGNMENT_ROUTE_MAP)
]);

/** Sidebar / dashboard → activePage key for a workflow bucket. */
export function assignmentsPageKey(view, category) {
  const prefix = view === 'verifier' ? 'verifier' : 'executor';
  if (!category || category === 'all' || category === 'other') return `${prefix}-assignments`;
  const slug = {
    not_started: 'not-started',
    in_process: 'in-process',
    verification_required: 'verification-required',
    returned: 'returned',
    done: 'done'
  }[category];
  if (!slug) return `${prefix}-assignments`;
  return `${prefix}-assignments-${slug}`;
}
