From 7c4676d0a45281bd4e5517454dcb532df67d6e10 Mon Sep 17 00:00:00 2001 From: Mrugesh Mohapatra <1884376+raisedadead@users.noreply.github.com> Date: Sat, 8 May 2021 01:09:42 +0530 Subject: [PATCH] fix(client): quick-fix for cert claiming (#42055) * chore: reinstate the quick-fix for cert claiming This reverts commit d80d093c8bd2ee9f24dace9e98c50eae9cdb7cfa. * feat: add progress to claim cert card --- client/i18n/locales/english/intro.json | 1 + client/i18n/locales/english/translations.json | 10 ++ .../src/components/settings/Certification.js | 9 +- client/src/components/settings/Honesty.js | 2 +- client/src/components/settings/Privacy.js | 2 +- .../__snapshots__/Honesty.test.js.snap | 2 + .../templates/Introduction/SuperBlockIntro.js | 1 + .../Introduction/components/CertChallenge.js | 11 +++ .../components/CertificationCard.js | 67 +++++++++++++ .../Introduction/components/ClaimCertSteps.js | 99 +++++++++++++++++++ 10 files changed, 200 insertions(+), 4 deletions(-) create mode 100644 client/src/templates/Introduction/components/CertificationCard.js create mode 100644 client/src/templates/Introduction/components/ClaimCertSteps.js diff --git a/client/i18n/locales/english/intro.json b/client/i18n/locales/english/intro.json index d39ff3d0e4..46227ae015 100644 --- a/client/i18n/locales/english/intro.json +++ b/client/i18n/locales/english/intro.json @@ -506,6 +506,7 @@ "certification": "{{cert}} Certification", "browse-other": "Browse our other free certifications\n(we recommend doing these in order)", "courses": "Courses", + "steps": "Steps", "expand": "Expand", "collapse": "Collapse" } diff --git a/client/i18n/locales/english/translations.json b/client/i18n/locales/english/translations.json index 15bd0852f0..99e0a7589a 100644 --- a/client/i18n/locales/english/translations.json +++ b/client/i18n/locales/english/translations.json @@ -554,5 +554,15 @@ "Neural Network SMS Text Classifier": "Neural Network SMS Text Classifier" } } + }, + "certification-card": { + "title": "Claim Your Certification", + "intro": "Complete the following steps to claim and view your {{i18nCertText}}", + "complete-project": "Complete {{i18nCertText}} Projects", + "accept-honesty": "Accept our Academic Honesty Policy", + "set-name": "Set your name, and make it public", + "set-certs-public": "Set your certificication settings to public", + "set-profile-public": "Set your profile settings to public", + "set-claim": "Claim and view your certification" } } diff --git a/client/src/components/settings/Certification.js b/client/src/components/settings/Certification.js index bfe08b93b6..7f8d67eb21 100644 --- a/client/src/components/settings/Certification.js +++ b/client/src/components/settings/Certification.js @@ -260,10 +260,13 @@ export class CertificationSettings extends Component { renderCertifications = certName => { const { t } = this.props; + const { certSlug } = first(projectMap[certName]); return ( -

{certName}

+

+ {certName} +

@@ -448,7 +451,9 @@ export class CertificationSettings extends Component { return ( -

{certName}

+

+ {certName} +

{ ); return ( -
+
{t('settings.headings.honesty')} diff --git a/client/src/components/settings/Privacy.js b/client/src/components/settings/Privacy.js index b0f1d745c2..0e34243975 100644 --- a/client/src/components/settings/Privacy.js +++ b/client/src/components/settings/Privacy.js @@ -66,7 +66,7 @@ class PrivacySettings extends Component { } = user.profileUI; return ( -
+
{t('settings.headings.privacy')}

{t('settings.privacy')}

diff --git a/client/src/components/settings/__snapshots__/Honesty.test.js.snap b/client/src/components/settings/__snapshots__/Honesty.test.js.snap index c88fda569d..9e6d5accbd 100644 --- a/client/src/components/settings/__snapshots__/Honesty.test.js.snap +++ b/client/src/components/settings/__snapshots__/Honesty.test.js.snap @@ -3,6 +3,7 @@ exports[` snapshot when isHonest is false: Honesty 1`] = `
settings.headings.honesty @@ -31,6 +32,7 @@ exports[` snapshot when isHonest is false: Honesty 1`] = exports[` snapshot when isHonest is true: HonestyAccepted 1`] = `
settings.headings.honesty diff --git a/client/src/templates/Introduction/SuperBlockIntro.js b/client/src/templates/Introduction/SuperBlockIntro.js index 4d0d104c01..147b0373ee 100644 --- a/client/src/templates/Introduction/SuperBlockIntro.js +++ b/client/src/templates/Introduction/SuperBlockIntro.js @@ -180,6 +180,7 @@ class SuperBlockIntroductionPage extends Component { {superBlock !== 'coding-interview-prep' && (
{ export class CertChallenge extends Component { render() { const { + isSignedIn, superBlock, t, title, @@ -54,9 +57,17 @@ export class CertChallenge extends Component { const i18nCertText = t(`intro:misc-text.certification`, { cert: i18nSuperBlock }); + const { certSlug } = cert; return (
+ {isSignedIn && !isCertified && ( + + )} + {isExpanded && ( + + )} +
+ + ); +}; + +CertificationCard.displayName = 'CertStatus'; +CertificationCard.propTypes = propTypes; + +export default CertificationCard; diff --git a/client/src/templates/Introduction/components/ClaimCertSteps.js b/client/src/templates/Introduction/components/ClaimCertSteps.js new file mode 100644 index 0000000000..c7f102b0d8 --- /dev/null +++ b/client/src/templates/Introduction/components/ClaimCertSteps.js @@ -0,0 +1,99 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { Link } from 'gatsby'; +import { withTranslation, useTranslation } from 'react-i18next'; +import { connect } from 'react-redux'; +import { createSelector } from 'reselect'; + +import GreenPass from '../../../assets/icons/GreenPass'; +import GreenNotCompleted from '../../../assets/icons/GreenNotCompleted'; +import { userSelector } from '../../../redux'; +import { User } from '../../../redux/propTypes'; + +const mapIconStyle = { height: '15px', marginRight: '10px', width: '15px' }; +const renderCheckMark = isCompleted => { + return isCompleted ? ( + + ) : ( + + ); +}; + +const propTypes = { + certSlug: PropTypes.string, + i18nCertText: PropTypes.string, + superBlock: PropTypes.string, + user: User +}; + +const mapStateToProps = state => { + return createSelector(userSelector, user => ({ + user + }))(state); +}; + +const ClaimCertSteps = ({ certSlug, i18nCertText, superBlock, user }) => { + const { t } = useTranslation(); + + const settingsLink = '/settings#privacy-settings'; + const certClaimLink = `/settings#cert-${certSlug}`; + const honestyPolicyAnchor = '/settings#honesty-policy'; + + const { + name, + isHonest, + profileUI: { isLocked, showCerts, showName } + } = user; + + return ( +
    +
  • + + {t('certification-card.accept-honesty')} + + {renderCheckMark(isHonest)} + + +
  • +
  • + + {t('certification-card.set-profile-public')} + + {renderCheckMark(!isLocked)} + + +
  • +
  • + + {t('certification-card.set-certs-public')} + + {renderCheckMark(showCerts)} + + +
  • +
  • + + {t('certification-card.set-name')} + + {renderCheckMark(name && name !== '' && showName)} + + +
  • +
  • + + {t('certification-card.complete-project', { + i18nCertText + })} + +
  • +
  • + {t('certification-card.set-claim')} +
  • +
+ ); +}; + +ClaimCertSteps.displayName = 'ClaimCertSteps'; +ClaimCertSteps.propTypes = propTypes; + +export default connect(mapStateToProps)(withTranslation()(ClaimCertSteps));