diff --git a/tools/challenge-editor/client/src/components/editor/editor.tsx b/tools/challenge-editor/client/src/components/editor/editor.tsx index e9d14c90f0a..87c26fcd7f4 100644 --- a/tools/challenge-editor/client/src/components/editor/editor.tsx +++ b/tools/challenge-editor/client/src/components/editor/editor.tsx @@ -13,7 +13,14 @@ import { ChallengeContent } from '../../../interfaces/challenge-content'; import SaveChallenge from '../buttons/save-challenge'; import './editor.css'; import { API_LOCATION } from '../../utils/handle-request'; -import { superBlockNameMap } from '../../utils/block-name-translator'; + +// only includes superblocks whose folder names don't match their dashed names? +export const superBlockNameMap: { [key: string]: string } = { + 'responsive-web-design-22': '2022/responsive-web-design', + 'javascript-algorithms-and-data-structures-22': + 'javascript-algorithms-and-data-structures-v8', + 'front-end-development': 'full-stack-developer' +}; const Editor = () => { const [error, setError] = useState(null); @@ -24,7 +31,12 @@ const Editor = () => { fileData: '' }); const [stepContent, setStepContent] = useState(''); - const { superblock, block, challenge } = useParams(); + const { superblock = '', block = '', challenge = '' } = useParams(); + + const superblockUrl = + superblock in superBlockNameMap + ? superBlockNameMap[superblock] + : superblock; useEffect(() => { fetchData(); @@ -33,9 +45,7 @@ const Editor = () => { const fetchData = () => { setLoading(true); - fetch( - `${API_LOCATION}/${superblock || ''}/${block || ''}/${challenge || ''}` - ) + fetch(`${API_LOCATION}/${superblock}/${block}/${challenge}`) .then(res => res.json() as Promise) .then( content => { @@ -65,7 +75,7 @@ const Editor = () => {

{items.name}

- {superblock || ''} / {block || ''} + {superblock} / {block} { }} />

- Return to Block + Return to Block