fixed some errors

main
alex 2023-10-23 18:46:57 +02:00
parent 335b1df740
commit ef5b21e7ae
3 changed files with 35 additions and 21 deletions

View File

@ -126,17 +126,14 @@ export default function WebSocketProvider({
};
const SendSocketMessage = (cmd, body) => {
if (isWebSocketReady && ws.current !== null) {
if (
isWebSocketReady &&
ws.current !== null &&
ws.current.readyState === 1
) {
ws.current.send(JSON.stringify({ Cmd: cmd, Body: body }));
} else {
/*notificationApi["error"]({
message: `Websocket is not ready`,
description: `Please check your internet connection`,
}); */
wsMessageCache.current.push({ Cmd: cmd, Body: body });
// message.error(`Websocket is not ready`);
}
};

View File

@ -238,10 +238,8 @@ export function handleWebSocketMessage(
});
console.log(
"a",
scannerContext
.checkboxAutomaticRecognitionOfEquipmentDocumentationCheckedRef
.current
"here1",
scannerContext.checkboxAutomaticFillingOfInputFieldsCheckedRef.current
);
if (
@ -250,19 +248,33 @@ export function handleWebSocketMessage(
.current &&
IsScannedQrCodeValid(body)
) {
OpenScannedEquipmentDocumentation({
navigate: navigate,
scannedEquipment: JSON.parse(body).stockitem.toString(),
});
} else if (
let item = null;
// check if body is json
try {
item = JSON.parse(body).stockitem.toString();
} catch (error) {}
if (item !== null) {
OpenScannedEquipmentDocumentation({
navigate: navigate,
scannedEquipment: item,
});
}
}
if (
scannerContext.checkboxAutomaticFillingOfInputFieldsCheckedRef.current
) {
// get the current focused input on the page and set the value
const foundInput = document.activeElement;
if (!foundInput) break;
setNativeValue(foundInput, body);
console.log(
"here",
scannerContext.checkboxAutomaticFillingOfInputFieldsCheckedRef.current
);
if (foundInput) {
setNativeValue(foundInput, body);
}
}
break;

View File

@ -350,6 +350,8 @@ export default function Robots() {
const getRobotsTableItems = (robots) => {
let items = [];
if (robots === undefined || robots.length === 0) return items;
robots.sort((a, b) => new Date(b.CreatedAt) - new Date(a.CreatedAt));
robots.forEach((robot) =>
@ -471,6 +473,9 @@ export default function Robots() {
const getUnauthorizedTableItems = (unauthorizedRobots) => {
let items = [];
if (unauthorizedRobots === undefined || unauthorizedRobots.length === 0)
return items;
unauthorizedRobots.forEach((robot) => {
items.push({
key: robot.Id,