diff --git a/modern/src/common/attributes/usePositionAttributes.js b/modern/src/common/attributes/usePositionAttributes.js index e08e91d54b..0b191ebc5b 100644 --- a/modern/src/common/attributes/usePositionAttributes.js +++ b/modern/src/common/attributes/usePositionAttributes.js @@ -349,7 +349,7 @@ export default (t) => useMemo(() => ({ type: 'string', }, driverUniqueId: { - name: t('positionDriverUniqueId'), + name: t('sharedDriver'), type: 'string', }, card: { diff --git a/modern/src/common/components/DriverValue.js b/modern/src/common/components/DriverValue.js new file mode 100644 index 0000000000..0969ca20de --- /dev/null +++ b/modern/src/common/components/DriverValue.js @@ -0,0 +1,9 @@ +import { useSelector } from 'react-redux'; + +const DriverValue = ({ driverUniqueId }) => { + const driver = useSelector((state) => state.drivers.items[driverUniqueId]); + + return driver.name; +}; + +export default DriverValue; diff --git a/modern/src/common/components/PositionValue.jsx b/modern/src/common/components/PositionValue.jsx index 64f9dc0463..b1f8f65603 100644 --- a/modern/src/common/components/PositionValue.jsx +++ b/modern/src/common/components/PositionValue.jsx @@ -25,6 +25,7 @@ import { useTranslation } from './LocalizationProvider'; import { useAdministrator } from '../util/permissions'; import AddressValue from './AddressValue'; import GeofencesValue from './GeofencesValue'; +import DriverValue from './DriverValue'; const PositionValue = ({ position, property, attribute }) => { const t = useTranslation(); @@ -97,26 +98,31 @@ const PositionValue = ({ position, property, attribute }) => { case 'image': case 'video': case 'audio': - return ({value}); + return {value}; case 'totalDistance': case 'hours': return ( <> {formatValue(value)}    - {admin && (⚙)} + {admin && ⚙} ); case 'address': - return (); + return ; case 'network': if (value) { - return ({t('sharedInfoTitle')}); + return {t('sharedInfoTitle')}; } return ''; case 'geofenceIds': if (value) { - return (); + return ; + } + return ''; + case 'driverUniqueId': + if (value) { + return ; } return ''; default: diff --git a/modern/src/common/components/StatusCard.jsx b/modern/src/common/components/StatusCard.jsx index 38de944bd7..04e1d172cf 100644 --- a/modern/src/common/components/StatusCard.jsx +++ b/modern/src/common/components/StatusCard.jsx @@ -211,7 +211,7 @@ const StatusCard = ({ deviceId, position, onClose, disableActions, desktopPaddin {positionItems.split(',').filter((key) => position.hasOwnProperty(key) || position.attributes.hasOwnProperty(key)).map((key) => ( ({ root: { @@ -30,6 +31,8 @@ const PositionPage = () => { const navigate = useNavigate(); const t = useTranslation(); + const positionAttributes = usePositionAttributes(t); + const { id } = useParams(); const [item, setItem] = useState(); @@ -85,14 +88,14 @@ const PositionPage = () => { {item && Object.getOwnPropertyNames(item).filter((it) => it !== 'attributes').map((property) => ( {property} - {t(prefixString('position', property))} + {positionAttributes[property]?.name || property} ))} {item && Object.getOwnPropertyNames(item.attributes).map((attribute) => ( {attribute} - {t(prefixString('position', attribute)) || t(prefixString('device', attribute))} + {positionAttributes[attribute]?.name || attribute} ))} diff --git a/modern/src/settings/PreferencesPage.jsx b/modern/src/settings/PreferencesPage.jsx index e067368813..bd96b1405b 100644 --- a/modern/src/settings/PreferencesPage.jsx +++ b/modern/src/settings/PreferencesPage.jsx @@ -173,7 +173,7 @@ const PreferencesPage = () => { multiple freeSolo options={Object.keys(positionAttributes)} - getOptionLabel={(option) => (positionAttributes.hasOwnProperty(option) ? positionAttributes[option].name : option)} + getOptionLabel={(option) => (positionAttributes[option]?.name || option)} value={attributes.positionItems?.split(',') || ['speed', 'address', 'totalDistance', 'course']} onChange={(_, option) => { setAttributes({ ...attributes, positionItems: option.join(',') }); diff --git a/modern/src/store/drivers.js b/modern/src/store/drivers.js index 38933d8401..3ebbdd84ed 100644 --- a/modern/src/store/drivers.js +++ b/modern/src/store/drivers.js @@ -7,7 +7,7 @@ const { reducer, actions } = createSlice({ }, reducers: { update(state, action) { - action.payload.forEach((item) => state.items[item.id] = item); + action.payload.forEach((item) => state.items[item.uniqueId] = item); }, }, });