diff --git a/src/components/Roster/UnitModelsTable.js b/src/components/Roster/UnitModelsTable.js index 23a8623..a4d3168 100644 --- a/src/components/Roster/UnitModelsTable.js +++ b/src/components/Roster/UnitModelsTable.js @@ -15,16 +15,17 @@ class UnitModelsTable extends React.Component { name: PropTypes.string.isRequired, }), categories: PropTypes.array.isRequired, - selections: PropTypes.array.isRequired, + selections: PropTypes.array, profiles: PropTypes.array.isRequired, }).isRequired, - rosterType: PropTypes.string.isRequired, + rosterType: PropTypes.string, onlyModel: PropTypes.string, showOnlyIds: PropTypes.arrayOf(PropTypes.string).isRequired, }; static defaultProps = { onlyModel: 'false', + rosterType: '' }; static getModelCharacteristic(model, profiles, characteristicName) { @@ -287,7 +288,7 @@ class UnitModelsTable extends React.Component { profile => profile.$.typeName === 'Weapon', ).length ) - return ''; + return null; return modelAttributs.$.name; }), ), @@ -303,7 +304,7 @@ class UnitModelsTable extends React.Component { profile => profile.$.typeName === 'Weapon', ).length ) - return ''; + return null; return modelAttributs.$.name; }), ), @@ -423,9 +424,53 @@ class UnitModelsTable extends React.Component { // If multiples submodels with different characteristics, do not regroup them but display new line for each if (UnitModelsTable.hasDifferentSubModelsCharacteristics(model)) { - return models.filter(selection => selection.selections).map( - selection => - selection.selections[0].selection + const modelFromCharacteristics = models.filter(selection => selection.profiles).map(profile => profile.profiles[0].profile + .filter( + subModel => + subModel.$.typeName === 'Unit' || profile.$.typeName === 'Model' + ) + .map(subModel => { + if (modelsDone.includes(subModel.$.name)) return null; + modelsDone.push(subModel.$.name); + return [ +