Skip to content

Commit

Permalink
Adapted user input to reset after submit
Browse files Browse the repository at this point in the history
  • Loading branch information
Bianca Wentzel committed Oct 7, 2024
1 parent d3f8a90 commit 028c28a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions assets/js/Containers/FrevaGPT/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class FrevaGPT extends React.Component {

this.state = {
loading: false,
userInput: {},
userInput: "",
};
}

Expand Down Expand Up @@ -76,7 +76,7 @@ class FrevaGPT extends React.Component {
}

handleUserInput(e) {
this.setState({ userInput: {variant: "User", content: e.target.value }});
this.setState({ userInput: e.target.value });
}

async handleKeyDown(e) {
Expand All @@ -86,8 +86,8 @@ class FrevaGPT extends React.Component {
}

async handleSubmit() {
this.props.dispatch(addElement(this.state.userInput));
this.setState({ userInput: {} });
this.props.dispatch(addElement({ variant: "User", content: this.state.userInput}));
this.setState({ userInput: "" });

this.setState({ loading: true });
try {
Expand All @@ -101,7 +101,7 @@ class FrevaGPT extends React.Component {
async fetchData() {

const queryObject = {
input: this.state.userInput.content,
input: this.state.userInput,
auth_key: process.env.BOT_AUTH_KEY,
thread_id: this.props.frevaGPT.thread,
freva_config: "/work/ch1187/clint/freva-dev/freva/evaluation_system.conf",
Expand Down Expand Up @@ -284,7 +284,7 @@ class FrevaGPT extends React.Component {
<Row>
<Col md={10}>
<InputGroup className="mb-2 pb-2">
<FormControl type="text" onChange={this.handleUserInput} onKeyDown={this.handleKeyDown} placeholder="Ask a question"/>
<FormControl type="text" value={this.state.userInput} onChange={this.handleUserInput} onKeyDown={this.handleKeyDown} placeholder="Ask a question"/>
{this.state.loading
? (<Button variant="outline-danger" onClick={this.handleStop}><i className="bi bi-stop-fill"></i></Button>)
: (<Button variant="outline-success" onClick={this.handleSubmit}><i className="bi bi-play-fill"></i></Button>)
Expand Down

0 comments on commit 028c28a

Please sign in to comment.