diff --git a/app/src/Model2.js b/app/src/Model2.js new file mode 100644 index 0000000..b7c3bef --- /dev/null +++ b/app/src/Model2.js @@ -0,0 +1,260 @@ +// Model2.js + +import { useState } from 'react'; + +function Model2() { + + const [values, setValues] = useState([""]); + const [response, setResponse] = useState([""]); + const [selectedOption1, setSelectedOption1] = useState([""]); + const [selectedOption2, setSelectedOption2] = useState([""]); + const [selectedOption3, setSelectedOption3] = useState([""]); + const [selectedOption4, setSelectedOption4] = useState([""]); + const [selectedOption5, setSelectedOption5] = useState([""]); + const [selectedOption6, setSelectedOption6] = useState([""]); + const [selectedOption7, setSelectedOption7] = useState([""]); + const [selectedOption8, setSelectedOption8] = useState([""]); + const [selectedOption9, setSelectedOption9] = useState([""]); + const [selectedOption10, setSelectedOption10] = useState([""]); + const [selectedOption11, setSelectedOption11] = useState([""]); + + const onValueChange1 = (index, event) => { + values[index] = event.target.value; + setSelectedOption1(event.target.value); + } + + const onValueChange2 = (index, event) => { + values[index] = event.target.value; + setSelectedOption2(event.target.value); + } + + const onValueChange3 = (index, event) => { + values[index] = event.target.value; + setSelectedOption3(event.target.value); + } + + const onValueChange4 = (index, event) => { + values[index] = event.target.value; + setSelectedOption4(event.target.value); + } + + const onValueChange5 = (index, event) => { + values[index] = event.target.value; + setSelectedOption5(event.target.value); + } + + const onValueChange6 = (index, event) => { + values[index] = event.target.value; + setSelectedOption6(event.target.value); + } + const onValueChange7 = (index, event) => { + values[index] = event.target.value; + setSelectedOption7(event.target.value); + } + + const onValueChange8 = (index, event) => { + values[index] = event.target.value; + setSelectedOption8(event.target.value); + } + + const onValueChange9 = (index, event) => { + values[index] = event.target.value; + setSelectedOption9(event.target.value); + } + + const onValueChange10 = (index, event) => { + values[index] = event.target.value; + setSelectedOption10(event.target.value); + } + + const onValueChange11 = (index, event) => { + values[index] = event.target.value; + setSelectedOption11(event.target.value); + } + + const handleSubmit = async(e) => { + e.preventDefault(); + setValues(values); + try { + const response = await fetch('https://fluence-backend.onrender.com/api/process_input_seasonal', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({input: values}), + }); + + // const response = await fetch('http://localhost:3001/api/process_input_seasonal', { + // method: 'POST', + // headers: { + // 'Content-Type': 'application/json', + // }, + // body: JSON.stringify({input: values}), + // }); + + const data = await response.json(); + // setResponse(data.prediction); + if (data.prediction[0] === 1){ + setResponse("Patient is highly likely to be vaccinated for Seasonal Flu"); + } + else if (data.prediction[0] === 0){ + setResponse("Patient is not likely to be vaccinated for Seasonal Flu"); + } + else { + setResponse("Some error occured"); + } + } + catch (error) { + console.error("Error: ", error); + } + } + + return ( +