aboutsummaryrefslogtreecommitdiff
path: root/modern/src/DevicePage.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-05-02 17:13:33 -0700
committerAnton Tananaev <anton@traccar.org>2022-05-02 17:13:33 -0700
commitf52be84522da7f8e1c2b19d3484250e275252799 (patch)
treef13316af299e5f1665cbb0e9d73a5f9ffc04d961 /modern/src/DevicePage.js
parent3a8a11c5d101c30cabf727f6a27a892e9bc4c99a (diff)
downloadtrackermap-web-f52be84522da7f8e1c2b19d3484250e275252799.tar.gz
trackermap-web-f52be84522da7f8e1c2b19d3484250e275252799.tar.bz2
trackermap-web-f52be84522da7f8e1c2b19d3484250e275252799.zip
Implement model validation
Diffstat (limited to 'modern/src/DevicePage.js')
-rw-r--r--modern/src/DevicePage.js14
1 files changed, 7 insertions, 7 deletions
diff --git a/modern/src/DevicePage.js b/modern/src/DevicePage.js
index def48d9c..e4b853e7 100644
--- a/modern/src/DevicePage.js
+++ b/modern/src/DevicePage.js
@@ -28,10 +28,11 @@ const DevicePage = () => {
const [item, setItem] = useState();
+ const validate = () => item && item.name && item.uniqueId;
+
return (
- <EditItemView endpoint="devices" item={item} setItem={setItem}>
- {item
- && (
+ <EditItemView endpoint="devices" item={item} setItem={setItem} validate={validate}>
+ {item && (
<>
<Accordion defaultExpanded>
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
@@ -124,8 +125,7 @@ const DevicePage = () => {
/>
</AccordionDetails>
</Accordion>
- {item.id
- && (
+ {item.id && (
<Accordion>
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
<Typography variant="subtitle1">
@@ -187,9 +187,9 @@ const DevicePage = () => {
/>
</AccordionDetails>
</Accordion>
- )}
+ )}
</>
- )}
+ )}
</EditItemView>
);
};