I have a form where the user fills up a form for one employee with data like father’s name etc..
Now i have another form where the user can change these data incase of an error or sth.
I want to get the value of these variables sth like fathersname or mothersname etc.. and show their value in the proper input element. So the user can see the previous value and change it if needed.
So in conclusion i have the Employee component, another Component named Employees where i show all the employees in chart, in which i pass each employee with the help of usecontext hook, and then at last i have the DataChange component which i pass the employee obj through Employees as a variable (not through usecontext hook) and from there i am trying to get each one’s values
What i have tried is sth like this in the Employee Component :
function handleAddYpallilos() {
const NewYpallilos = {
Yname: name,
Yepitheto: epitheto,
Ycode: code,
Yfathername: fathername
};
setYpalliloi(prevYpalliloi => [...prevYpalliloi, NewYpallilos]);
}
<div className="mb-3">
<label htmlFor="formEmployeeFathername" className="form-label">Όνομα Πατέρα</label>
<input type="text" className="form-control" id="formEmployeeFathername" placeholder=""
value={fathername} onChange={handleFathernameChange} />
</div>
Employees “ignore the modals”
<DataChange
showModal2={showModal2}
setShowModal2={setShowModal2}
ypallilos={selectedYpallilos} // Πέρασμα του επιλεγμένου υπαλλήλου
/>
and lastly the DataChange component
const [name, setName] = useState(ypallilos.Yname);
<div className="mb-3">
<label htmlFor="formEmployeeFathername" className="form-label">Όνομα Πατέρα</label>
<input type="text" className="form-control" id="formEmployeeFathername" value={fathername} placeholder="" />
</div>


