fix: add popular and trending products lists (#1000)

This commit is contained in:
Shahbaz Shabbir
2023-07-27 10:54:57 +05:00
committed by GitHub
parent 423958c899
commit bfa7874108
3 changed files with 10 additions and 3 deletions

View File

@@ -24,8 +24,11 @@ const configuration = {
BANNER_IMAGE_MEDIUM: process.env.BANNER_IMAGE_MEDIUM || '',
BANNER_IMAGE_SMALL: process.env.BANNER_IMAGE_SMALL || '',
BANNER_IMAGE_EXTRA_SMALL: process.env.BANNER_IMAGE_EXTRA_SMALL || '',
// Miscellaneous
// Recommendation constants
GENERAL_RECOMMENDATIONS: process.env.GENERAL_RECOMMENDATIONS || '[]',
POPULAR_PRODUCTS: process.env.POPULAR_PRODUCTS || '[]',
TRENDING_PRODUCTS: process.env.TRENDING_PRODUCTS || '[]',
// Miscellaneous
INFO_EMAIL: process.env.INFO_EMAIL || '',
ZENDESK_KEY: process.env.ZENDESK_KEY,
ZENDESK_LOGO_URL: process.env.ZENDESK_LOGO_URL,

View File

@@ -18,13 +18,15 @@ const RecommendationsPage = (props) => {
const registrationResponse = location.state?.registrationResult;
const userId = location.state?.userId;
const DASHBOARD_URL = getConfig().LMS_BASE_URL.concat(DEFAULT_REDIRECT_URL);
const POPULAR_PRODUCTS = JSON.parse(getConfig().POPULAR_PRODUCTS);
const TRENDING_PRODUCTS = JSON.parse(getConfig().TRENDING_PRODUCTS);
const { formatMessage } = useIntl();
const [selectedRecommendationsType, setSelectedRecommendationsType] = useState(RECOMMENDATIONS_OPTION_LIST[1]);
const [recommendations] = useState([]);
const [recommendations, setRecommendations] = useState(POPULAR_PRODUCTS);
const handleRecommendationType = (option) => {
setSelectedRecommendationsType(option);
setRecommendations(option.value === 'popular' ? POPULAR_PRODUCTS : TRENDING_PRODUCTS);
};
if (!registrationResponse) {

View File

@@ -25,6 +25,8 @@ jest.mock('../data/service', () => ({
describe('RecommendationsPageTests', () => {
mergeConfig({
GENERAL_RECOMMENDATIONS: '[]',
POPULAR_PRODUCTS: '[]',
TRENDING_PRODUCTS: '[]',
});
let defaultProps = {};