diff --git a/src/routes/Morph/MorphResults.js b/src/routes/Morph/MorphResults.js index bc98ff04..e5ca54b1 100644 --- a/src/routes/Morph/MorphResults.js +++ b/src/routes/Morph/MorphResults.js @@ -10,6 +10,16 @@ const MorphResults = props => { let resultsArr = props.results || [] const outputText = styles => { + // If there were errors, print them + if (typeof resultsArr[0] === 'string') { + return resultsArr.map((error, i) => ( +
+ {error} +
+ )) + } + + // Format the results according to the selected option const format = result => { if (props.outputFormat === 'oo') { return result.output.trim() @@ -20,12 +30,14 @@ const MorphResults = props => { } } + // Assign the changed class if the result is different from last run const classes = result => { return result.changed && props.showDiff - ? classNames(props.styles.outText, props.styles.changed) - : props.styles.outText + ? classNames(styles.outText, styles.changed) + : styles.outText } + // Return the results text return resultsArr.length > 0 ? ( resultsArr.map((result, i) => (@@ -33,7 +45,7 @@ const MorphResults = props => {
)) ) : ( - + ) } @@ -83,13 +95,16 @@ MorphResults.propTypes = { classes: PropTypes.object, styles: PropTypes.object, outputFormat: PropTypes.string.isRequired, - results: PropTypes.arrayOf( - PropTypes.shape({ - input: PropTypes.string.isRequired, - output: PropTypes.string.isRequired, - changed: PropTypes.bool.isRequired - }) - ), + results: PropTypes.oneOfType([ + PropTypes.arrayOf( + PropTypes.shape({ + input: PropTypes.string.isRequired, + output: PropTypes.string.isRequired, + changed: PropTypes.bool.isRequired + }) + ).isRequired, + PropTypes.arrayOf(PropTypes.string.isRequired).isRequired + ]), showDiff: PropTypes.bool.isRequired } diff --git a/src/routes/Morph/MorphService.js b/src/routes/Morph/MorphService.js index ce189322..382f1052 100644 --- a/src/routes/Morph/MorphService.js +++ b/src/routes/Morph/MorphService.js @@ -246,9 +246,15 @@ class MorphService { const categories = this.splitCategories(newData.categories) const rewriteRules = this.splitRewriteRules(newData.rewriteRules) const soundChanges = this.splitSoundChanges(newData.soundChanges) - console.log(categories) - console.log(rewriteRules) - console.log(soundChanges) + + let allErrors = [] + if (typeof categories[0] === 'string') + allErrors = allErrors.concat(categories) + if (typeof rewriteRules[0] === 'string') + allErrors = allErrors.concat(rewriteRules) + if (typeof soundChanges[0] === 'string') + allErrors = allErrors.concat(soundChanges) + if (allErrors.length) return allErrors let results = [ {