From b39ffd97e355dc2a6bba65ffa56947734455ed24 Mon Sep 17 00:00:00 2001
From: Matjaž Črnko <m.crnko@txt.si>
Date: Mon, 22 Jan 2024 14:55:53 +0100
Subject: fix: Migrate ReportFilter to SelectField

---
 modern/src/reports/components/ReportFilter.jsx | 43 +++++---------------------
 1 file changed, 8 insertions(+), 35 deletions(-)

(limited to 'modern/src/reports/components/ReportFilter.jsx')

diff --git a/modern/src/reports/components/ReportFilter.jsx b/modern/src/reports/components/ReportFilter.jsx
index de64188c..9e6a0a23 100644
--- a/modern/src/reports/components/ReportFilter.jsx
+++ b/modern/src/reports/components/ReportFilter.jsx
@@ -92,41 +92,14 @@ const ReportFilter = ({ children, handleSubmit, handleSchedule, showOnly, ignore
     <div className={classes.filter}>
       {!ignoreDevice && (
         <div className={classes.filterItem}>
-          <FormControl fullWidth>
-          {multiDevice ? (
-            <>
-              <InputLabel>{t('deviceTitle')}</InputLabel>
-              <Select
-                label={t('deviceTitle')}
-                value={deviceIds}
-                onChange={(e) => dispatch(devicesActions.selectIds(e.target.value))}
-                multiple
-              >
-                {Object.values(devices).sort((a, b) => a.name.localeCompare(b.name)).map((device) => (
-                  <MenuItem key={device.id} value={device.id}>{device.name}</MenuItem>
-                ))}
-              </Select>
-            </>
-          ) : (
-            <>
-              <Autocomplete
-                size="small"
-                options={Object.values(devices).sort((a, b) => a.name.localeCompare(b.name))}
-                getOptionLabel={(option) => option?.name ?? ''}
-                renderOption={(props, option) => (
-                  <MenuItem {...props} key={option.id}>
-                      {option.name}
-                  </MenuItem>
-                )}
-                value={devices[deviceId] || null}
-                onChange={(event, newValue) => {
-                  dispatch(devicesActions.selectId(newValue?.id ?? null))
-                }}
-                renderInput={(params) => <TextField {...params} label={t('reportDevice')} />}
-              />
-            </>
-          )}
-          </FormControl>
+          <SelectField 
+            label={t(multiDevice ? 'deviceTitle' : 'reportDevice')}
+            data={Object.values(devices).sort((a, b) => a.name.localeCompare(b.name))}
+            value={multiDevice ? deviceIds : deviceId || null}
+            onChange={(e) => dispatch(multiDevice ? devicesActions.selectIds(e.target.value) : devicesActions.selectId(e.target.value))}
+            multiple={multiDevice}
+            fullWidth
+          />
         </div>
       )}
       {includeGroups && (
-- 
cgit v1.2.3

