Skip to content

Commit 053b2fa

Browse files
author
Zhou
committed
fix bugs
1 parent b04917d commit 053b2fa

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

src/pages/PageFour/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ class PageFour extends React.Component {
337337

338338
render() {
339339
// Get all sprites
340+
if(!vfg.visualStages) return null;
340341
var sprites = vfg.visualStages[this.state.stepInfoIndex].visualSprites;
341342
// Sort sprites by their depth
342343
sprites.sort((itemA, itemB) => itemA.depth - itemB.depth)
@@ -347,7 +348,7 @@ class PageFour extends React.Component {
347348
<div className={styles.sub_title}> Steps </div>
348349
<div className={styles.left_upper}>
349350
{
350-
steps.map((step, i) => {
351+
steps && steps.map((step, i) => {
351352
return <div className={styles.stage_item}
352353
style={{backgroundColor: i === this.state.stepInfoIndex ? '#eef': 'white'}}
353354
onClick={()=>{this.handleSwitchStage(i);}}

src/pages/PageOne/dropAndFetch.jsx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Container from "@material-ui/core/Container";
55
import CloudUploadIcon from "@material-ui/icons/CloudUpload";
66
import css from "./index.module.less";
77

8-
const dragsAndDrops=[
8+
const dragsAndDrops = [
99
{ name: "Domain", fileType: ".pddl", desc: "or predictes and actions." },
1010
{
1111
name: "Problem",
@@ -24,8 +24,6 @@ class DropAndFetch extends React.Component {
2424
this.datas = {};
2525
}
2626

27-
28-
2927
componentWillUnmount = () => {
3028
this.setState = (state, callback) => {
3129
return;
@@ -37,18 +35,22 @@ class DropAndFetch extends React.Component {
3735
for (const name in files) {
3836
formData.append(name, files[name]);
3937
}
40-
const resp = await fetch(
41-
"https://planimation.planning.domains/upload/pddl",
42-
{
43-
//"http://127.0.0.1:8000/upload/pddl" On local server
44-
method: "POST", //DO NOT use headers
45-
body: formData, // Dataformat
46-
}
47-
);
38+
try {
39+
const resp = await fetch(
40+
"https://planimation.planning.domains/upload/pddl",
41+
{
42+
//"http://127.0.0.1:8000/upload/pddl" On local server
43+
method: "POST", //DO NOT use headers
44+
body: formData, // Dataformat
45+
}
46+
);
4847

49-
const data = await resp.json();
50-
const txt = JSON.stringify(data);
51-
this.props.onStore(txt);
48+
const data = await resp.json();
49+
const txt = JSON.stringify(data);
50+
this.props.onStore(txt);
51+
} catch (error) {
52+
alert(error);
53+
}
5254
};
5355

5456
handleSubmit = () => {

src/pages/PageOne/dropZone.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class DropZone extends React.Component {
3232
this.state.files.length > 0
3333
? this.state.files[0].name
3434
: "Drag and drop " +
35-
this.props.name.toLowerCase() +
36-
this.props.fileType +
35+
this.props?.name?.toLowerCase() +
36+
this.props?.fileType?? '--' +
3737
" here or click";
3838

3939
return (

src/pages/PageOne/dropZone.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import DropZone from './dropZone';
55

66
it("Renders Correctly ", () => {
77
const div = document.createElement("div");
8-
ReactDOM.render(<DragAndDrop
8+
ReactDOM.render(<DropZone
99
/>, div);
1010
ReactDOM.unmountComponentAtNode(div);
1111
});

0 commit comments

Comments
 (0)