feat: reduce request payload for non-js projects (#44429)
* feat: reduce request payload for non-js projects * break future TS Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@ -62,16 +62,19 @@ function submitModern(type, state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type === actionTypes.submitChallenge) {
|
if (type === actionTypes.submitChallenge) {
|
||||||
const { id } = challengeMetaSelector(state);
|
const { id, block } = challengeMetaSelector(state);
|
||||||
const challengeFiles = challengeFilesSelector(state);
|
const challengeFiles = challengeFilesSelector(state);
|
||||||
const { username } = userSelector(state);
|
const { username } = userSelector(state);
|
||||||
const challengeInfo = {
|
const challengeInfo = {
|
||||||
id,
|
id
|
||||||
files: challengeFiles.reduce(
|
};
|
||||||
|
// Only send files to server, if it is a JS project
|
||||||
|
if (block === 'javascript-algorithms-and-data-structures-projects') {
|
||||||
|
challengeInfo.files = challengeFiles.reduce(
|
||||||
(acc, { fileKey, ...curr }) => [...acc, { ...curr, key: fileKey }],
|
(acc, { fileKey, ...curr }) => [...acc, { ...curr, key: fileKey }],
|
||||||
[]
|
[]
|
||||||
)
|
);
|
||||||
};
|
}
|
||||||
const update = {
|
const update = {
|
||||||
endpoint: '/modern-challenge-completed',
|
endpoint: '/modern-challenge-completed',
|
||||||
payload: challengeInfo
|
payload: challengeInfo
|
||||||
|
Reference in New Issue
Block a user