Skip to content

Commit

Permalink
fix: only set default for coursetypes filter
Browse files Browse the repository at this point in the history
  • Loading branch information
pkulkark committed Sep 9, 2024
1 parent 1a1c8c2 commit fa800c9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const CoursesFilterMenu = ({
menuItems,
onItemMenuSelected,
defaultItemSelectedText,
menuType,
}) => {
const [itemMenuSelected, setItemMenuSelected] = useState(defaultItemSelectedText);
const { cleanFilters } = useSelector(getStudioHomeCoursesParams);
Expand All @@ -26,6 +27,9 @@ const CoursesFilterMenu = ({
if (cleanFilters) {
setItemMenuSelected(defaultItemSelectedText);
}
if (menuType !== 'courseTypes') {
return;
}
const defaultItem = menuItems.find(item => item.name === defaultItemSelectedText);
if (defaultItem) {
onItemMenuSelected(defaultItem.value);
Expand Down Expand Up @@ -61,6 +65,7 @@ const CoursesFilterMenu = ({
CoursesFilterMenu.defaultProps = {
defaultItemSelectedText: '',
menuItems: [],
menuType: '',
};

CoursesFilterMenu.propTypes = {
Expand All @@ -74,6 +79,7 @@ CoursesFilterMenu.propTypes = {
value: PropTypes.string.isRequired,
}),
),
menuType: PropTypes.string,
};

export default CoursesFilterMenu;
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const CoursesOrderFilterMenu = ({ onItemMenuSelected }) => {
menuItems={courseOrders}
onItemMenuSelected={handleCourseTypeSelected}
defaultItemSelectedText={intl.formatMessage(messages.coursesOrderFilterMenuAscendantCurses)}
menuType="courseOrders"
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const CoursesTypesFilterMenu = ({ onItemMenuSelected }) => {
menuItems={courseTypes}
onItemMenuSelected={handleCourseTypeSelected}
defaultItemSelectedText={intl.formatMessage(messages.coursesTypesFilterMenuActiveCurses)}
menuType="courseTypes"
/>
);
};
Expand Down

0 comments on commit fa800c9

Please sign in to comment.