mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-14 04:00:42 -04:00
feat(tools): remove assertion in params inside challenge editor (#49931)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<ChallengeContent>)
|
||||
.then(
|
||||
content => {
|
||||
@@ -70,7 +64,7 @@ const Editor = () => {
|
||||
<div>
|
||||
<h1>{items.name}</h1>
|
||||
<span className='breadcrumb'>
|
||||
{params.superblock} / {params.block}
|
||||
{superblock} / {block}
|
||||
</span>
|
||||
<CodeMirror
|
||||
value={input}
|
||||
@@ -86,15 +80,13 @@ const Editor = () => {
|
||||
}}
|
||||
/>
|
||||
<SaveChallenge
|
||||
superblock={params.superblock}
|
||||
block={params.block}
|
||||
challenge={params.challenge}
|
||||
superblock={superblock}
|
||||
block={block}
|
||||
challenge={challenge}
|
||||
content={input}
|
||||
/>
|
||||
<p>
|
||||
<Link to={`/${params.superblock}/${params.block}`}>
|
||||
Return to Block
|
||||
</Link>
|
||||
<Link to={`/${superblock}/${block}`}>Return to Block</Link>
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user