import React, { useState, useEffect } from 'react'; import { CCard, CCardHeader, CCardBody, CFormGroup, CCol, CLabel, CForm, CInput, CCollapse, CCardFooter, CButton, } from '@coreui/react'; import CIcon from '@coreui/icons-react'; import PropTypes from 'prop-types'; import { cleanTimestamp } from '../../utils/helper'; import axiosInstance from '../../utils/axiosInstance'; import { getToken } from '../../utils/authHelper'; const DeviceConfiguration = ({ selectedDeviceId }) => { const [collapse, setCollapse] = useState(false); const [device, setDevice] = useState(null); const toggle = (e) => { setCollapse(!collapse); e.preventDefault(); }; const getDevice = () => { const options = { headers: { Accept: 'application/json', Authorization: `Bearer ${getToken()}`, }, }; axiosInstance .get(`/device/${selectedDeviceId}`, options) .then((response) => { setDevice(response.data); }) .catch(() => {}); }; useEffect(() => { if (selectedDeviceId) getDevice(); }, [selectedDeviceId]); if (device) { return ( #{device.serialNumber} Details UUID : {device.UUID} Serial Number : {device.serialNumber} Device Type : {device.deviceType} Last Configuration Change : {cleanTimestamp(device.lastConfigurationChange)} MAC address : {device.macAddress} Created : {cleanTimestamp(device.createdTimestamp)} Last Configuration Download : {cleanTimestamp(device.lastConfigurationDownload)} Manufacturer : {device.manufacturer} Notes : Owner : {device.owner} Location : {device.location} ); } return ( Device Configuration ); }; DeviceConfiguration.propTypes = { selectedDeviceId: PropTypes.string.isRequired, }; export default DeviceConfiguration;