Files
frontend-app-learner-dashboard/src/containers/CourseCard/components/CourseCardActions/ViewCourseButton.jsx
Adolfo R. Brandes 89559a4987 refactor: migrate to frontend-base
BREAKING CHANGE: refactors the MFE for frontend-base.
2025-06-24 15:31:23 -03:00

38 lines
973 B
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { useIntl } from '@openedx/frontend-base';
import track from '../../../../tracking';
import { reduxHooks } from '../../../../hooks';
import useActionDisabledState from '../hooks';
import ActionButton from './ActionButton';
import messages from './messages';
export const ViewCourseButton = ({ cardId }) => {
const { formatMessage } = useIntl();
const { homeUrl } = reduxHooks.useCardCourseRunData(cardId);
const { disableViewCourse } = useActionDisabledState(cardId);
const handleClick = reduxHooks.useTrackCourseEvent(
track.course.enterCourseClicked,
cardId,
homeUrl,
);
return (
<ActionButton
disabled={disableViewCourse}
as="a"
href="#"
onClick={handleClick}
>
{formatMessage(messages.viewCourse)}
</ActionButton>
);
};
ViewCourseButton.propTypes = {
cardId: PropTypes.string.isRequired,
};
export default ViewCourseButton;