feat(mobile): shadcn like and tailwind added to make things look yummy
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 1m21s

This commit is contained in:
2026-04-27 21:23:40 -05:00
parent 649ae1ee9f
commit 7d2f048932
32 changed files with 1909 additions and 325 deletions

View File

@@ -1,7 +1,7 @@
import TcpSocket from "react-native-tcp-socket";
const STX = "\x02";
const ETX = "\x03";
// const STX = "\x02";
// const ETX = "\x03";
type TcpResponse = {
success: boolean;
@@ -9,26 +9,154 @@ type TcpResponse = {
data: string[];
};
function parseErpResponse(buffer: Buffer) {
const text = buffer
.toString("utf8")
.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|#[0-9A-Za-z])/g, "")
.replace(/\x02/g, "")
.replace(/\x03/g, "")
.trim();
const noHeader = text.replace(/^\d+@/, "");
console.log(text);
if (!noHeader.includes("Scan:")) {
return {
raw: text,
type: "error",
message: noHeader.trim(),
lines: [noHeader.trim()],
};
}
const [actionPart, scanPart = ""] = noHeader.split("Scan:");
const action = actionPart.trim();
const scanClean = scanPart.trim();
const successMatch = scanClean.match(/^(.*?)\s+V$/);
if (successMatch) {
const prompt = successMatch[1].trim();
return {
raw: text,
type: "success",
action,
prompt,
status: "V",
lines: [action, prompt, "V"],
};
}
// // Handles: "Production lotInvalid barcode"
// const knownErrors = [
// "Invalid barcode",
// "Invalid machine",
// "Not on stock",
// "Article tolerance for consolidation not satisfied",
// ].sort((a, b) => b.length - a.length);
// const foundError = knownErrors.find((err) => scanClean.includes(err));
// if (foundError) {
// const prompt = scanClean.replace(foundError, "").trim();
// return {
// raw: text,
// type: "error",
// action,
// prompt,
// message: foundError,
// lines: [action, prompt, foundError].filter(Boolean),
// };
// }
// return {
// raw: text,
// type: "pending",
// action,
// prompt: scanClean,
// lines: [action, scanClean].filter(Boolean),
// };
const unitMatch = scanClean.match(/^(Unit\s+\d+\/\d+)(.*)$/);
if (unitMatch) {
const prompt = unitMatch[1].trim(); // "Unit 1/4"
const remainder = unitMatch[2].trim(); // everything after
// SUCCESS
if (remainder === "V") {
return {
raw: text,
type: "success",
action,
prompt,
status: "V",
lines: [action, prompt, "V"],
};
}
// Known ERP errors
const knownErrors = [
"Invalid barcode",
"Invalid machine",
"Not on stock",
"Article tolerance for consolidation not satisfied",
];
const foundError = knownErrors.find((err) =>
remainder.toLowerCase().includes(err.toLowerCase()),
);
if (foundError) {
return {
raw: text,
type: "error",
action,
prompt,
message: foundError,
lines: [action, prompt, foundError],
};
}
if (remainder) {
return {
raw: text,
type: "prompt",
action,
prompt,
message: remainder,
lines: [action, prompt, remainder],
};
}
return {
raw: text,
type: "pending",
action,
prompt,
lines: [action, prompt],
};
}
}
/**
* Sends a Zebra-style TCP message:
* <STX>98@{scanned}<ETX>
*/
export async function sendTcpMessage(
scanned: string,
command: string,
host: string,
port: number,
timeoutMs = 5000,
): Promise<TcpResponse> {
return new Promise((resolve) => {
const responses: string[] = [];
const responses: any = [];
const client = TcpSocket.createConnection({ host, port }, () => {
const payload = `${STX}98@${scanned}${ETX}`;
console.log("Sending TCP (visible):", `${command}`);
console.log("Sending TCP (raw):", payload);
console.log("Sending TCP (visible):", `<stx>98@${scanned}<etx>`);
client.write(payload);
client.write(command);
});
const timeout = setTimeout(() => {
@@ -42,10 +170,17 @@ export async function sendTcpMessage(
}, timeoutMs);
client.on("data", (data) => {
const text = data.toString();
console.log("TCP received:", text);
//const text = data.toString();
//console.log("TCP received:", text);
const parsed = parseErpResponse(data);
responses.push(text);
responses.push(parsed);
clearTimeout(timeout);
resolve({
success: true,
message: "TCP Response",
data: responses,
});
});
client.on("error", (err) => {

View File

@@ -0,0 +1,81 @@
import { DarkTheme, DefaultTheme, type Theme } from "@react-navigation/native";
export const THEME = {
light: {
background: "hsl(0 0% 100%)",
foreground: "hsl(0 0% 3.9%)",
card: "hsl(0 0% 100%)",
cardForeground: "hsl(0 0% 3.9%)",
popover: "hsl(0 0% 100%)",
popoverForeground: "hsl(0 0% 3.9%)",
primary: "hsl(0 0% 9%)",
primaryForeground: "hsl(0 0% 98%)",
secondary: "hsl(0 0% 96.1%)",
secondaryForeground: "hsl(0 0% 9%)",
muted: "hsl(0 0% 96.1%)",
mutedForeground: "hsl(0 0% 45.1%)",
accent: "hsl(0 0% 96.1%)",
accentForeground: "hsl(0 0% 9%)",
destructive: "hsl(0 84.2% 60.2%)",
border: "hsl(0 0% 89.8%)",
input: "hsl(0 0% 89.8%)",
ring: "hsl(0 0% 63%)",
radius: "0.625rem",
chart1: "hsl(12 76% 61%)",
chart2: "hsl(173 58% 39%)",
chart3: "hsl(197 37% 24%)",
chart4: "hsl(43 74% 66%)",
chart5: "hsl(27 87% 67%)",
},
dark: {
background: "hsl(0 0% 3.9%)",
foreground: "hsl(0 0% 98%)",
card: "hsl(0 0% 3.9%)",
cardForeground: "hsl(0 0% 98%)",
popover: "hsl(0 0% 3.9%)",
popoverForeground: "hsl(0 0% 98%)",
primary: "hsl(0 0% 98%)",
primaryForeground: "hsl(0 0% 9%)",
secondary: "hsl(0 0% 14.9%)",
secondaryForeground: "hsl(0 0% 98%)",
muted: "hsl(0 0% 14.9%)",
mutedForeground: "hsl(0 0% 63.9%)",
accent: "hsl(0 0% 14.9%)",
accentForeground: "hsl(0 0% 98%)",
destructive: "hsl(0 70.9% 59.4%)",
border: "hsl(0 0% 14.9%)",
input: "hsl(0 0% 14.9%)",
ring: "hsl(300 0% 45%)",
radius: "0.625rem",
chart1: "hsl(220 70% 50%)",
chart2: "hsl(160 60% 45%)",
chart3: "hsl(30 80% 55%)",
chart4: "hsl(280 65% 60%)",
chart5: "hsl(340 75% 55%)",
},
};
export const NAV_THEME: Record<"light" | "dark", Theme> = {
light: {
...DefaultTheme,
colors: {
background: THEME.light.background,
border: THEME.light.border,
card: THEME.light.card,
notification: THEME.light.destructive,
primary: THEME.light.primary,
text: THEME.light.foreground,
},
},
dark: {
...DarkTheme,
colors: {
background: THEME.dark.background,
border: THEME.dark.border,
card: THEME.dark.card,
notification: THEME.dark.destructive,
primary: THEME.dark.primary,
text: THEME.dark.foreground,
},
},
};

View File

@@ -0,0 +1,6 @@
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}