import { UserInfoResponse } from './api/user-info.response.model';
import { mapResponseToRoles, Role } from './role.model';

export interface UserInfo {
  id: string;
  firstName: string;
  lastName: string;
  fullName: string;
  roles: Role[];
}

export function mapResponseToUserInfo(data: UserInfoResponse): UserInfo {
  const { id, firstName, lastName, roles } = data;

  return {
    id,
    firstName,
    lastName,
    fullName: `${firstName} ${lastName}`,
    roles: mapResponseToRoles(roles),
  };
}
