refactor(scanner): finished login stuff for current routes
This commit is contained in:
@@ -7,6 +7,7 @@ import { useMobileAuthStore } from "../hooks/useMobileAuth";
|
||||
import { useScannerStore } from "../hooks/useScannerStore";
|
||||
import { scannerFeedback } from "../lib/feedbackScan";
|
||||
import { sendTcpMessage } from "../lib/tcpScan";
|
||||
import { versionCheck } from "../lib/versionValidation";
|
||||
import { type ZebraScanResult, zebraScanner } from "../lib/ZebraScanner";
|
||||
import { ScannedLabelBox } from "./ScannedLabels";
|
||||
import { GlobalFooter } from "./UpdateFooter";
|
||||
@@ -45,10 +46,15 @@ export default function LSTScanner() {
|
||||
scan.data.toLowerCase().includes(cmd.toLowerCase()),
|
||||
);
|
||||
|
||||
console.log(user?.excludedCommand);
|
||||
|
||||
if (isAlphaStart && isExcluded) {
|
||||
Alert.alert(
|
||||
`Command: ${scan.data} is not allowed to be used, please contact logistics if this is an error`,
|
||||
"Command not allowed",
|
||||
`Command: ${scan.data}\n\nPlease contact logistics if this is an error`,
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let commandToSend = `${STX}${user?.scannerId}@${scan.data}${ETX}`;
|
||||
@@ -68,16 +74,24 @@ export default function LSTScanner() {
|
||||
const scanned = (await sendTcpMessage(
|
||||
commandToSend,
|
||||
serverIp,
|
||||
parseInt(serverPort || "0", 10),
|
||||
50004,
|
||||
)) as any;
|
||||
|
||||
// send the logs to lst but allow it to time out if it dose not exist just bc.
|
||||
const logInfo = { ...scanned, user: user?.name };
|
||||
|
||||
try {
|
||||
await axios.post(
|
||||
`http://${serverIp.trim()}:3000/lst/api/mobile/logs`,
|
||||
logInfo,
|
||||
);
|
||||
await axios.post(`http://${serverIp.trim()}:3000/lst/api/mobile/logs`, {
|
||||
scannerId: user?.scannerId ?? "0",
|
||||
message: scanned.data.message,
|
||||
prompt: scanned.data.prompt,
|
||||
commandDescription: scanned.data.commandDescription,
|
||||
status: scanned.data.status,
|
||||
lines: scanned.data.lines,
|
||||
user: user?.name ?? "prodScan",
|
||||
runningNumber: scan.data.startsWith("000")
|
||||
? parseInt(scan.data.slice(10, -1) || "000", 10).toString()
|
||||
: "0",
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
@@ -90,7 +104,15 @@ export default function LSTScanner() {
|
||||
vibrate: true,
|
||||
led: true,
|
||||
});
|
||||
|
||||
setBGColor("bg-green-500");
|
||||
|
||||
// version check
|
||||
versionCheck();
|
||||
|
||||
// auth update
|
||||
useMobileAuthStore.getState().updateLastScan();
|
||||
|
||||
setTimeout(() => {
|
||||
setBGColor(null);
|
||||
}, 1 * 1000);
|
||||
@@ -117,7 +139,6 @@ export default function LSTScanner() {
|
||||
},
|
||||
[
|
||||
serverIp,
|
||||
serverPort,
|
||||
setLastScan,
|
||||
user?.scannerId,
|
||||
user?.name,
|
||||
|
||||
Reference in New Issue
Block a user