/**
 * 用户、角色、部门数据源
 */
import type { DataSourceConfig } from '../types';

export const usersConfig: DataSourceConfig = {
  url: '/api/v1/user/list',
  transform: (data: any[]) => {
    return data.map((item: any) => ({
      label: `${item.nickname} (${item.username})`,
      value: item.username,  // 后台使用 username 进行审批
      id: item.id,
      email: item.email,
      departmentName: item.departmentName
    }));
  }
};

export const rolesConfig: DataSourceConfig = {
  url: '/api/v1/role/list',
  transform: (data: any[]) => {
    return data.map((item: any) => ({
      label: `${item.name} (${item.code})`,
      value: item.code,  // 使用 code 作为值
      id: item.id,
      description: item.description
    }));
  }
};

export const departmentsConfig: DataSourceConfig = {
  url: '/api/v1/department/list',
  transform: (data: any[]) => {
    return data.map((item: any) => ({
      label: `${item.name} (${item.code})`,
      value: item.code,  // 使用 code 作为值
      id: item.id,
      description: item.description,
      parentId: item.parentId
    }));
  }
};

