Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
import PropTypes from 'prop-types';
import { type FC } from 'react';
import { useSelector } from 'react-redux';
import { Button } from '@openedx/paragon';
import { Link } from 'react-router-dom';

import { DeprecatedReduxState } from '@src/store';
import { getCourseId, getSequenceId } from '@src/course-unit/data/selectors';
import UnitIcon from './UnitIcon';
import { getCourseId, getSequenceId } from '../../data/selectors';

const UnitButton = ({
interface Props {
unitId: string;
className?: string;
showTitle?: boolean;
isActive?: boolean;
}

const UnitButton: FC<Props> = ({
unitId,
className,
showTitle,
isActive, // passed from parent (SequenceNavigationTabs)
showTitle = false,
}) => {
const courseId = useSelector(getCourseId);
const sequenceId = useSelector(getSequenceId);

const unit = useSelector((state) => state.models.units[unitId]);
const unit = useSelector((state: DeprecatedReduxState) => state.models.units[unitId]);
const { title, contentType } = unit || {};

return (
Expand All @@ -33,17 +41,4 @@ const UnitButton = ({
);
};

UnitButton.propTypes = {
className: PropTypes.string,
showTitle: PropTypes.bool,
unitId: PropTypes.string.isRequired,
isActive: PropTypes.bool,
};

UnitButton.defaultProps = {
className: undefined,
showTitle: false,
isActive: false,
};

export default UnitButton;
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import PropTypes from 'prop-types';
import { type FC } from 'react';
import { Icon } from '@openedx/paragon';
import { BookOpen as BookOpenIcon } from '@openedx/paragon/icons';

import { UNIT_TYPE_ICONS_MAP, UNIT_ICON_TYPES } from '../../../generic/block-type-utils/constants';
import { UNIT_TYPE_ICONS_MAP } from '@src/generic/block-type-utils/constants';

const UnitIcon = ({ type }) => {
interface Props {
type: keyof typeof UNIT_TYPE_ICONS_MAP;
}

const UnitIcon: FC<Props> = ({ type }) => {
const icon = UNIT_TYPE_ICONS_MAP[type] || BookOpenIcon;

return <Icon src={icon} screenReaderText={type} />;
};

UnitIcon.propTypes = {
type: PropTypes.oneOf(UNIT_ICON_TYPES).isRequired,
};

export default UnitIcon;
2 changes: 0 additions & 2 deletions src/generic/block-type-utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import {
} from '@openedx/paragon/icons';
import NewsstandIcon from '../NewsstandIcon';

export const UNIT_ICON_TYPES = ['video', 'other', 'vertical', 'problem', 'lock'];

export const COMPONENT_TYPES = {
advanced: 'advanced',
discussion: 'discussion',
Expand Down