refactor(scanner): added toasts in to make it look better
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 1m25s

This commit is contained in:
2026-05-06 19:42:52 -05:00
parent 87803eed43
commit edb3668548
8 changed files with 286 additions and 32 deletions

View File

@@ -1,5 +1,6 @@
import axios from "axios";
import { format } from "date-fns-tz";
import { useFocusEffect } from "expo-router";
import { useCallback, useEffect, useState } from "react";
import { Text, View } from "react-native";
import { useAppStore } from "../hooks/useAppStore";
@@ -58,7 +59,9 @@ export default function ProdScanner() {
...scanned.data,
runningNumber: scan.data.startsWith("000")
? parseInt(scan.data.slice(10, -1) || "000", 10).toString()
: "0",
: scan.data.startsWith("loc")
? scan.data
: "0",
};
try {
await axios.post(
@@ -118,20 +121,21 @@ export default function ProdScanner() {
//console.log(lastScan);
useEffect(() => {
zebraScanner.ensureProfile();
zebraScanner.startListening();
useFocusEffect(
useCallback(() => {
zebraScanner.startListening();
const sub = zebraScanner.addScanListener((scan) => {
//console.log("SCAN:", scan);
handleScan(scan);
});
const sub = zebraScanner.addScanListener((scan) => {
//console.log("SCAN:", scan);
handleScan(scan);
});
return () => {
sub.remove();
zebraScanner.stopListening();
};
}, [handleScan]);
return () => {
sub.remove();
zebraScanner.stopListening();
};
}, [handleScan]),
);
return (
<View className={`${bgColor ?? ""} flex-1 w-screen`}>
<View>