diff --git a/packages/nulp_elite/src/components/Card.js b/packages/nulp_elite/src/components/Card.js index c0a867e3..523e6f52 100644 --- a/packages/nulp_elite/src/components/Card.js +++ b/packages/nulp_elite/src/components/Card.js @@ -34,6 +34,7 @@ export default function BoxCard({ items, index, onClick, continueLearning }) { return dateObject.toLocaleDateString("en-GB", options); }; + if (items.content) { return ( {items.content.organisation.length === 1 ? items.content.organisation[0] - : `${items.content.organisation[0]} + ${ - items.content.organisation.length - 1 - }`} + : `${items.content.organisation[0]} + ${items.content.organisation.length - 1 + }`} )} @@ -227,76 +227,52 @@ export default function BoxCard({ items, index, onClick, continueLearning }) { {items.organisation.length === 1 ? items.organisation[0] - : `${items.organisation[0]} + ${ - items.organisation.length - 1 - }`} + : `${items.organisation[0]} + ${items.organisation.length - 1 + }`} )} - {" "} - {items?.medium || - (items?.se_mediums && ( - <> - {items?.medium && items.medium.length > 0 ? ( - 1 - ? items.medium.join(", ") - : items.medium[0] - } - arrow - placement="top" - > - - - {items.medium.length === 1 - ? items.medium[0] - : `${items.medium[0]} + ${items.medium.length - 1}`} - - - - ) : ( - 1 + {items?.medium || items?.se_mediums ? ( + <> + {(items?.medium && items.medium.length > 0) || items?.se_mediums.length > 0 ? ( + 1 + ? items.medium.join(", ") + : items.medium?.[0] || + (items.se_mediums.length > 1 ? items.se_mediums.join(", ") - : items.se_mediums[0] - } - arrow - placement="top" + : items.se_mediums[0]) + } + arrow + placement="top" + > + - - - {items.se_mediums.length === 1 + + {items.medium?.length > 0 + ? items.medium.length === 1 + ? items.medium[0] + : `${items.medium[0]} + ${items.medium.length - 1}` + : items.se_mediums.length === 1 ? items.se_mediums[0] - : `${items.se_mediums[0]} + ${ - items.se_mediums.length - 1 - }`} - - - - )} - - ))} + : `${items.se_mediums[0]} + ${items.se_mediums.length - 1}`} + + + + ) : null} + + ) : null} @@ -304,72 +280,69 @@ export default function BoxCard({ items, index, onClick, continueLearning }) { items?.gradeLevel || items?.se_boards || items?.se_gradeLevels) && ( - <> - - {items?.board ? ( - - - - ) : ( - 0 - ? items.se_boards.join(", ") - : "" - } - placement="top" - className="labelOne cardLabelEllips" - > - + + ) : ( + 0 + ? items.se_boards.join(", ") + : "" + } + placement="top" + className="labelOne cardLabelEllips" + > + - - )} - {(items.gradeLevel || items.se_gradeLevels) && ( - 1 - ? items.gradeLevel.join(", ") - : items.gradeLevel?.[0] || + : ""} + + + )} + {(items.gradeLevel || items.se_gradeLevels) && ( + 1 + ? items.gradeLevel.join(", ") + : items.gradeLevel?.[0] || (Array.isArray(items?.se_gradeLevels) && - items.se_gradeLevels.length > 1 + items.se_gradeLevels.length > 1 ? items.se_gradeLevels.join(", ") : items.se_gradeLevels?.[0] || "") - } - placement="top" - className="labeltwo cardLabelEllips" - > - - - )} - - - )} + (Array.isArray(items?.se_gradeLevels) && + items.se_gradeLevels.length === 1) + ? items.se_gradeLevels[0] + : `${items.se_gradeLevels[0]} + ${items.se_gradeLevels.length - 1 + }`} + + + )} + + + )} ); }