diff options
author | Anton Tananaev <anton@traccar.org> | 2022-05-02 17:13:33 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-05-02 17:13:33 -0700 |
commit | f52be84522da7f8e1c2b19d3484250e275252799 (patch) | |
tree | f13316af299e5f1665cbb0e9d73a5f9ffc04d961 /modern/src/UserPage.js | |
parent | 3a8a11c5d101c30cabf727f6a27a892e9bc4c99a (diff) | |
download | trackermap-web-f52be84522da7f8e1c2b19d3484250e275252799.tar.gz trackermap-web-f52be84522da7f8e1c2b19d3484250e275252799.tar.bz2 trackermap-web-f52be84522da7f8e1c2b19d3484250e275252799.zip |
Implement model validation
Diffstat (limited to 'modern/src/UserPage.js')
-rw-r--r-- | modern/src/UserPage.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/modern/src/UserPage.js b/modern/src/UserPage.js index 895dac43..ce1e082f 100644 --- a/modern/src/UserPage.js +++ b/modern/src/UserPage.js @@ -25,10 +25,11 @@ const UserPage = () => { const [item, setItem] = useState(); + const validate = () => item && item.name && item.email && (item.id || item.password); + return ( - <EditItemView endpoint="users" item={item} setItem={setItem}> - {item - && ( + <EditItemView endpoint="users" item={item} setItem={setItem} validate={validate}> + {item && ( <> <Accordion defaultExpanded> <AccordionSummary expandIcon={<ExpandMoreIcon />}> @@ -97,8 +98,7 @@ const UserPage = () => { /> </AccordionDetails> </Accordion> - {item.id - && ( + {item.id && ( <Accordion> <AccordionSummary expandIcon={<ExpandMoreIcon />}> <Typography variant="subtitle1"> @@ -128,9 +128,9 @@ const UserPage = () => { /> </AccordionDetails> </Accordion> - )} + )} </> - )} + )} </EditItemView> ); }; |