diff --git a/src/client/components/ResultPage/Results.tsx b/src/client/components/ResultPage/Results.tsx index b0ba88dc..482c4748 100644 --- a/src/client/components/ResultPage/Results.tsx +++ b/src/client/components/ResultPage/Results.tsx @@ -11,14 +11,21 @@ const classes = styles.cardStyles const ResultElement = ({ result, dimensions }: any) => { if (!result) return null + const language = localStorage.getItem('language') || 'en' + return ( - + - {result.isSelected.fi} + {result.isSelected[language]} - {dimensions.map((dimension) => ( - {result[dimension].fi} + {dimensions.map((dimension: string) => ( + + {result[dimension][language]} + ))} @@ -53,7 +60,12 @@ const Results = ({ formResultData }: { formResultData: FormValues }) => { 4: selectedCompletionMethods, } - console.log('RESULTS:', resultObject) + const resultValues = Object.values(resultObject) + .slice(1) + .filter((x) => x !== '') + .map((result: string | Array) => + typeof result === 'string' ? [result] : result + ) return ( @@ -66,31 +78,15 @@ const Results = ({ formResultData }: { formResultData: FormValues }) => { - {Object.values(resultObject) - .slice(1) - .map((result: string | Array) => { - if (typeof result === 'string') { - return ( - - ) - } - if (Array.isArray(result)) { - return ( - <> - {result.map((res) => ( - - ))} - - ) - } - return null - })} + {resultValues.map((results) => + results.map((res) => ( + + )) + )} ) }