From 21e6bb6eec59e1f806ce2f4d118e5265963bbba1 Mon Sep 17 00:00:00 2001 From: Zainab Amir Date: Thu, 27 Jul 2023 15:04:56 +0500 Subject: [PATCH] feat: update static recommendation placement (#1002) * feat: update static recommendation placement * refactor: clean recommendation code (#1003) --------- Co-authored-by: Syed Sajjad Hussain Shah <52817156+syedsajjadkazmii@users.noreply.github.com> --- .../ProductCard/Footer/index.jsx | 55 +---- src/recommendations/ProductCard/index.jsx | 14 +- src/recommendations/RecommendationsList.jsx | 67 +----- src/recommendations/RecommendationsPage.jsx | 92 ++++---- src/recommendations/data/constants.js | 7 - src/recommendations/data/utils.js | 16 -- src/recommendations/messages.js | 87 ++------ .../tests/RecommendationsList.test.jsx | 126 ++--------- .../tests/RecommendationsPage.test.jsx | 81 ++----- src/recommendations/tests/mockedData.js | 211 +++--------------- src/sass/_recommendations_page.scss | 25 +-- 11 files changed, 147 insertions(+), 634 deletions(-) diff --git a/src/recommendations/ProductCard/Footer/index.jsx b/src/recommendations/ProductCard/Footer/index.jsx index 9c7caa01..80bca885 100644 --- a/src/recommendations/ProductCard/Footer/index.jsx +++ b/src/recommendations/ProductCard/Footer/index.jsx @@ -1,72 +1,27 @@ import React from 'react'; import { useIntl } from '@edx/frontend-platform/i18n'; -import { Icon } from '@edx/paragon'; -import { Launch } from '@edx/paragon/icons'; import PropTypes from 'prop-types'; -import { isEdxProgram } from '../../data/utils'; import { cardFooterMessages, - externalLinkIconMessages, } from '../../messages'; const ProductCardFooter = ({ factoid, quickFacts, courseLength, - footerMessage, cardType, - is2UDegreeProgram, - isSubscriptionView, }) => { const intl = useIntl(); const courseLengthLabel = courseLength > 1 ? 'Courses' : 'Course'; - if (isSubscriptionView) { - return ( -

- {intl.formatMessage( - cardFooterMessages[ - 'recommendation.2u-product-card.footer-text.number-of-courses' - ], - { length: courseLength, label: courseLengthLabel }, - )} - -

- {intl.formatMessage( - cardFooterMessages[ - 'recommendation.2u-product-card.footer-text.subscription' - ], - )} -

-

- ); - } - - if (footerMessage) { - return ( -
-

{footerMessage}

- -
- ); - } - if (courseLength) { return (

{intl.formatMessage( cardFooterMessages[ - 'recommendation.2u-product-card.footer-text.number-of-courses' + 'recommendation.product-card.footer-text.number-of-courses' ], { length: courseLength, label: courseLengthLabel }, )} @@ -74,7 +29,7 @@ const ProductCardFooter = ({ ); } - if (isEdxProgram({ cardType, is2UDegreeProgram })) { + if (cardType === 'program') { if (quickFacts && quickFacts.length > 0) { const quickFactsCount = quickFacts.length; @@ -106,21 +61,15 @@ const ProductCardFooter = ({ ProductCardFooter.propTypes = { cardType: PropTypes.string, factoid: PropTypes.string, - footerMessage: PropTypes.string, quickFacts: PropTypes.arrayOf(PropTypes.shape({})), courseLength: PropTypes.number, - is2UDegreeProgram: PropTypes.bool, - isSubscriptionView: PropTypes.bool, }; ProductCardFooter.defaultProps = { cardType: '', factoid: '', - footerMessage: '', quickFacts: [], courseLength: undefined, - is2UDegreeProgram: false, - isSubscriptionView: false, }; export default ProductCardFooter; diff --git a/src/recommendations/ProductCard/index.jsx b/src/recommendations/ProductCard/index.jsx index 726c459c..65a73678 100644 --- a/src/recommendations/ProductCard/index.jsx +++ b/src/recommendations/ProductCard/index.jsx @@ -5,11 +5,9 @@ import PropTypes from 'prop-types'; import BaseCard from './BaseCard'; import Footer from './Footer'; -import { EXTERNAL_PRODUCT_SOURCES } from '../data/constants'; import { createCodeFriendlyProduct, getVariant, useProductType } from '../data/utils'; import { cardBadgesMessages, - cardFooterMessages, } from '../messages'; import { trackRecommendationCardClickOptimizely } from '../optimizelyExperiment'; import { trackRecommendationsClicked } from '../track'; @@ -27,15 +25,6 @@ const ProductCard = ({ const headerImage = product?.cardImageUrl || product?.image?.src; - const footerMessagesObj = { - [EXTERNAL_PRODUCT_SOURCES.EMERITUS]: formatMessage( - cardFooterMessages['recommendation.2u-product-card.footer-text.emeritus'], - ), - [EXTERNAL_PRODUCT_SOURCES.SHORELIGHT]: formatMessage( - cardFooterMessages['recommendation.2u-product-card.footer-text.shorelight'], - ), - }; - const schoolName = product?.organizationShortCodeOverride || product?.owners?.[0]?.name || product?.authoringOrganizations?.[0]?.name @@ -71,7 +60,7 @@ const ProductCard = ({ const productTypeCopy = formatMessage( cardBadgesMessages[ - `recommendation.2u-product-card.pill-text.${createCodeFriendlyProduct(productType)}` + `recommendation.product-card.pill-text.${createCodeFriendlyProduct(productType)}` ], ); const handleCardClick = () => { @@ -100,7 +89,6 @@ const ProductCard = ({ variant={variant} footer={(