feat(curriculum): download solution as non-json text file (#37681)
* feat: download solution as non-json text file * fix: added missing end of line character Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@ -87,14 +87,14 @@ export class CompletionModal extends Component {
|
|||||||
if (Object.keys(files).length) {
|
if (Object.keys(files).length) {
|
||||||
const filesForDownload = Object.keys(files)
|
const filesForDownload = Object.keys(files)
|
||||||
.map(key => files[key])
|
.map(key => files[key])
|
||||||
.reduce(
|
.reduce((allFiles, { path, contents }) => {
|
||||||
(allFiles, { path, contents }) => ({
|
const beforeText = `** start of ${path} **\n\n`;
|
||||||
...allFiles,
|
const afterText = `\n\n** end of ${path} **\n\n`;
|
||||||
[path]: contents
|
allFiles +=
|
||||||
}),
|
files.length > 1 ? beforeText + contents + afterText : contents;
|
||||||
{}
|
return allFiles;
|
||||||
);
|
}, '');
|
||||||
const blob = new Blob([JSON.stringify(filesForDownload, null, 2)], {
|
const blob = new Blob([filesForDownload], {
|
||||||
type: 'text/json'
|
type: 'text/json'
|
||||||
});
|
});
|
||||||
newURL = URL.createObjectURL(blob);
|
newURL = URL.createObjectURL(blob);
|
||||||
@ -170,7 +170,7 @@ export class CompletionModal extends Component {
|
|||||||
bsSize='lg'
|
bsSize='lg'
|
||||||
bsStyle='primary'
|
bsStyle='primary'
|
||||||
className='btn-invert'
|
className='btn-invert'
|
||||||
download={`${dashedName}.json`}
|
download={`${dashedName}.txt`}
|
||||||
href={this.state.downloadURL}
|
href={this.state.downloadURL}
|
||||||
>
|
>
|
||||||
Download my solution
|
Download my solution
|
||||||
|
Reference in New Issue
Block a user