Skip to content

Commit

Permalink
删除isLoading
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhixu-W committed Oct 29, 2023
1 parent ae34268 commit 16b7eb9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
25 changes: 10 additions & 15 deletions smarthub/src/containers/AIPractice.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import '../css/AIPractice.css'
import '../css/Styles.css';


class AIPractice extends Component {

Expand All @@ -15,7 +15,7 @@ class AIPractice extends Component {
MCQ: {questionTitle: "Thank you",questionDetail: "Let's begin"},
isArtSelected: false,
imageURL: '../assets/1.jpg',
isLoading: false,

};
}

Expand Down Expand Up @@ -68,14 +68,14 @@ class AIPractice extends Component {
'Authorization': sessionStorage.getItem("tokenStr")
},
});
this.setState({ isLoading: true });

const data = await response.json();
console.log( data);
this.setState({ AI: data.msg });
} catch (error) {
console.error(`Could not submit form. Error: ${error}`);
} finally {
this.setState({ isLoading: false });

}

}else if(this.state.selectedOption === 'grammar'){
Expand All @@ -87,14 +87,14 @@ class AIPractice extends Component {
'Authorization': sessionStorage.getItem("tokenStr")
},
});
this.setState({ isLoading: true });

const data = await response.json();
console.log( data);
this.setState({ AI: data.msg });
} catch (error) {
console.error(`Could not submit form. Error: ${error}`);
} finally {
this.setState({ isLoading: false });

}
}else if(this.state.selectedOption === 'art'){
try {
Expand All @@ -105,15 +105,15 @@ class AIPractice extends Component {
'Authorization': sessionStorage.getItem("tokenStr")
},
});
this.setState({ isLoading: true });

const data = await response.json();
console.log(data[0]);
this.setState({imageURL: data[0]})
// this.setState({ AI: data.msg });
} catch (error) {
console.error(`Could not submit form. Error: ${error}`);
} finally {
this.setState({ isLoading: false });

}
}else{
try {
Expand All @@ -124,14 +124,14 @@ class AIPractice extends Component {
'Authorization': sessionStorage.getItem("tokenStr")
},
});
this.setState({ isLoading: true });

const data = await response.json();
console.log(data.data);
this.setState({ MCQ: data.data });
} catch (error) {
console.error(`Could not submit form. Error: ${error}`);
} finally {
this.setState({ isLoading: false });

}
}
};
Expand Down Expand Up @@ -236,11 +236,6 @@ class AIPractice extends Component {
>Submit</div>

</div>
{this.state.isLoading && (
<div className="overlay">
<div className="loader"></div>
</div>
)}

</div>
);
Expand Down
12 changes: 6 additions & 6 deletions smarthub/src/css/Styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ color: #fff; /* 设置文字颜色 */
justify-content: center;
align-items: center;
z-index: 1000;
}
}

.loader {
.loader {
border: 16px solid #f3f3f3;
border-top: 16px solid #3498db;
border-radius: 50%;
width: 100px;
height: 100px;
animation: spin 2s linear infinite;
}
}

@keyframes spin {
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
}

body {
body {
font-family: Arial, sans-serif;
}

Expand Down

0 comments on commit 16b7eb9

Please sign in to comment.