diff --git a/imports/ui/pages/Assignments/ByAsset.jsx b/imports/ui/pages/Assignments/ByAsset.jsx
index e186051..acf264f 100644
--- a/imports/ui/pages/Assignments/ByAsset.jsx
+++ b/imports/ui/pages/Assignments/ByAsset.jsx
@@ -30,6 +30,7 @@ import Tab from '@mui/material/Tab';
import TabContext from '@mui/lab/TabContext';
import TabList from '@mui/lab/TabList';
import TabPanel from '@mui/lab/TabPanel';
+import {ErrorBoundary} from "react-error-boundary";
const cssTwoColumnContainer = {
display: 'grid',
@@ -174,30 +175,32 @@ const AssignmentsByAsset = () => {
return (
<>
- {data.map((next, i) => (
- -
- {next.person && (
- <>
- User: {next.person.firstName} {next.person.lastName} {next.person.grade ? "~ " + next.person.grade : ""} ({next.email})
- >
- )}
- {!next.person && (
- <>
- User: N/A
- >
- )}
- {/*Device ID: {next.deviceId}
*/}
- {/*{next.asset && (*/}
- {/* <>Asset ID: {next.asset.assetId}
>*/}
- {/*)}*/}
- {/*<>Asset Type: {next.assetType ? next.assetType.name : "Unknown"}
>*/}
- {/*Serial: {next.serial}
*/}
- {new Date(next.startTime).toLocaleDateString("en-US") + "-" + new Date(next.endTime).toLocaleDateString("en-US") + " @ " + new Date(next.endTime).toLocaleTimeString("en-US")} ({Math.ceil(((next.endTime ? next.endTime : new Date().getTime()) - next.startTime) / (1000*60*60*24))} days)
- {/*{next.assignedTo && (*/}
- {/* <>Currently assigned to: {next.assignedTo.firstName} {next.assignedTo.lastName} {next.assignedTo.grade ? "~ " + next.assignedTo.grade : ""} ({next.assignedTo.email})>*/}
- {/*)}*/}
-
- ))}
+ Error}>
+ {data && data.map && data.map((next, i) => (
+ -
+ {next.person && (
+ <>
+ User: {next.person.firstName} {next.person.lastName} {next.person.grade ? "~ " + next.person.grade : ""} ({next.email})
+ >
+ )}
+ {!next.person && (
+ <>
+ User: N/A
+ >
+ )}
+ {/*Device ID: {next.deviceId}
*/}
+ {/*{next.asset && (*/}
+ {/* <>Asset ID: {next.asset.assetId}
>*/}
+ {/*)}*/}
+ {/*<>Asset Type: {next.assetType ? next.assetType.name : "Unknown"}
>*/}
+ {/*Serial: {next.serial}
*/}
+ {new Date(next.startTime).toLocaleDateString("en-US") + "-" + new Date(next.endTime).toLocaleDateString("en-US") + " @ " + new Date(next.endTime).toLocaleTimeString("en-US")} ({Math.ceil(((next.endTime ? next.endTime : new Date().getTime()) - next.startTime) / (1000*60*60*24))} days)
+ {/*{next.assignedTo && (*/}
+ {/* <>Currently assigned to: {next.assignedTo.firstName} {next.assignedTo.lastName} {next.assignedTo.grade ? "~ " + next.assignedTo.grade : ""} ({next.assignedTo.email})>*/}
+ {/*)}*/}
+
+ ))}
+
>
)
diff --git a/imports/ui/util/SimpleTable.jsx b/imports/ui/util/SimpleTable.jsx
index 5e14222..0d42945 100644
--- a/imports/ui/util/SimpleTable.jsx
+++ b/imports/ui/util/SimpleTable.jsx
@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React, {useRef, useState} from 'react';
import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell';
@@ -48,6 +48,7 @@ const cssTopControls = {
*/
export default ({columns, rows, options}) => {
const [selected, setSelected] = useState(undefined);
+ const tableContainer = useRef(null)
let selectRow = (e, row) => {
setSelected(row);
@@ -67,6 +68,7 @@ export default ({columns, rows, options}) => {
const addRow = () => {
setEdited({});
+ setTimeout(() => tableContainer.current.scrollTo({top: 0, left: 0, behavior: "smooth"}),0)
}
let containerStyle = options.maxHeight ? {maxHeight: options.maxHeight} : {}
@@ -131,7 +133,7 @@ export default ({columns, rows, options}) => {
{options.add && }
{options.remove && _.isFunction(options.remove) && }
-
+
diff --git a/package.json b/package.json
index aa09f68..5570d82 100644
--- a/package.json
+++ b/package.json
@@ -30,6 +30,7 @@
"mongodb": "^4.4.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
+ "react-error-boundary": "^4.0.11",
"react-router-dom": "^6.3.0",
"typescript": "^4.8.4",
"umbrellajs": "^3.3.1",