From 6e89d3b2dd2cfbe8e42fe778f3044eaea1e019d5 Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Mon, 3 Apr 2023 20:38:22 +0200 Subject: [PATCH] feat(tools): remove assertion in params inside challenge editor (#49931) --- .../client/interfaces/prop-types.ts | 22 ++++++------------- .../client/src/components/editor/editor.tsx | 22 ++++++------------- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/tools/challenge-editor/client/interfaces/prop-types.ts b/tools/challenge-editor/client/interfaces/prop-types.ts index f0a32a441af..2bb76daf4be 100644 --- a/tools/challenge-editor/client/interfaces/prop-types.ts +++ b/tools/challenge-editor/client/interfaces/prop-types.ts @@ -1,17 +1,9 @@ -export interface ChallengeContentRequiredProps { - superblock: string; - block: string; - challenge: string; +export interface BlockRequiredProps { + superblock?: string; + block?: string; +} + +export interface ChallengeContentRequiredProps extends BlockRequiredProps { + challenge?: string; content: string; } - -export interface ChallengeRequiredProps { - superblock: string; - block: string; - challenge: string; -} - -export interface BlockRequiredProps { - superblock: string; - block: string; -} diff --git a/tools/challenge-editor/client/src/components/editor/editor.tsx b/tools/challenge-editor/client/src/components/editor/editor.tsx index d61ec254f26..57a6a5f8485 100644 --- a/tools/challenge-editor/client/src/components/editor/editor.tsx +++ b/tools/challenge-editor/client/src/components/editor/editor.tsx @@ -22,11 +22,7 @@ const Editor = () => { fileData: '' }); const [input, setInput] = useState(''); - const params = useParams() as { - superblock: string; - block: string; - challenge: string; - }; + const { superblock, block, challenge } = useParams(); useEffect(() => { fetchData(); @@ -35,9 +31,7 @@ const Editor = () => { const fetchData = () => { setLoading(true); - fetch( - `${API_LOCATION}/${params.superblock}/${params.block}/${params.challenge}` - ) + fetch(`${API_LOCATION}/${superblock}/${block}/${challenge}`) .then(res => res.json() as Promise) .then( content => { @@ -70,7 +64,7 @@ const Editor = () => {

{items.name}

- {params.superblock} / {params.block} + {superblock} / {block} { }} />

- - Return to Block - + Return to Block

);