<commit_before>import {
  GET_COMMANDS,
  ADD_COMMANDS,
  ADD_COMMAND,
  DELETE_COMMANDS,
  DELETE_COMMAND,
} from '../constants';

import { handleActions } from 'redux-actions';
const initialState = {
  list: null,
};

const formatOrder = order => {
  const comandas = order.comandas.map(comanda => {
    let text = '';
    if (comanda.platos.length) text = comanda.platos[0].nombre;
    if (comanda.productos.length) text = comanda.productos[0].descripcion;
    if (comanda.promos.length) text = comanda.promos[0].nombre;
    return {
      ...comanda,
      text,
    };
  });
  return {
    ...order,
    comandas,
  };
};

const formatList = list => list.map(formatOrder);

const addCommand = (order, command) => ({
  ...order,
  comandas: [...order.comandas, command],
});

const deleteCommand = (order, command) => ({
  ...order,
  comandas: order.comandas.filter(x => x.id !== command.id),
});

export default handleActions({
  [GET_COMMANDS]: (state, { payload }) => (
    {
      ...state,
      list: formatList(payload),
    }<commit_msg>fix comandas con texto vacio<commit_after>import {
  GET_COMMANDS,
  ADD_COMMANDS,
  ADD_COMMAND,
  DELETE_COMMANDS,
  DELETE_COMMAND,
} from '../constants';

import { handleActions } from 'redux-actions';
const initialState = {
  list: null,
};

const formatOrder = order => {
  const comandas = order.comandas.map(comanda => {
    let text = '';
    if (comanda.platos.length) text = comanda.platos[0].nombre;
    if (comanda.productos.length) text = comanda.productos[0].descripcion;
    if (comanda.promos.length) text = comanda.promos[0].nombre;
    return {
      ...comanda,
      text,
    };
  });
  return {
    ...order,
    comandas,
  };
};

const formatList = list => list.map(formatOrder);

const addCommand = (order, command) => ({
  ...order,
  comandas: [...order.comandas, command],
});

const deleteCommand = (order, command) => ({
  ...order,
  comandas: order.comandas.filter(x => x.id !== command.id),
});

export default handleActions({
  [GET_COMMANDS]: (state, { payload }) => (
    {
      ...state,
      list: formatList(payload).filter(x => x.text),
    }
{'fraction_non_alphanumeric': 0.16768149882903982, 'fraction_numerical': 0.002810304449648712, 'mean_word_length': 3.115606936416185, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5806371', 'n_tokens_mistral': 751, 'n_tokens_neox': 761, 'n_words': 149}