aboutsummaryrefslogtreecommitdiff
path: root/modern
diff options
context:
space:
mode:
authorAshutosh Bishnoi <mail2bishnoi@gmail.com>2020-11-02 18:29:47 +0530
committerAshutosh Bishnoi <mail2bishnoi@gmail.com>2020-11-02 18:29:47 +0530
commit3780cf9986947e409ffccd9e7a06d9554ce3cdcf (patch)
tree88f47314bee42a2764cfb3ff3234489cd5623a43 /modern
parent8c167d82b75b764d3b12845aae7827550607a148 (diff)
downloadtrackermap-web-3780cf9986947e409ffccd9e7a06d9554ce3cdcf.tar.gz
trackermap-web-3780cf9986947e409ffccd9e7a06d9554ce3cdcf.tar.bz2
trackermap-web-3780cf9986947e409ffccd9e7a06d9554ce3cdcf.zip
Code formatting changes and use of async/await
Diffstat (limited to 'modern')
-rw-r--r--modern/src/reports/EventReportPage.js14
-rw-r--r--modern/src/reports/ReportFilter.js17
2 files changed, 11 insertions, 20 deletions
diff --git a/modern/src/reports/EventReportPage.js b/modern/src/reports/EventReportPage.js
index 4134de3d..fce9597f 100644
--- a/modern/src/reports/EventReportPage.js
+++ b/modern/src/reports/EventReportPage.js
@@ -25,19 +25,19 @@ const EventReportPage = () => {
const classes = useStyles();
const [data, setData] = useState([]);
- const handleSubmit = (deviceId, from, to) => {
+ const handleSubmit = async (deviceId, from, to) => {
const query = new URLSearchParams({
deviceId,
from: from.toISOString(),
to: to.toISOString(),
});
- fetch(`/api/reports/events?${query.toString()}`, { headers: { Accept: 'application/json' } })
- .then((response) => {
- if (response.ok) {
- response.json().then(setData);
- }
- });
+ const response = await fetch(`/api/reports/events?${query.toString()}`, { headers: { Accept: 'application/json' } })
+
+ if(response.ok) {
+ const data = await response.json();
+ setData(data);
+ }
}
return (
diff --git a/modern/src/reports/ReportFilter.js b/modern/src/reports/ReportFilter.js
index 6f248048..be48413b 100644
--- a/modern/src/reports/ReportFilter.js
+++ b/modern/src/reports/ReportFilter.js
@@ -81,8 +81,7 @@ const ReportFilter = (props) => {
onChange={(e) =>
setFrom(moment(e.target.value, moment.HTML5_FMT.DATETIME_LOCAL))
}
- fullWidth
- />
+ fullWidth />
)}
{period === 'custom' && (
<TextField
@@ -94,23 +93,15 @@ const ReportFilter = (props) => {
onChange={(e) =>
setTo(moment(e.target.value, moment.HTML5_FMT.DATETIME_LOCAL))
}
- fullWidth
- />
+ fullWidth />
)}
<FormControl margin="normal" fullWidth>
- <Button
- type="button"
- color="primary"
- variant="contained"
- disabled={!deviceId}
- onClick={handleShow}
- >
+ <Button type="button" color="primary" variant="contained" disabled={!deviceId} onClick={handleShow}>
{t('reportShow')}
</Button>
</FormControl>
</>
);
-
}
-export default ReportFilter; \ No newline at end of file
+export default ReportFilter;