chore: remove Types suffixes from client/src/redux/prop-types.ts (#44010)

* chore: remove Type suffixes from client/src/redux/prop-types.ts.

* chore: add  PropType suffixes to PropTypes in client/src/redux/prop-types.ts.
This commit is contained in:
Vishwasa Navada K
2021-11-09 19:51:46 +05:30
committed by GitHub
parent 4c88fcdc69
commit 5ffd65e4e7
17 changed files with 113 additions and 229 deletions

View File

@ -25,7 +25,7 @@ import {
userByNameSelector, userByNameSelector,
fetchProfileForUser fetchProfileForUser
} from '../redux'; } from '../redux';
import { UserType } from '../redux/prop-types'; import { User } from '../redux/prop-types';
import { certMap } from '../resources/cert-and-project-map'; import { certMap } from '../resources/cert-and-project-map';
import certificateMissingMessage from '../utils/certificate-missing-message'; import certificateMissingMessage from '../utils/certificate-missing-message';
import reallyWeirdErrorMessage from '../utils/really-weird-error-message'; import reallyWeirdErrorMessage from '../utils/really-weird-error-message';
@ -69,7 +69,7 @@ interface IShowCertificationProps {
certSlug: string; certSlug: string;
}) => void; }) => void;
signedInUserName: string; signedInUserName: string;
user: UserType; user: User;
userFetchState: { userFetchState: {
complete: boolean; complete: boolean;
}; };
@ -78,7 +78,7 @@ interface IShowCertificationProps {
} }
const requestedUserSelector = (state: unknown, { username = '' }) => const requestedUserSelector = (state: unknown, { username = '' }) =>
userByNameSelector(username.toLowerCase())(state) as UserType; userByNameSelector(username.toLowerCase())(state) as User;
const validCertSlugs = certMap.map(cert => cert.certSlug); const validCertSlugs = certMap.map(cert => cert.certSlug);

View File

@ -12,7 +12,7 @@ import {
fetchProfileForUser, fetchProfileForUser,
usernameSelector usernameSelector
} from '../redux'; } from '../redux';
import { UserType } from '../redux/prop-types'; import { User } from '../redux/prop-types';
interface IShowProfileOrFourOhFourProps { interface IShowProfileOrFourOhFourProps {
fetchProfileForUser: (username: string) => void; fetchProfileForUser: (username: string) => void;
@ -23,14 +23,14 @@ interface IShowProfileOrFourOhFourProps {
}; };
isSessionUser: boolean; isSessionUser: boolean;
maybeUser: string; maybeUser: string;
requestedUser: UserType; requestedUser: User;
showLoading: boolean; showLoading: boolean;
} }
const createRequestedUserSelector = const createRequestedUserSelector =
() => () =>
(state: unknown, { maybeUser = '' }) => (state: unknown, { maybeUser = '' }) =>
userByNameSelector(maybeUser.toLowerCase())(state) as UserType; userByNameSelector(maybeUser.toLowerCase())(state) as User;
const createIsSessionUserSelector = const createIsSessionUserSelector =
() => () =>
(state: unknown, { maybeUser = '' }) => (state: unknown, { maybeUser = '' }) =>

View File

@ -4,11 +4,7 @@ import '../components/layouts/project-links.css';
import { Trans, useTranslation } from 'react-i18next'; import { Trans, useTranslation } from 'react-i18next';
import ProjectModal from '../components/SolutionViewer/ProjectModal'; import ProjectModal from '../components/SolutionViewer/ProjectModal';
import { Spacer, Link } from '../components/helpers'; import { Spacer, Link } from '../components/helpers';
import { import { ChallengeFiles, CompletedChallenge, User } from '../redux/prop-types';
ChallengeFiles,
CompletedChallenge,
UserType
} from '../redux/prop-types';
import { import {
projectMap, projectMap,
legacyProjectMap legacyProjectMap
@ -19,7 +15,7 @@ import { maybeUrlRE } from '../utils';
interface IShowProjectLinksProps { interface IShowProjectLinksProps {
certName: string; certName: string;
name: string; name: string;
user: UserType; user: User;
} }
type SolutionStateType = { type SolutionStateType = {

View File

@ -22,7 +22,7 @@ import {
isSignedInSelector, isSignedInSelector,
hardGoTo as navigate hardGoTo as navigate
} from '../redux'; } from '../redux';
import { UserType } from '../redux/prop-types'; import { User } from '../redux/prop-types';
import { submitNewAbout, updateUserFlag, verifyCert } from '../redux/settings'; import { submitNewAbout, updateUserFlag, verifyCert } from '../redux/settings';
const { apiLocation } = envData; const { apiLocation } = envData;
@ -40,7 +40,7 @@ interface IShowSettingsProps {
updateIsHonest: () => void; updateIsHonest: () => void;
updatePortfolio: () => void; updatePortfolio: () => void;
updateQuincyEmail: (isSendQuincyEmail: boolean) => void; updateQuincyEmail: (isSendQuincyEmail: boolean) => void;
user: UserType; user: User;
verifyCert: () => void; verifyCert: () => void;
path?: string; path?: string;
} }
@ -49,7 +49,7 @@ const mapStateToProps = createSelector(
signInLoadingSelector, signInLoadingSelector,
userSelector, userSelector,
isSignedInSelector, isSignedInSelector,
(showLoading: boolean, user: UserType, isSignedIn) => ({ (showLoading: boolean, user: User, isSignedIn) => ({
showLoading, showLoading,
user, user,
isSignedIn isSignedIn

View File

@ -6,7 +6,7 @@ import envData from '../../../../config/env.json';
import { isAuditedCert } from '../../../../utils/is-audited'; import { isAuditedCert } from '../../../../utils/is-audited';
import { generateIconComponent, SuperBlock } from '../../assets/icons'; import { generateIconComponent, SuperBlock } from '../../assets/icons';
import LinkButton from '../../assets/icons/link-button'; import LinkButton from '../../assets/icons/link-button';
import { ChallengeNodeType } from '../../redux/prop-types'; import { ChallengeNode } from '../../redux/prop-types';
import { Link, Spacer } from '../helpers'; import { Link, Spacer } from '../helpers';
import './map.css'; import './map.css';
@ -20,7 +20,7 @@ interface MapProps {
interface MapData { interface MapData {
allChallengeNode: { allChallengeNode: {
nodes: ChallengeNodeType[]; nodes: ChallengeNode[];
}; };
} }
@ -39,7 +39,7 @@ const linkSpacingStyle = {
alignItems: 'center' alignItems: 'center'
}; };
function renderLandingMap(nodes: ChallengeNodeType[]) { function renderLandingMap(nodes: ChallengeNode[]) {
nodes = nodes.filter(node => node.superBlock !== 'coding-interview-prep'); nodes = nodes.filter(node => node.superBlock !== 'coding-interview-prep');
return ( return (
<ul data-test-label='certifications'> <ul data-test-label='certifications'>
@ -61,7 +61,7 @@ function renderLandingMap(nodes: ChallengeNodeType[]) {
); );
} }
function renderLearnMap(nodes: ChallengeNodeType[], currentSuperBlock = '') { function renderLearnMap(nodes: ChallengeNode[], currentSuperBlock = '') {
nodes = nodes.filter(node => node.superBlock !== currentSuperBlock); nodes = nodes.filter(node => node.superBlock !== currentSuperBlock);
return curriculumLocale === 'english' ? ( return curriculumLocale === 'english' ? (
<ul data-test-label='learn-curriculum-map'> <ul data-test-label='learn-curriculum-map'>

View File

@ -1,7 +1,7 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { HandlerProps } from 'react-reflex'; import { HandlerProps } from 'react-reflex';
export const FileType = PropTypes.shape({ export const FilePropType = PropTypes.shape({
key: PropTypes.string, key: PropTypes.string,
ext: PropTypes.string, ext: PropTypes.string,
name: PropTypes.string, name: PropTypes.string,
@ -10,7 +10,7 @@ export const FileType = PropTypes.shape({
tail: PropTypes.string tail: PropTypes.string
}); });
export const MarkdownRemark = PropTypes.shape({ export const MarkdownRemarkPropType = PropTypes.shape({
html: PropTypes.string, html: PropTypes.string,
frontmatter: PropTypes.shape({ frontmatter: PropTypes.shape({
title: PropTypes.string, title: PropTypes.string,
@ -19,60 +19,15 @@ export const MarkdownRemark = PropTypes.shape({
}) })
}); });
export const ChallengeNode = PropTypes.shape({ export const AllMarkdownRemarkPropType = PropTypes.shape({
block: PropTypes.string,
challengeOrder: PropTypes.number,
challengeType: PropTypes.number,
dashedName: PropTypes.string,
description: PropTypes.string,
challengeFiles: PropTypes.array,
fields: PropTypes.shape({
slug: PropTypes.string,
blockName: PropTypes.string
}),
forumTopicId: PropTypes.number,
guideUrl: PropTypes.string,
head: PropTypes.arrayOf(PropTypes.string),
helpCategory: PropTypes.string,
instructions: PropTypes.string,
isComingSoon: PropTypes.bool,
removeComments: PropTypes.bool,
isLocked: PropTypes.bool,
isPrivate: PropTypes.bool,
order: PropTypes.number,
required: PropTypes.arrayOf(
PropTypes.shape({
link: PropTypes.string,
raw: PropTypes.string,
src: PropTypes.string
})
),
superOrder: PropTypes.number,
superBlock: PropTypes.string,
tail: PropTypes.arrayOf(PropTypes.string),
time: PropTypes.string,
title: PropTypes.string,
translationPending: PropTypes.bool,
videoUrl: PropTypes.string
});
export const AllChallengeNode = PropTypes.shape({
edges: PropTypes.arrayOf( edges: PropTypes.arrayOf(
PropTypes.shape({ PropTypes.shape({
node: ChallengeNode node: MarkdownRemarkPropType
}) })
) )
}); });
export const AllMarkdownRemark = PropTypes.shape({ export const UserPropType = PropTypes.shape({
edges: PropTypes.arrayOf(
PropTypes.shape({
node: MarkdownRemark
})
)
});
export const User = PropTypes.shape({
about: PropTypes.string, about: PropTypes.string,
completedChallenges: PropTypes.arrayOf( completedChallenges: PropTypes.arrayOf(
PropTypes.shape({ PropTypes.shape({
@ -125,7 +80,7 @@ export const User = PropTypes.shape({
website: PropTypes.string website: PropTypes.string
}); });
export const CurrentCertsType = PropTypes.arrayOf( export const CurrentCertsPropType = PropTypes.arrayOf(
PropTypes.shape({ PropTypes.shape({
show: PropTypes.bool, show: PropTypes.bool,
title: PropTypes.string, title: PropTypes.string,
@ -133,8 +88,8 @@ export const CurrentCertsType = PropTypes.arrayOf(
}) })
); );
export const StepsType = PropTypes.shape({ export const StepsPropType = PropTypes.shape({
currentCerts: CurrentCertsType, currentCerts: CurrentCertsPropType,
isShowCerts: PropTypes.bool, isShowCerts: PropTypes.bool,
isShowName: PropTypes.bool, isShowName: PropTypes.bool,
isShowProfile: PropTypes.bool isShowProfile: PropTypes.bool
@ -142,13 +97,13 @@ export const StepsType = PropTypes.shape({
// TYPESCRIPT TYPES // TYPESCRIPT TYPES
export type CurrentCertType = { export type CurrentCert = {
show: boolean; show: boolean;
title: string; title: string;
certSlug: string; certSlug: string;
}; };
export type MarkdownRemarkType = { export type MarkdownRemark = {
fields: [{ component: string; nodeIdentity: string; slug: string }]; fields: [{ component: string; nodeIdentity: string; slug: string }];
fileAbsolutePath: string; fileAbsolutePath: string;
frontmatter: { frontmatter: {
@ -196,7 +151,7 @@ export interface VideoLocaleIds {
portuguese?: string; portuguese?: string;
} }
export type ChallengeNodeType = { export type ChallengeNode = {
block: string; block: string;
challengeOrder: number; challengeOrder: number;
challengeType: number; challengeType: number;
@ -211,15 +166,31 @@ export type ChallengeNodeType = {
id: string; id: string;
instructions: string; instructions: string;
isComingSoon: boolean; isComingSoon: boolean;
internal?: {
content: string;
contentDigest: string;
description: string;
fieldOwners: string[];
ignoreType: boolean | null;
mediaType: string;
owner: string;
type: string;
};
removeComments: boolean; removeComments: boolean;
isLocked: boolean; isLocked: boolean;
isPrivate: boolean; isPrivate: boolean;
order: number; order: number;
question: Question; question: Question;
required: Required[]; required: Required[];
solutions: {
[T in FileKey]: FileKeyChallenge;
};
sourceInstanceName: string;
superOrder: number; superOrder: number;
superBlock: string; superBlock: string;
tail: string[]; tail: string[];
template: string;
tests: Test[];
time: string; time: string;
title: string; title: string;
translationPending: boolean; translationPending: boolean;
@ -231,28 +202,28 @@ export type ChallengeNodeType = {
videoUrl: string; videoUrl: string;
}; };
export type AllChallengeNodeType = { export type AllChallengeNode = {
edges: [ edges: [
{ {
node: ChallengeNodeType; node: ChallengeNode;
} }
]; ];
}; };
export type AllMarkdownRemarkType = { export type AllMarkdownRemark = {
edges: [ edges: [
{ {
node: MarkdownRemarkType; node: MarkdownRemark;
} }
]; ];
}; };
export type ResizePropsType = { export type ResizeProps = {
onStopResize: (arg0: HandlerProps) => void; onStopResize: (arg0: HandlerProps) => void;
onResize: () => void; onResize: () => void;
}; };
export type DimensionsType = { export type Dimensions = {
height: number; height: number;
width: number; width: number;
}; };
@ -272,7 +243,7 @@ export type CertTest = {
title: string; title: string;
}; };
export type UserType = { export type User = {
about: string; about: string;
acceptedPrivacyTerms: boolean; acceptedPrivacyTerms: boolean;
completedChallenges: CompletedChallenge[]; completedChallenges: CompletedChallenge[];
@ -288,7 +259,7 @@ export type UserType = {
name: string; name: string;
picture: string; picture: string;
points: number; points: number;
portfolio: PortfolioType[]; portfolio: Portfolio[];
profileUI: { profileUI: {
isLocked: boolean; isLocked: boolean;
showCerts: boolean; showCerts: boolean;
@ -301,9 +272,9 @@ export type UserType = {
twitter: string; twitter: string;
username: string; username: string;
website: string; website: string;
} & isCertifiedTypes; } & isCertified;
export type isCertifiedTypes = { export type isCertified = {
is2018DataVisCert: boolean; is2018DataVisCert: boolean;
isApisMicroservicesCert: boolean; isApisMicroservicesCert: boolean;
isBackEndCert: boolean; isBackEndCert: boolean;
@ -331,10 +302,10 @@ export type CompletedChallenge = {
challengeFiles: ChallengeFiles; challengeFiles: ChallengeFiles;
}; };
export type ExtTypes = 'js' | 'html' | 'css' | 'jsx'; export type Ext = 'js' | 'html' | 'css' | 'jsx';
export type FileKeyTypes = 'indexjs' | 'indexhtml' | 'indexcss'; export type FileKey = 'indexjs' | 'indexhtml' | 'indexcss';
export type ChallengeMetaType = { export type ChallengeMeta = {
block: string; block: string;
id: string; id: string;
introPath: string; introPath: string;
@ -347,7 +318,7 @@ export type ChallengeMetaType = {
helpCategory: string; helpCategory: string;
}; };
export type PortfolioType = { export type Portfolio = {
id: string; id: string;
title?: string; title?: string;
url?: string; url?: string;
@ -355,88 +326,21 @@ export type PortfolioType = {
description?: string; description?: string;
}; };
export type FileKeyChallengeType = { export type FileKeyChallenge = {
contents: string; contents: string;
ext: ExtTypes; ext: Ext;
head: string; head: string;
id: string; id: string;
key: FileKeyTypes; key: FileKey;
name: string; name: string;
tail: string; tail: string;
}; };
// This looks redundant - same as ChallengeNodeType above?
// TODO: @moT01 Yes, it is an almost duplicate because @ojeytonwilliams
// does not allow us to add 'Type' at the end...
// The below is more accurate, because it was built based on graphql's
// interpretation of what we have. The props commented out are what we
// think are on the node, but actually do not exist.
export type ChallengeNode = {
block: string;
challengeFiles: ChallengeFiles;
challengeOrder: number;
challengeType: number;
dashedName: string;
description: string;
fields: {
slug: string;
blockName: string;
tests: Test[];
};
forumTopicId: number;
// guideUrl: string;
// head: string[];
helpCategory: string;
id: string;
instructions: string;
internal?: {
content: string;
contentDigest: string;
description: string;
fieldOwners: string[];
ignoreType: boolean | null;
mediaType: string;
owner: string;
type: string;
};
order: number;
question: {
answers: string[];
solution: number;
text: string;
} | null;
removeComments: boolean;
required: [
{
link: string;
raw: string;
src: string;
}
];
solutions: {
[T in FileKeyTypes]: FileKeyChallengeType;
};
sourceInstanceName: string;
superBlock: string;
superOrder: number;
template: string;
tests: Test[];
time: string;
title: string;
translationPending: boolean;
videoId?: string;
videoUrl?: string;
// isComingSoon: boolean;
// isLocked: boolean;
// isPrivate: boolean;
// tail: string[];
};
// Extra types built from challengeSchema // Extra types built from challengeSchema
export type ChallengeFile = { export type ChallengeFile = {
fileKey: string; fileKey: string;
ext: ExtTypes; ext: Ext;
name: string; name: string;
editableRegionBoundaries: number[]; editableRegionBoundaries: number[];
usesMultifileEditor: boolean; usesMultifileEditor: boolean;

View File

@ -6,7 +6,7 @@ import { sortChallengeFiles } from '../../../../../utils/sort-challengefiles';
import { import {
ChallengeFile, ChallengeFile,
ChallengeFiles, ChallengeFiles,
ResizePropsType ResizeProps
} from '../../../redux/prop-types'; } from '../../../redux/prop-types';
import EditorTabs from './EditorTabs'; import EditorTabs from './EditorTabs';
import ActionRow from './action-row'; import ActionRow from './action-row';
@ -30,7 +30,7 @@ interface DesktopLayoutProps {
testsPane: Pane; testsPane: Pane;
}; };
preview: ReactElement; preview: ReactElement;
resizeProps: ResizePropsType; resizeProps: ResizeProps;
superBlock: string; superBlock: string;
testOutput: ReactElement; testOutput: ReactElement;
} }

View File

@ -22,10 +22,10 @@ import { Loader } from '../../../components/helpers';
import { userSelector, isDonationModalOpenSelector } from '../../../redux'; import { userSelector, isDonationModalOpenSelector } from '../../../redux';
import { import {
ChallengeFiles, ChallengeFiles,
DimensionsType, Dimensions,
ExtTypes, Ext,
FileKeyTypes, FileKey,
ResizePropsType, ResizeProps,
Test Test
} from '../../../redux/prop-types'; } from '../../../redux/prop-types';
import { editorToneOptions } from '../../../utils/tone/editor-config'; import { editorToneOptions } from '../../../utils/tone/editor-config';
@ -55,11 +55,11 @@ interface EditorProps {
containerRef: RefObject<HTMLElement>; containerRef: RefObject<HTMLElement>;
contents: string; contents: string;
description: string; description: string;
dimensions: DimensionsType; dimensions: Dimensions;
editorRef: MutableRefObject<editor.IStandaloneCodeEditor>; editorRef: MutableRefObject<editor.IStandaloneCodeEditor>;
executeChallenge: (options?: { showCompletionModal: boolean }) => void; executeChallenge: (options?: { showCompletionModal: boolean }) => void;
ext: ExtTypes; ext: Ext;
fileKey: FileKeyTypes; fileKey: FileKey;
canFocusOnMountRef: MutableRefObject<boolean>; canFocusOnMountRef: MutableRefObject<boolean>;
initialEditorContent: string; initialEditorContent: string;
initialExt: string; initialExt: string;
@ -67,7 +67,7 @@ interface EditorProps {
initialTests: Test[]; initialTests: Test[];
isResetting: boolean; isResetting: boolean;
output: string[]; output: string[];
resizeProps: ResizePropsType; resizeProps: ResizeProps;
saveEditorContent: () => void; saveEditorContent: () => void;
setEditorFocusability: (isFocusable: boolean) => void; setEditorFocusability: (isFocusable: boolean) => void;
submitChallenge: () => void; submitChallenge: () => void;
@ -76,7 +76,7 @@ interface EditorProps {
theme: string; theme: string;
title: string; title: string;
updateFile: (object: { updateFile: (object: {
fileKey: FileKeyTypes; fileKey: FileKey;
editorValue: string; editorValue: string;
editableRegionBoundaries: number[] | null; editableRegionBoundaries: number[] | null;
}) => void; }) => void;

View File

@ -14,9 +14,9 @@ import LearnLayout from '../../../components/layouts/learn';
import { import {
ChallengeFile, ChallengeFile,
ChallengeFiles, ChallengeFiles,
ChallengeMetaType, ChallengeMeta,
ChallengeNodeType, ChallengeNode,
ResizePropsType, ResizeProps,
Test Test
} from '../../../redux/prop-types'; } from '../../../redux/prop-types';
import { isContained } from '../../../utils/is-contained'; import { isContained } from '../../../utils/is-contained';
@ -78,7 +78,7 @@ interface ShowClassicProps {
cancelTests: () => void; cancelTests: () => void;
challengeMounted: (arg0: string) => void; challengeMounted: (arg0: string) => void;
createFiles: (arg0: ChallengeFile[]) => void; createFiles: (arg0: ChallengeFile[]) => void;
data: { challengeNode: ChallengeNodeType }; data: { challengeNode: ChallengeNode };
executeChallenge: (options?: { showCompletionModal: boolean }) => void; executeChallenge: (options?: { showCompletionModal: boolean }) => void;
challengeFiles: ChallengeFiles; challengeFiles: ChallengeFiles;
initConsole: (arg0: string) => void; initConsole: (arg0: string) => void;
@ -86,11 +86,11 @@ interface ShowClassicProps {
isChallengeCompleted: boolean; isChallengeCompleted: boolean;
output: string[]; output: string[];
pageContext: { pageContext: {
challengeMeta: ChallengeMetaType; challengeMeta: ChallengeMeta;
}; };
t: TFunction; t: TFunction;
tests: Test[]; tests: Test[];
updateChallengeMeta: (arg0: ChallengeMetaType) => void; updateChallengeMeta: (arg0: ChallengeMeta) => void;
} }
interface ShowClassicState { interface ShowClassicState {
@ -122,7 +122,7 @@ class ShowClassic extends Component<ShowClassicProps, ShowClassicState> {
containerRef: React.RefObject<unknown>; containerRef: React.RefObject<unknown>;
editorRef: React.RefObject<unknown>; editorRef: React.RefObject<unknown>;
instructionsPanelRef: React.RefObject<HTMLDivElement>; instructionsPanelRef: React.RefObject<HTMLDivElement>;
resizeProps: ResizePropsType; resizeProps: ResizeProps;
constructor(props: ShowClassicProps) { constructor(props: ShowClassicProps) {
super(props); super(props);

View File

@ -10,10 +10,7 @@ import type { Dispatch } from 'redux';
// Local Utilities // Local Utilities
import LearnLayout from '../../../components/layouts/learn'; import LearnLayout from '../../../components/layouts/learn';
import { import { ChallengeNode, ChallengeMeta } from '../../../redux/prop-types';
ChallengeNodeType,
ChallengeMetaType
} from '../../../redux/prop-types';
import { updateChallengeMeta, challengeMounted } from '../redux'; import { updateChallengeMeta, challengeMounted } from '../redux';
// Redux // Redux
const mapStateToProps = () => ({}); const mapStateToProps = () => ({});
@ -28,11 +25,11 @@ const mapDispatchToProps = (dispatch: Dispatch) =>
// Types // Types
interface ShowCodeAllyProps { interface ShowCodeAllyProps {
data: { challengeNode: ChallengeNodeType }; data: { challengeNode: ChallengeNode };
pageContext: { pageContext: {
challengeMeta: ChallengeMetaType; challengeMeta: ChallengeMeta;
}; };
updateChallengeMeta: (arg0: ChallengeMetaType) => void; updateChallengeMeta: (arg0: ChallengeMeta) => void;
} }
// Component // Component

View File

@ -16,10 +16,7 @@ import {
executeGA, executeGA,
allowBlockDonationRequests allowBlockDonationRequests
} from '../../../redux'; } from '../../../redux';
import { import { AllChallengeNode, ChallengeFiles } from '../../../redux/prop-types';
AllChallengeNodeType,
ChallengeFiles
} from '../../../redux/prop-types';
import { import {
closeModal, closeModal,
@ -281,7 +278,7 @@ export class CompletionModalInner extends Component<
const useCurrentBlockIds = (blockName: string) => { const useCurrentBlockIds = (blockName: string) => {
const { const {
allChallengeNode: { edges } allChallengeNode: { edges }
}: { allChallengeNode: AllChallengeNodeType } = useStaticQuery(graphql` }: { allChallengeNode: AllChallengeNode } = useStaticQuery(graphql`
query getCurrentBlockNodes { query getCurrentBlockNodes {
allChallengeNode(sort: { fields: [superOrder, order, challengeOrder] }) { allChallengeNode(sort: { fields: [superOrder, order, challengeOrder] }) {
edges { edges {

View File

@ -14,8 +14,8 @@ import Spacer from '../../../../components/helpers/spacer';
import LearnLayout from '../../../../components/layouts/learn'; import LearnLayout from '../../../../components/layouts/learn';
import { isSignedInSelector } from '../../../../redux'; import { isSignedInSelector } from '../../../../redux';
import { import {
ChallengeMetaType, ChallengeMeta,
ChallengeNodeType, ChallengeNode,
Test Test
} from '../../../../redux/prop-types'; } from '../../../../redux/prop-types';
import ChallengeDescription from '../../components/Challenge-Description'; import ChallengeDescription from '../../components/Challenge-Description';
@ -73,7 +73,7 @@ const mapDispatchToActions = {
// Types // Types
interface BackEndProps { interface BackEndProps {
challengeMounted: (arg0: string) => void; challengeMounted: (arg0: string) => void;
data: { challengeNode: ChallengeNodeType }; data: { challengeNode: ChallengeNode };
description: string; description: string;
executeChallenge: (options: { showCompletionModal: boolean }) => void; executeChallenge: (options: { showCompletionModal: boolean }) => void;
forumTopicId: number; forumTopicId: number;
@ -84,12 +84,12 @@ interface BackEndProps {
isSignedIn: boolean; isSignedIn: boolean;
output: string[]; output: string[];
pageContext: { pageContext: {
challengeMeta: ChallengeMetaType; challengeMeta: ChallengeMeta;
}; };
t: TFunction; t: TFunction;
tests: Test[]; tests: Test[];
title: string; title: string;
updateChallengeMeta: (arg0: ChallengeMetaType) => void; updateChallengeMeta: (arg0: ChallengeMeta) => void;
updateSolutionFormValues: () => void; updateSolutionFormValues: () => void;
} }

View File

@ -12,10 +12,7 @@ import { createSelector } from 'reselect';
import Spacer from '../../../../components/helpers/spacer'; import Spacer from '../../../../components/helpers/spacer';
import LearnLayout from '../../../../components/layouts/learn'; import LearnLayout from '../../../../components/layouts/learn';
import { import { ChallengeNode, ChallengeMeta } from '../../../../redux/prop-types';
ChallengeNodeType,
ChallengeMetaType
} from '../../../../redux/prop-types';
import ChallengeDescription from '../../components/Challenge-Description'; import ChallengeDescription from '../../components/Challenge-Description';
import Hotkeys from '../../components/Hotkeys'; import Hotkeys from '../../components/Hotkeys';
import ChallengeTitle from '../../components/challenge-title'; import ChallengeTitle from '../../components/challenge-title';
@ -54,14 +51,14 @@ const mapDispatchToProps = (dispatch: Dispatch) =>
// Types // Types
interface ProjectProps { interface ProjectProps {
challengeMounted: (arg0: string) => void; challengeMounted: (arg0: string) => void;
data: { challengeNode: ChallengeNodeType }; data: { challengeNode: ChallengeNode };
isChallengeCompleted: boolean; isChallengeCompleted: boolean;
openCompletionModal: () => void; openCompletionModal: () => void;
pageContext: { pageContext: {
challengeMeta: ChallengeMetaType; challengeMeta: ChallengeMeta;
}; };
t: TFunction; t: TFunction;
updateChallengeMeta: (arg0: ChallengeMetaType) => void; updateChallengeMeta: (arg0: ChallengeMeta) => void;
updateSolutionFormValues: () => void; updateSolutionFormValues: () => void;
} }

View File

@ -14,10 +14,7 @@ import { createSelector } from 'reselect';
import Loader from '../../../components/helpers/loader'; import Loader from '../../../components/helpers/loader';
import Spacer from '../../../components/helpers/spacer'; import Spacer from '../../../components/helpers/spacer';
import LearnLayout from '../../../components/layouts/learn'; import LearnLayout from '../../../components/layouts/learn';
import { import { ChallengeNode, ChallengeMeta } from '../../../redux/prop-types';
ChallengeNodeType,
ChallengeMetaType
} from '../../../redux/prop-types';
import ChallengeDescription from '../components/Challenge-Description'; import ChallengeDescription from '../components/Challenge-Description';
import Hotkeys from '../components/Hotkeys'; import Hotkeys from '../components/Hotkeys';
import VideoPlayer from '../components/VideoPlayer'; import VideoPlayer from '../components/VideoPlayer';
@ -56,15 +53,15 @@ const mapDispatchToProps = (dispatch: Dispatch) =>
// Types // Types
interface ShowVideoProps { interface ShowVideoProps {
challengeMounted: (arg0: string) => void; challengeMounted: (arg0: string) => void;
data: { challengeNode: ChallengeNodeType }; data: { challengeNode: ChallengeNode };
description: string; description: string;
isChallengeCompleted: boolean; isChallengeCompleted: boolean;
openCompletionModal: () => void; openCompletionModal: () => void;
pageContext: { pageContext: {
challengeMeta: ChallengeMetaType; challengeMeta: ChallengeMeta;
}; };
t: TFunction; t: TFunction;
updateChallengeMeta: (arg0: ChallengeMetaType) => void; updateChallengeMeta: (arg0: ChallengeMeta) => void;
updateSolutionFormValues: () => void; updateSolutionFormValues: () => void;
} }

View File

@ -8,9 +8,9 @@ import ButtonSpacer from '../../components/helpers/button-spacer';
import FullWidthRow from '../../components/helpers/full-width-row'; import FullWidthRow from '../../components/helpers/full-width-row';
import LearnLayout from '../../components/layouts/learn'; import LearnLayout from '../../components/layouts/learn';
import { import {
MarkdownRemarkType, MarkdownRemark,
AllChallengeNodeType, AllChallengeNode,
ChallengeNodeType ChallengeNode
} from '../../redux/prop-types'; } from '../../redux/prop-types';
import './intro.css'; import './intro.css';
@ -18,7 +18,7 @@ import './intro.css';
function renderMenuItems({ function renderMenuItems({
edges = [] edges = []
}: { }: {
edges?: Array<{ node: ChallengeNodeType }>; edges?: Array<{ node: ChallengeNode }>;
}) { }) {
return edges return edges
.map(({ node }) => node) .map(({ node }) => node)
@ -33,8 +33,8 @@ function IntroductionPage({
data: { markdownRemark, allChallengeNode } data: { markdownRemark, allChallengeNode }
}: { }: {
data: { data: {
markdownRemark: MarkdownRemarkType; markdownRemark: MarkdownRemark;
allChallengeNode: AllChallengeNodeType; allChallengeNode: AllChallengeNode;
}; };
}): React.FunctionComponentElement<typeof LearnLayout> { }): React.FunctionComponentElement<typeof LearnLayout> {
const { t } = useTranslation(); const { t } = useTranslation();

View File

@ -22,11 +22,7 @@ import {
tryToShowDonationModal, tryToShowDonationModal,
userSelector userSelector
} from '../../redux'; } from '../../redux';
import { import { MarkdownRemark, AllChallengeNode, User } from '../../redux/prop-types';
MarkdownRemarkType,
AllChallengeNodeType,
UserType
} from '../../redux/prop-types';
import Block from './components/Block'; import Block from './components/Block';
import CertChallenge from './components/CertChallenge'; import CertChallenge from './components/CertChallenge';
import SuperBlockIntro from './components/SuperBlockIntro'; import SuperBlockIntro from './components/SuperBlockIntro';
@ -43,8 +39,8 @@ type FetchState = {
type SuperBlockProp = { type SuperBlockProp = {
currentChallengeId: string; currentChallengeId: string;
data: { data: {
markdownRemark: MarkdownRemarkType; markdownRemark: MarkdownRemark;
allChallengeNode: AllChallengeNodeType; allChallengeNode: AllChallengeNode;
}; };
expandedState: { expandedState: {
[key: string]: boolean; [key: string]: boolean;
@ -57,7 +53,7 @@ type SuperBlockProp = {
t: TFunction; t: TFunction;
toggleBlock: (arg0: string) => void; toggleBlock: (arg0: string) => void;
tryToShowDonationModal: () => void; tryToShowDonationModal: () => void;
user: UserType; user: User;
}; };
configureAnchors({ offset: -40, scrollDuration: 0 }); configureAnchors({ offset: -40, scrollDuration: 0 });
@ -74,7 +70,7 @@ const mapStateToProps = (state: unknown) => {
isSignedIn, isSignedIn,
signInLoading: boolean, signInLoading: boolean,
fetchState: FetchState, fetchState: FetchState,
user: UserType user: User
) => ({ ) => ({
currentChallengeId, currentChallengeId,
isSignedIn, isSignedIn,

View File

@ -4,7 +4,7 @@ import envData from '../../../config/env.json';
import type { import type {
ChallengeFile, ChallengeFile,
CompletedChallenge, CompletedChallenge,
UserType User
} from '../redux/prop-types'; } from '../redux/prop-types';
const { apiLocation } = envData; const { apiLocation } = envData;
@ -55,7 +55,7 @@ async function request<T>(
/** GET **/ /** GET **/
interface SessionUser { interface SessionUser {
user?: { [username: string]: UserType }; user?: { [username: string]: User };
sessionMeta: { activeDonations: number }; sessionMeta: { activeDonations: number };
} }
@ -71,12 +71,12 @@ type ApiUser = {
result?: string; result?: string;
}; };
type ApiUserType = Omit<UserType, 'completedChallenges'> & { type ApiUserType = Omit<User, 'completedChallenges'> & {
completedChallenges?: challengeFilesForFiles[]; completedChallenges?: challengeFilesForFiles[];
}; };
type UserResponseType = { type UserResponseType = {
user: { [username: string]: UserType } | Record<string, never>; user: { [username: string]: User } | Record<string, never>;
result: string | undefined; result: string | undefined;
}; };
@ -226,7 +226,7 @@ export function putUpdateMyUsername(username: string): Promise<void> {
} }
export function putUpdateMyProfileUI( export function putUpdateMyProfileUI(
profileUI: UserType['profileUI'] profileUI: User['profileUI']
): Promise<void> { ): Promise<void> {
return put('/update-my-profileui', { profileUI }); return put('/update-my-profileui', { profileUI });
} }