const roles = ['admin', 'finance', 'operations', 'viewer'];

const rolePermissions = {
  admin: [
    'Manage users, teams, roles, settings, and integrations',
    'Create, edit, delete, import, export, and assign assets',
    'Manage templates, tax rules, reports, and Workday sync'
  ],
  finance: [
    'Create, edit, delete, import, and export assets',
    'Manage templates, tax rules, reports, and depreciation workflows',
    'Assign and release assets'
  ],
  operations: [
    'Create and edit assets',
    'Assign and release assets',
    'Manage asset tasks, files, employees, and custody details'
  ],
  viewer: [
    'View assets, assignments, employees, templates, tax rules, and reports',
    'No create, update, delete, import, export, or integration access'
  ]
};

const roleCapabilities = [
  { key: 'view_assets', label: 'View assets', roles: ['admin', 'finance', 'operations', 'viewer'] },
  { key: 'edit_assets', label: 'Create/edit assets', roles: ['admin', 'finance', 'operations'] },
  { key: 'delete_assets', label: 'Delete assets', roles: ['admin', 'finance'] },
  { key: 'import_export', label: 'Import/export data', roles: ['admin', 'finance'] },
  { key: 'assign_assets', label: 'Assign assets', roles: ['admin', 'finance', 'operations'] },
  { key: 'templates', label: 'Manage templates', roles: ['admin', 'finance'] },
  { key: 'tax_rules', label: 'Manage tax rules', roles: ['admin', 'finance'] },
  { key: 'workday', label: 'Manage Workday connector', roles: ['admin'] },
  { key: 'users', label: 'Manage users and teams', roles: ['admin'] },
  { key: 'settings', label: 'Manage app settings', roles: ['admin'] }
];

function isValidRole(role) {
  return roles.includes(role);
}

module.exports = {
  isValidRole,
  roleCapabilities,
  rolePermissions,
  roles
};
