import React, { useState, useCallback, useMemo, useEffect, } from 'react'; import { Tabs, Tab } from '@edx/paragon'; import { useSelector, useDispatch } from 'react-redux'; import NotificationSections from './NotificationSections'; import { getNotificationTotalUnseenCounts, getSelectedNotificationType } from './data/selectors'; import { fetchNotificationList } from './data/thunks'; import { notificationTabsOptions } from './data/constants'; const NotificationTabs = () => { const notificationUnseenCounts = useSelector(getNotificationTotalUnseenCounts()); const selectedNotificationType = useSelector(getSelectedNotificationType()); const [activeTab, setActiveTab] = useState(notificationTabsOptions[0].key); const [loadMoreCount, setLoadMoreCount] = useState(10); const dispatch = useDispatch(); useEffect(() => { dispatch(fetchNotificationList({ notificationType: activeTab, notificationCount: loadMoreCount })); }, [dispatch, activeTab, loadMoreCount]); const handleActiveTab = useCallback((tab) => { setActiveTab(tab); }, []); const handleLoadMoreNotification = useCallback((count) => { setLoadMoreCount(count); }, []); const tabArray = useMemo(() => notificationTabsOptions.map((option) => ( {option.key === selectedNotificationType && } )), [notificationUnseenCounts, handleLoadMoreNotification, loadMoreCount, selectedNotificationType]); // This code is used to replace More... text to More to match the UI const buttons = document.getElementsByClassName('dropdown-toggle'); for (let i = 0; i < buttons.length; i++) { buttons[i].firstChild.nodeValue = 'More'; } return ( {tabArray} ); }; export default NotificationTabs;