@@ -7,21 +7,7 @@ import { prepareAllData, updAllItems } from "../../functions/updstate";
77
88function EditItemForm ( _props : any ) {
99
10- const item :Item = {
11- ID : _props . item . ID ,
12- Group : _props . item . Group ,
13- Name : _props . item . Name ,
14- Type : _props . item . Type ,
15- Link : _props . item . Link ,
16- Icon : _props . item . Icon ,
17- Exec : "" ,
18- State : "" ,
19- CPU : "" ,
20- Mem : "" ,
21- AnyCom : _props . item . AnyCom ,
22- } ;
23-
24- const [ formData , setFormData ] = useState < Item > ( item ) ;
10+ const [ formData , setFormData ] = useState < Item > ( _props . item ) ;
2511
2612 const handleChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
2713 const { name, value } = e . target ;
@@ -49,7 +35,7 @@ function EditItemForm(_props: any) {
4935 }
5036
5137 const saveChanges = async ( data : Item ) => {
52- await apiSaveItem ( item , data ) ;
38+ await apiSaveItem ( _props . item , data ) ;
5339 prepareAllData ( ) ;
5440 setTimeout ( ( ) => {
5541 updAllItems ( ) ;
@@ -58,11 +44,11 @@ function EditItemForm(_props: any) {
5844
5945 return (
6046 < >
61- < form >
47+ < form autoComplete = "on" onSubmit = { e => e . preventDefault ( ) } >
6248 < label htmlFor = "gid" className = "form-label text-primary" > Group</ label >
63- < input className = "form-control mb-3" defaultValue = { item . Group } id = "gid" name = "Group" onChange = { handleChange } placeholder = "Not empty string" > </ input >
49+ < input className = "form-control mb-3" defaultValue = { _props . item . Group } id = "gid" name = "Group" type = "text " onChange = { handleChange } placeholder = "Not empty string" > </ input >
6450 < label htmlFor = "nid" className = "form-label text-primary" > Name</ label >
65- < input className = "form-control mb-3" defaultValue = { item . Name } id = "nid" name = "Name" onChange = { handleChange } placeholder = "Not empty string" > </ input >
51+ < input className = "form-control mb-3" defaultValue = { _props . item . Name } id = "nid" name = "Name" type = "text " onChange = { handleChange } placeholder = "Not empty string" > </ input >
6652 < label htmlFor = "tid" className = "form-label text-primary" > Type</ label >
6753 < select className = "form-select mb-3" id = "tid" onChange = { handleSelectType } defaultValue = { formData . Type } >
6854 < option value = "" disabled > Select type</ option >
@@ -71,13 +57,13 @@ function EditItemForm(_props: any) {
7157 ) ) }
7258 </ select >
7359 < label htmlFor = "iid" className = "form-label text-primary" > Icon</ label >
74- < input className = "form-control mb-3" defaultValue = { item . Icon } id = "iid" name = "Icon" onChange = { handleChange } placeholder = "Link to Icon (optional)" > </ input >
60+ < input className = "form-control mb-3" defaultValue = { _props . item . Icon } id = "iid" name = "Icon" onChange = { handleChange } placeholder = "Link to Icon (optional)" > </ input >
7561 < label htmlFor = "lid" className = "form-label text-primary" > Link</ label >
76- < input className = "form-control mb-3" defaultValue = { item . Link } id = "lid" name = "Link" onChange = { handleChange } placeholder = "URL (optional)" > </ input >
62+ < input className = "form-control mb-3" defaultValue = { _props . item . Link } id = "lid" name = "Link" onChange = { handleChange } placeholder = "URL (optional)" > </ input >
7763 < hr > </ hr >
7864 < div className = 'd-flex justify-content-between' >
7965 < button className = "btn btn-danger" type = "button" onClick = { handleDel } > Delete</ button >
80- < button className = "btn btn-primary" type = "button " onClick = { handleSave } > Save</ button >
66+ < button className = "btn btn-outline- primary" type = "submit " onClick = { handleSave } > Save</ button >
8167 </ div >
8268 </ form >
8369 </ >
0 commit comments