when i submit the form it wont go to the next route and I'm not sure about if this the right way to call loadUser function that I wrote on the app.js file and I call it here
function OrderCP(props) {
const [firstName, setFirstName] = useState('');
const [lastName, setLastName] = useState('');
const [email, setEmail] = useState('');
const [mobileNumber, setMobileNumber] = useState('');
const [adress, setAddress] = useState('');
const [city, setCity] = useState('');
const [size, setSize] = useState('');
const [quantity, setQuantity] = useState('1');
function onOrderSubmit () {
fetch('http://localhost:3000/orderCP', {
method: 'post',
mode: 'cors',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
firstname: firstName,
lastname:lastName,
email: email,
mobilenumber: mobileNumber,
adress: adress,
city: city,
size:size,
quantity: quantity
})
})
.then(response => response.json())
.then(user => {
if (user.id) {
return (
this.props.loadUser(user),
<Link to ='/orderCP/orderCompletedCP' /> )
}
})
}
