diff --git a/client/components/AdminPage/UserTable/deviceModels.js b/client/components/AdminPage/UserTable/deviceModels.js index 3f5037f..f20fc5d 100644 --- a/client/components/AdminPage/UserTable/deviceModels.js +++ b/client/components/AdminPage/UserTable/deviceModels.js @@ -6,4 +6,15 @@ const deviceModels = { 2023: 'Thinkpad L14 gen 3', } -export default deviceModels +const deviceModelColumn = { + key: 'device_model', + label: 'Device model', + renderCell: ({ deviceGivenAt }) => { + if (!deviceGivenAt) return '-' + const model = deviceModels[new Date(deviceGivenAt).getFullYear()] + if (!model) return 'Not found' + return model + }, +} + +export default deviceModelColumn diff --git a/client/components/AdminPage/UserTable/index.js b/client/components/AdminPage/UserTable/index.js index 5cd0711..2863e80 100644 --- a/client/components/AdminPage/UserTable/index.js +++ b/client/components/AdminPage/UserTable/index.js @@ -7,7 +7,7 @@ import { } from '../../../util/redux/usersReducer' import dateFormatter from '../../../util/dateFormatter' import VirtualizedTable from '../../VirtualizedTable' -import deviceModels from './deviceModels' +import deviceModelColumn from './deviceModels' const UserTable = ({ users, handleAdminNoteClick, handleStaffSettingClick, hiddenColumns, filter, @@ -158,16 +158,7 @@ const UserTable = ({ ), }, - { - key: 'device_model', - label: 'Device model', - renderCell: ({ deviceGivenAt }) => { - if (!deviceGivenAt) return '-' - const model = deviceModels[new Date(deviceGivenAt).getFullYear()] - if (!model) return 'Not found' - return model - }, - }, + deviceModelColumn, { key: 'device_returned_at', label: 'Returned at', diff --git a/client/components/StaffPage/StudentTable/index.js b/client/components/StaffPage/StudentTable/index.js index 058e86a..1e9a945 100644 --- a/client/components/StaffPage/StudentTable/index.js +++ b/client/components/StaffPage/StudentTable/index.js @@ -3,6 +3,7 @@ import { useDispatch } from 'react-redux' import { Button, } from 'semantic-ui-react' +import deviceModelColumn from 'Components/AdminPage/UserTable/deviceModels' import dateFormatter from '../../../util/dateFormatter' import VirtualizedTable from '../../VirtualizedTable' import { updateStudentStatus, markStudentEligible } from '../../../util/redux/studentReducer' @@ -96,6 +97,7 @@ const StudentTable = ({ students, hiddenColumns }) => { getCellVal: ({ deviceGivenAt }) => new Date(deviceGivenAt).getTime(), width: 160, }, + deviceModelColumn, { key: 'wants_device', label: 'Wants device',