I experimenting with passing information from a Form to the Ledger
My Form data looks like this
…
import React from “react”;
class Covid19Form extends React.Component {
constructor(props) {
super(props);
this.state = {
issuedby: healthclinic,
testnumber: 1
// these are some default values //
}
this.handleInputChange = this.handleInputChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}handleSubmit(event) { // Function to submit to the Ledger in React.js // NEED HELP HERE // } handleInputChange(event) { const target = event.target; const value = target.value; const name = target.name; this.setState({ [name]: value }); } render() { return ( <form onSubmit={this.handleSubmit}> <label> Test Date: <input margin="dense" name="testdate" type="date" value={this.state.testdate} onChange={this.handleInputChange} /> </label> <label> // More Input Fields Here // </label> <input type="submit" value="Submit" /> </form> ); }
};
export default Covid19Form;
…
I am seeking some help to correctly deal with the handleSubmit Function (see above in code) to correctly submit all the Input fields from a Form to the the Ledger and create and exercise a contract (choice) in react.js
The DAML Cheatsheet mentions ( in JSX)
…
const ledger = useLedger();
const [choiceReturnValue, events] = await ledger.exercise(ContractChoice, contractId, choiceArguments)`
…
Questions:
- How do I get the current contractID value assigned when exercising a choice on an existing contract ?
- how do I pas the “this.state.X” values as choiceArguments ?
- How do I generate a pop-up message for successful submission ?