2021-05-08 01:09:42 +05:30
|
|
|
import React, { useState } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import ScrollableAnchor from 'react-scrollable-anchor';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
|
|
import ClaimCertSteps from './ClaimCertSteps';
|
2021-06-25 20:11:27 +05:30
|
|
|
import Caret from '../../../assets/icons/caret';
|
2021-05-08 01:09:42 +05:30
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
certSlug: PropTypes.string,
|
|
|
|
i18nCertText: PropTypes.string,
|
|
|
|
superBlock: PropTypes.string
|
|
|
|
};
|
|
|
|
|
|
|
|
const CertificationCard = ({ certSlug, superBlock, i18nCertText }) => {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const [isExpanded, setIsExpanded] = useState(true);
|
|
|
|
|
|
|
|
const handleBlockClick = () => {
|
|
|
|
setIsExpanded(!isExpanded);
|
|
|
|
};
|
|
|
|
|
2021-05-10 08:48:49 -07:00
|
|
|
const {
|
|
|
|
expand: expandText,
|
|
|
|
collapse: collapseText,
|
|
|
|
steps: stepsText
|
|
|
|
} = t('intro:misc-text');
|
2021-05-08 01:09:42 +05:30
|
|
|
return (
|
|
|
|
<ScrollableAnchor id='claim-cert-block'>
|
|
|
|
<div className={`block ${isExpanded ? 'open' : ''}`}>
|
|
|
|
<div className='block-title-wrapper'>
|
|
|
|
<a className='block-link' href='#claim-cert-block'>
|
|
|
|
<h3 className='big-block-title'>
|
|
|
|
{t('certification-card.title')}
|
|
|
|
<span className='block-link-icon'>#</span>
|
|
|
|
</h3>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div className='block-description'>
|
|
|
|
{t('certification-card.intro', { i18nCertText })}
|
|
|
|
</div>
|
|
|
|
<button
|
|
|
|
aria-expanded={isExpanded}
|
|
|
|
className='map-title'
|
|
|
|
onClick={handleBlockClick}
|
|
|
|
>
|
|
|
|
<Caret />
|
|
|
|
<h4 className='course-title'>
|
|
|
|
{`${
|
|
|
|
isExpanded ? collapseText : expandText
|
|
|
|
} ${stepsText.toLowerCase()}`}
|
|
|
|
</h4>
|
|
|
|
</button>
|
|
|
|
{isExpanded && (
|
|
|
|
<ClaimCertSteps
|
|
|
|
certSlug={certSlug}
|
|
|
|
i18nCertText={i18nCertText}
|
|
|
|
superBlock={superBlock}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</ScrollableAnchor>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
CertificationCard.displayName = 'CertStatus';
|
|
|
|
CertificationCard.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default CertificationCard;
|