import { Parents } from 'src/entities/parents.entity';
import { sanitizeUserForApi } from '../../common/utils/sanitize-user-for-api';

/**
 * Sérialisation API fiche parent — ticket #131.
 * Garantit `user`, `co_parent` (si présent) et relations sans champs sensibles.
 */
export function mapParentForApi(parent: Parents): Parents {
  return {
    ...parent,
    user: sanitizeUserForApi(parent.user)!,
    co_parent: sanitizeUserForApi(parent.co_parent),
  };
}

export function mapParentsForApi(parents: Parents[]): Parents[] {
  return parents.map(mapParentForApi);
}
