From 6b52d6c331f1c026dae595a5b452f5aaeaeec868 Mon Sep 17 00:00:00 2001 From: Parth Parth <34807532+thecodingaviator@users.noreply.github.com> Date: Tue, 29 Jun 2021 15:51:49 +0530 Subject: [PATCH] feat(client): ts-migrate client/src/resources/certAndProjectMap.js (#42648) Co-authored-by: Parth Parth --- client/src/client-only-routes/show-certification.tsx | 2 +- client/src/client-only-routes/show-project-links.tsx | 5 ++++- client/src/components/settings/Certification.js | 2 +- .../{certAndProjectMap.js => cert-and-project-map.ts} | 10 ++++++---- .../templates/Introduction/components/CertChallenge.js | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) rename client/src/resources/{certAndProjectMap.js => cert-and-project-map.ts} (98%) diff --git a/client/src/client-only-routes/show-certification.tsx b/client/src/client-only-routes/show-certification.tsx index 6b0710f6f0b..7f3e2d8edf3 100644 --- a/client/src/client-only-routes/show-certification.tsx +++ b/client/src/client-only-routes/show-certification.tsx @@ -20,7 +20,7 @@ import { userByNameSelector, fetchProfileForUser } from '../redux'; -import { certMap } from '../resources/certAndProjectMap'; +import { certMap } from '../resources/cert-and-project-map'; import { createFlashMessage } from '../components/Flash/redux'; import standardErrorMessage from '../utils/standardErrorMessage'; import reallyWeirdErrorMessage from '../utils/reallyWeirdErrorMessage'; diff --git a/client/src/client-only-routes/show-project-links.tsx b/client/src/client-only-routes/show-project-links.tsx index 23ba7aec098..7d25a1ef6b3 100644 --- a/client/src/client-only-routes/show-project-links.tsx +++ b/client/src/client-only-routes/show-project-links.tsx @@ -2,7 +2,10 @@ import React, { useState } from 'react'; import '../components/layouts/project-links.css'; import { maybeUrlRE } from '../utils'; import { Spacer, Link } from '../components/helpers'; -import { projectMap, legacyProjectMap } from '../resources/certAndProjectMap'; +import { + projectMap, + legacyProjectMap +} from '../resources/cert-and-project-map'; import ProjectModal from '../components/SolutionViewer/ProjectModal'; import { find, first } from 'lodash-es'; import { Trans, useTranslation } from 'react-i18next'; diff --git a/client/src/components/settings/Certification.js b/client/src/components/settings/Certification.js index b6ee84c6b7b..a40ac252f34 100644 --- a/client/src/components/settings/Certification.js +++ b/client/src/components/settings/Certification.js @@ -14,7 +14,7 @@ import { withTranslation } from 'react-i18next'; import { projectMap, legacyProjectMap -} from '../../resources/certAndProjectMap'; +} from '../../resources/cert-and-project-map'; import SectionHeader from './section-header'; import ProjectModal from '../SolutionViewer/ProjectModal'; diff --git a/client/src/resources/certAndProjectMap.js b/client/src/resources/cert-and-project-map.ts similarity index 98% rename from client/src/resources/certAndProjectMap.js rename to client/src/resources/cert-and-project-map.ts index 882a810c971..2c8e560493b 100644 --- a/client/src/resources/certAndProjectMap.js +++ b/client/src/resources/cert-and-project-map.ts @@ -440,7 +440,7 @@ const certMap = [ { id: '606243f50267e718b1e755f4', title: 'Relational Databases', - slug: 'relational-databases', + certSlug: 'relational-databases', flag: 'isRelationalDatabasesCert', projects: [ { @@ -704,10 +704,12 @@ const certMap = [ } ] } -]; +] as const; -const legacyProjectMap = {}; -const projectMap = {}; +const titles = certMap.map(({ title }) => title); +type Title = typeof titles[number]; +const legacyProjectMap: Partial> = {}; +const projectMap: Partial> = {}; certMap.forEach(cert => { // Filter out Legacy Full Stack so inputs for project diff --git a/client/src/templates/Introduction/components/CertChallenge.js b/client/src/templates/Introduction/components/CertChallenge.js index c42485f1177..95a6b56068e 100644 --- a/client/src/templates/Introduction/components/CertChallenge.js +++ b/client/src/templates/Introduction/components/CertChallenge.js @@ -10,7 +10,7 @@ import GreenPass from '../../../assets/icons/green-pass'; import GreenNotCompleted from '../../../assets/icons/green-not-completed'; import { certificatesByNameSelector } from '../../../redux'; import { CurrentCertsType, User } from '../../../redux/prop-types'; -import { certMap } from '../../../resources/certAndProjectMap'; +import { certMap } from '../../../resources/cert-and-project-map'; import { certSlugTypeMap, superBlockCertTypeMap