Compare commits
13 Commits
v0.0.2-alp
...
e9b0101095
| Author | SHA1 | Date | |
|---|---|---|---|
| e9b0101095 | |||
| ca885fb01a | |||
| edb3668548 | |||
| 87803eed43 | |||
| e61038e004 | |||
| d99449ddc4 | |||
| 3552ca31f9 | |||
| b578f05d64 | |||
| 4ca74de279 | |||
| 12412536d1 | |||
| a38e2e0339 | |||
| 8c253a90b6 | |||
| ba30281e59 |
66
.gitea/ISSUE_TEMPLATE/bug_report.md
Normal file
66
.gitea/ISSUE_TEMPLATE/bug_report.md
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
---
|
||||||
|
name: Bug Report
|
||||||
|
about: Report something that is broken or not working correctly
|
||||||
|
title: "[BUG] "
|
||||||
|
ref: "main"
|
||||||
|
labels:
|
||||||
|
|
||||||
|
- bug
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
|
||||||
|
Briefly explain the issue.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Steps To Reproduce
|
||||||
|
|
||||||
|
1. Go to ...
|
||||||
|
2. Click ...
|
||||||
|
3. Scan ...
|
||||||
|
4. Error occurs ...
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Expected Behavior
|
||||||
|
|
||||||
|
What should have happened?
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Actual Behavior
|
||||||
|
|
||||||
|
What actually happened instead?
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Severity
|
||||||
|
|
||||||
|
- [ ] Low
|
||||||
|
- [ ] Medium
|
||||||
|
- [ ] High
|
||||||
|
- [ ] Critical
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Environment
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
- Production
|
||||||
|
- Development
|
||||||
|
- Zebra Scanner
|
||||||
|
- Mobile Device
|
||||||
|
- Windows Server
|
||||||
|
- Docker
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Logs / Screenshots
|
||||||
|
|
||||||
|
Paste logs or upload screenshots here.
|
||||||
|
|
||||||
|
```txt
|
||||||
|
Paste logs here
|
||||||
0
.gitea/ISSUE_TEMPLATE/config.yaml
Normal file
0
.gitea/ISSUE_TEMPLATE/config.yaml
Normal file
47
.gitea/ISSUE_TEMPLATE/enhancement.md
Normal file
47
.gitea/ISSUE_TEMPLATE/enhancement.md
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
---
|
||||||
|
name: Enhancement
|
||||||
|
about: Improve or refine an existing feature
|
||||||
|
title: "[ENHANCEMENT] "
|
||||||
|
ref: "main"
|
||||||
|
labels:
|
||||||
|
|
||||||
|
- enhancement
|
||||||
|
---
|
||||||
|
|
||||||
|
# Existing Feature
|
||||||
|
|
||||||
|
What current feature or workflow is being improved?
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
- Notifications
|
||||||
|
- Scanner Login
|
||||||
|
- Release Monitor
|
||||||
|
- Printing
|
||||||
|
- Auth
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Proposed Improvement
|
||||||
|
|
||||||
|
Describe the improvement.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Expected Benefit
|
||||||
|
|
||||||
|
Why would this improvement help?
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Impact
|
||||||
|
|
||||||
|
- [ ] Small
|
||||||
|
- [ ] Medium
|
||||||
|
- [ ] Large
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Additional Notes
|
||||||
|
|
||||||
|
Anything else worth mentioning.
|
||||||
40
.gitea/ISSUE_TEMPLATE/feature_request.md
Normal file
40
.gitea/ISSUE_TEMPLATE/feature_request.md
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
name: Feature Request
|
||||||
|
about: Suggest a brand new feature or module
|
||||||
|
title: "[FEATURE] "
|
||||||
|
ref: "main"
|
||||||
|
labels:
|
||||||
|
|
||||||
|
- feature
|
||||||
|
---
|
||||||
|
|
||||||
|
# Problem Statement
|
||||||
|
|
||||||
|
What problem are you trying to solve?
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Proposed Solution
|
||||||
|
|
||||||
|
Describe the feature you would like added.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Alternatives Considered
|
||||||
|
|
||||||
|
Any other ideas, workarounds, or approaches?
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Priority
|
||||||
|
|
||||||
|
- [ ] Nice to Have
|
||||||
|
- [ ] Medium Priority
|
||||||
|
- [ ] High Priority
|
||||||
|
- [ ] Critical
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Additional Context
|
||||||
|
|
||||||
|
Add mockups, screenshots, examples, or notes here.
|
||||||
@@ -12,20 +12,20 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout (local)
|
- name: Checkout (local)
|
||||||
run: |
|
run: |
|
||||||
git clone https://git.tuffraid.net/cowch/lst_v3.git .
|
git clone http://10.75.9.150:3100/cowch/lst_v3.git .
|
||||||
git checkout ${{ gitea.sha }}
|
git checkout ${{ gitea.sha }}
|
||||||
|
|
||||||
- name: Login to registry
|
- name: Login to registry
|
||||||
run: echo "${{ secrets.PASSWORD }}" | docker login git.tuffraid.net -u "cowch" --password-stdin
|
run: echo "${{ secrets.PASSWORD }}" | docker login 10.75.9.150:3100 -u "cowch" --password-stdin
|
||||||
|
|
||||||
- name: Build image
|
- name: Build image
|
||||||
run: |
|
run: |
|
||||||
docker build \
|
docker build \
|
||||||
-t git.tuffraid.net/cowch/lst_v3:latest \
|
-t 10.75.9.150:3100/cowch/lst_v3:latest \
|
||||||
-t git.tuffraid.net/cowch/lst_v3:${{ gitea.sha }} \
|
-t 10.75.9.150:3100/cowch/lst_v3:${{ gitea.sha }} \
|
||||||
.
|
.
|
||||||
|
|
||||||
- name: Push
|
- name: Push
|
||||||
run: |
|
run: |
|
||||||
docker push git.tuffraid.net/cowch/lst_v3:latest
|
docker push 10.75.9.150:3100/cowch/lst_v3:latest
|
||||||
docker push git.tuffraid.net/cowch/lst_v3:${{ gitea.sha }}
|
docker push 10.75.9.150:3100/cowch/lst_v3:${{ gitea.sha }}
|
||||||
@@ -14,12 +14,12 @@ jobs:
|
|||||||
# Examples:
|
# Examples:
|
||||||
# http://gitea.internal.lan:3000
|
# http://gitea.internal.lan:3000
|
||||||
# https://gitea-origin.yourdomain.local
|
# https://gitea-origin.yourdomain.local
|
||||||
GITEA_INTERNAL_URL: "https://git.tuffraid.net"
|
GITEA_INTERNAL_URL: "http://10.75.9.150:3100" #"https://git.tuffraid.net"
|
||||||
|
|
||||||
# Internal/origin registry host. Usually same host as above, but without protocol.
|
# Internal/origin registry host. Usually same host as above, but without protocol.
|
||||||
# Example:
|
# Example:
|
||||||
# gitea.internal:3000
|
# gitea.internal:3000
|
||||||
REGISTRY_HOST: "git.tuffraid.net"
|
REGISTRY_HOST: "10.75.9.150:3100" #"git.tuffraid.net"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository
|
- name: Check out repository
|
||||||
|
|||||||
27
CHANGELOG.md
27
CHANGELOG.md
@@ -1,5 +1,32 @@
|
|||||||
# All Changes to LST can be found below.
|
# All Changes to LST can be found below.
|
||||||
|
|
||||||
|
## [0.0.2-alpha.9](https://git.tuffraid.net/cowch/lst_v3/compare/v0.0.2-alpha.8...v0.0.2-alpha.9) (2026-05-06)
|
||||||
|
|
||||||
|
|
||||||
|
### 🛠️ Code Refactor
|
||||||
|
|
||||||
|
* **mobile:** valildation of server after each scan ([4ca74de](https://git.tuffraid.net/cowch/lst_v3/commits/4ca74de2795cea7244e38697d16afe2822164ed6))
|
||||||
|
* **scanner:** added in running number ([a38e2e0](https://git.tuffraid.net/cowch/lst_v3/commits/a38e2e033977b725538e9a9046098d94194d549e))
|
||||||
|
* **scanner:** finished login stuff for current routes ([1241253](https://git.tuffraid.net/cowch/lst_v3/commits/12412536d10981013053c39d156c6c9cb0babd11))
|
||||||
|
|
||||||
|
|
||||||
|
### 📝 Testing Code
|
||||||
|
|
||||||
|
* **scanner:** lane check ([d99449d](https://git.tuffraid.net/cowch/lst_v3/commits/d99449ddc4e2777c1b0fe9189ba0a7c01fe1dd8f))
|
||||||
|
|
||||||
|
|
||||||
|
### 📈 Project Builds
|
||||||
|
|
||||||
|
* **builds:** changed to ip as its on the same server ([3552ca3](https://git.tuffraid.net/cowch/lst_v3/commits/3552ca31f9f7b3bcbe557a145e7eb154bfdae79c))
|
||||||
|
* **release:** bypass cloudflare upload limit ([b578f05](https://git.tuffraid.net/cowch/lst_v3/commits/b578f05d6482f9b6f30febeee6ab0b708a70f68b))
|
||||||
|
|
||||||
|
## [0.0.2-alpha.8](https://git.tuffraid.net/cowch/lst_v3/compare/v0.0.2-alpha.7...v0.0.2-alpha.8) (2026-05-06)
|
||||||
|
|
||||||
|
|
||||||
|
### 🌟 Enhancements
|
||||||
|
|
||||||
|
* **mobile:** auth added in ([ba30281](https://git.tuffraid.net/cowch/lst_v3/commits/ba30281e59040513a036fb7413e372457d04a7c8))
|
||||||
|
|
||||||
## [0.0.2-alpha.7](https://git.tuffraid.net/cowch/lst_v3/compare/v0.0.2-alpha.6...v0.0.2-alpha.7) (2026-05-06)
|
## [0.0.2-alpha.7](https://git.tuffraid.net/cowch/lst_v3/compare/v0.0.2-alpha.6...v0.0.2-alpha.7) (2026-05-06)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
boolean,
|
boolean,
|
||||||
|
jsonb,
|
||||||
pgEnum,
|
pgEnum,
|
||||||
pgTable,
|
pgTable,
|
||||||
text,
|
text,
|
||||||
@@ -25,7 +26,7 @@ export const scanUser = pgTable(
|
|||||||
scannerId: text("scanner_id").unique().notNull(),
|
scannerId: text("scanner_id").unique().notNull(),
|
||||||
pinNumber: text("pin_number").unique().notNull(),
|
pinNumber: text("pin_number").unique().notNull(),
|
||||||
pinHash: text("pin_hash").notNull(),
|
pinHash: text("pin_hash").notNull(),
|
||||||
excludedCommand: text("excluded_commands").default(""),
|
excludedCommand: jsonb("excluded_commands").default([]),
|
||||||
role: mobileRoleEnum("role").notNull().default("user"),
|
role: mobileRoleEnum("role").notNull().default("user"),
|
||||||
active: boolean("active").default(true),
|
active: boolean("active").default(true),
|
||||||
lastScan: timestamp("last_scan").defaultNow(),
|
lastScan: timestamp("last_scan").defaultNow(),
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ import type z from "zod";
|
|||||||
|
|
||||||
export const scanLog = pgTable("scan_log", {
|
export const scanLog = pgTable("scan_log", {
|
||||||
id: uuid("id").defaultRandom().primaryKey(),
|
id: uuid("id").defaultRandom().primaryKey(),
|
||||||
|
user: text("user"),
|
||||||
scannerId: text("scanner_id"),
|
scannerId: text("scanner_id"),
|
||||||
message: text("message").notNull(),
|
message: text("message").notNull(),
|
||||||
prompt: text("prompt"),
|
prompt: text("prompt"),
|
||||||
commandDescription: text("command_description"),
|
commandDescription: text("command_description"),
|
||||||
|
runningNumber: text("running_number").default("0"),
|
||||||
status: text("status"),
|
status: text("status"),
|
||||||
lines: jsonb("lines").default([]),
|
lines: jsonb("lines").default([]),
|
||||||
add_Date: timestamp("add_Date").defaultNow(),
|
add_Date: timestamp("add_Date").defaultNow(),
|
||||||
|
|||||||
34
backend/mobile/laneCheck.ts
Normal file
34
backend/mobile/laneCheck.ts
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import { Router } from "express";
|
||||||
|
import { runProdApi } from "../utils/prodEndpoint.utils.js";
|
||||||
|
import { apiReturn } from "../utils/returnHelper.utils.js";
|
||||||
|
|
||||||
|
const router = Router();
|
||||||
|
|
||||||
|
router.post("/", async (req, res) => {
|
||||||
|
const body = req.body;
|
||||||
|
|
||||||
|
const lane = body.lane.split("#");
|
||||||
|
|
||||||
|
console.log(lane[2]);
|
||||||
|
const laneData = await runProdApi({
|
||||||
|
method: "post",
|
||||||
|
endpoint: "/public/v1.1/Warehousing/GetWarehouseUnits",
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
laneIds: [lane[2]],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
return apiReturn(res, {
|
||||||
|
success: true,
|
||||||
|
level: "info",
|
||||||
|
module: "mobile",
|
||||||
|
subModule: "lane check",
|
||||||
|
message: `all data for lane Id: ${lane}`,
|
||||||
|
data: laneData?.data ?? [],
|
||||||
|
status: 200,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
export default router;
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { Express } from "express";
|
import type { Express } from "express";
|
||||||
import downloads from "./donwloadApps.route.js";
|
import downloads from "./donwloadApps.route.js";
|
||||||
|
import lanes from "./laneCheck.js";
|
||||||
import authPin from "./mobileAuth.route.js";
|
import authPin from "./mobileAuth.route.js";
|
||||||
import newPin from "./mobilePin.route.js";
|
import newPin from "./mobilePin.route.js";
|
||||||
import logs from "./scanLogs.route.js";
|
import logs from "./scanLogs.route.js";
|
||||||
@@ -12,6 +13,7 @@ export const setupMobileRoutes = (baseUrl: string, app: Express) => {
|
|||||||
app.use(`${baseUrl}/api/mobile/logs`, logs);
|
app.use(`${baseUrl}/api/mobile/logs`, logs);
|
||||||
app.use(`${baseUrl}/api/mobile/auth`, authPin);
|
app.use(`${baseUrl}/api/mobile/auth`, authPin);
|
||||||
app.use(`${baseUrl}/api/mobile/pin`, newPin);
|
app.use(`${baseUrl}/api/mobile/pin`, newPin);
|
||||||
|
app.use(`${baseUrl}/api/mobile/laneCheck`, lanes);
|
||||||
|
|
||||||
// all other system should be under /api/system/*
|
// all other system should be under /api/system/*
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -263,6 +263,10 @@ r.patch("/user/:id", requireAuth, async (req, res) => {
|
|||||||
updates.active = req.body.active;
|
updates.active = req.body.active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (req.body?.excludedCommand !== undefined) {
|
||||||
|
updates.excludedCommand = req.body.excludedCommand;
|
||||||
|
}
|
||||||
|
|
||||||
if (req.body?.role !== undefined) {
|
if (req.body?.role !== undefined) {
|
||||||
updates.role = req.body.role;
|
updates.role = req.body.role;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ router.post("/", async (req, res) => {
|
|||||||
commandDescription: body.commandDescription,
|
commandDescription: body.commandDescription,
|
||||||
status: body.status,
|
status: body.status,
|
||||||
lines: body.lines,
|
lines: body.lines,
|
||||||
|
user: body.user,
|
||||||
|
runningNumber: body.runningNumber,
|
||||||
})
|
})
|
||||||
.returning();
|
.returning();
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
"foregroundImage": "./assets/adaptive-icon-white.png",
|
"foregroundImage": "./assets/adaptive-icon-white.png",
|
||||||
"backgroundColor": "#ffffff"
|
"backgroundColor": "#ffffff"
|
||||||
},
|
},
|
||||||
"versionCode": 23,
|
"versionCode": 31,
|
||||||
"minSupportedVersionCode": 21,
|
"minSupportedVersionCode": 26,
|
||||||
"predictiveBackGestureEnabled": false,
|
"predictiveBackGestureEnabled": false,
|
||||||
"package": "net.alpla.lst.mobile"
|
"package": "net.alpla.lst.mobile"
|
||||||
},
|
},
|
||||||
|
|||||||
BIN
lstMobile/assets/sounds/scan.wav
Normal file
BIN
lstMobile/assets/sounds/scan.wav
Normal file
Binary file not shown.
5496
lstMobile/package-lock.json
generated
5496
lstMobile/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,7 @@
|
|||||||
"ios": "expo run:ios",
|
"ios": "expo run:ios",
|
||||||
"web": "expo start --web",
|
"web": "expo start --web",
|
||||||
"lint": "expo lint",
|
"lint": "expo lint",
|
||||||
"build:apk:clean": "expo prebuild --clean && cd android && gradlew.bat clean && gradlew.bat assembleRelease && npm run copy:apk",
|
"build:apk:clean": "expo prebuild --clean && cd android && gradlew.bat assembleRelease && npm run copy:apk",
|
||||||
"build:apk": "expo prebuild && cd android && gradlew.bat assembleRelease && npm run copy:apk",
|
"build:apk": "expo prebuild && cd android && gradlew.bat assembleRelease && npm run copy:apk",
|
||||||
"build:mobile": "cd scripts && node runBuild.ts",
|
"build:mobile": "cd scripts && node runBuild.ts",
|
||||||
"build:mobile:bump": "cd scripts && node runBuild.ts --bump",
|
"build:mobile:bump": "cd scripts && node runBuild.ts --bump",
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
"@react-navigation/bottom-tabs": "^7.15.5",
|
"@react-navigation/bottom-tabs": "^7.15.5",
|
||||||
"@react-navigation/elements": "^2.9.10",
|
"@react-navigation/elements": "^2.9.10",
|
||||||
"@react-navigation/native": "^7.1.33",
|
"@react-navigation/native": "^7.1.33",
|
||||||
|
"@rn-primitives/dialog": "^1.4.0",
|
||||||
"@rn-primitives/portal": "^1.4.0",
|
"@rn-primitives/portal": "^1.4.0",
|
||||||
"@rn-primitives/separator": "^1.4.0",
|
"@rn-primitives/separator": "^1.4.0",
|
||||||
"@rn-primitives/slot": "^1.4.0",
|
"@rn-primitives/slot": "^1.4.0",
|
||||||
@@ -56,10 +57,11 @@
|
|||||||
"react-dom": "19.2.0",
|
"react-dom": "19.2.0",
|
||||||
"react-native": "0.83.4",
|
"react-native": "0.83.4",
|
||||||
"react-native-gesture-handler": "~2.30.0",
|
"react-native-gesture-handler": "~2.30.0",
|
||||||
"react-native-reanimated": "^4.2.1",
|
"react-native-reanimated": "4.2.1",
|
||||||
"react-native-safe-area-context": "~5.6.2",
|
"react-native-safe-area-context": "~5.6.2",
|
||||||
"react-native-screens": "~4.23.0",
|
"react-native-screens": "~4.23.0",
|
||||||
"react-native-tcp-socket": "^6.4.1",
|
"react-native-tcp-socket": "^6.4.1",
|
||||||
|
"react-native-toast-message": "^2.3.3",
|
||||||
"react-native-web": "~0.21.0",
|
"react-native-web": "~0.21.0",
|
||||||
"react-native-worklets": "0.7.2",
|
"react-native-worklets": "0.7.2",
|
||||||
"socket.io-client": "^4.8.3",
|
"socket.io-client": "^4.8.3",
|
||||||
|
|||||||
@@ -1,9 +1,34 @@
|
|||||||
import { Tabs } from "expo-router";
|
import { Redirect, Tabs } from "expo-router";
|
||||||
import { Home, Settings } from "lucide-react-native";
|
import { Container, Home, Logs, Rows4, Settings } from "lucide-react-native";
|
||||||
import { useAppStore } from "../../hooks/useAppStore";
|
import { useAppStore } from "../../hooks/useAppStore";
|
||||||
|
import { useMobileAuthStore } from "../../hooks/useMobileAuth";
|
||||||
|
|
||||||
|
// const roles = {
|
||||||
|
// adminOnly: ["admin"],
|
||||||
|
// management: ["admin", "manager"],
|
||||||
|
// allStaff: ["admin", "manager", "driver", "lead", "user"],
|
||||||
|
// };
|
||||||
|
|
||||||
export default function TabsLayout() {
|
export default function TabsLayout() {
|
||||||
const serverPort = useAppStore((s) => s.serverPort);
|
const serverPort = useAppStore((s) => s.serverPort);
|
||||||
|
const user = useMobileAuthStore((s) => s.user);
|
||||||
|
const isUnlocked = useMobileAuthStore((s) => s.isUnlocked);
|
||||||
|
|
||||||
|
const port = parseInt(serverPort || "0", 10) >= 50000;
|
||||||
|
console.log(port);
|
||||||
|
if (!port) {
|
||||||
|
if (!user || !isUnlocked) {
|
||||||
|
return <Redirect href="/login" />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const isNormalScanner = parseInt(serverPort || "0", 10) >= 50000;
|
||||||
|
|
||||||
|
const hasRole = (allowed: string[] = []) => {
|
||||||
|
const role = user?.role?.toLowerCase();
|
||||||
|
return role ? allowed.includes(role) : false;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tabs
|
<Tabs
|
||||||
screenOptions={{
|
screenOptions={{
|
||||||
@@ -27,11 +52,24 @@ export default function TabsLayout() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Tabs.Screen
|
<Tabs.Screen
|
||||||
name="config"
|
name="laneCheck"
|
||||||
options={{
|
options={{
|
||||||
title: "settings",
|
title: "Lane Check",
|
||||||
|
|
||||||
|
href: isNormalScanner ? null : "/(tabs)/laneCheck",
|
||||||
|
tabBarIcon: ({ color, size }) => <Rows4 size={size} color={color} />,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Tabs.Screen
|
||||||
|
name="dockScan"
|
||||||
|
options={{
|
||||||
|
title: "Dock scan",
|
||||||
|
href:
|
||||||
|
isNormalScanner || !hasRole(["admin", "manager"])
|
||||||
|
? null
|
||||||
|
: "/(tabs)/dockScan",
|
||||||
tabBarIcon: ({ color, size }) => (
|
tabBarIcon: ({ color, size }) => (
|
||||||
<Settings size={size} color={color} />
|
<Container size={size} color={color} />
|
||||||
),
|
),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -40,7 +78,10 @@ export default function TabsLayout() {
|
|||||||
options={{
|
options={{
|
||||||
title: "Logs",
|
title: "Logs",
|
||||||
href:
|
href:
|
||||||
parseInt(serverPort || "0", 10) >= 50000 ? null : "/(tabs)/logs",
|
isNormalScanner || !hasRole(["admin", "manager"])
|
||||||
|
? null
|
||||||
|
: "/(tabs)/logs",
|
||||||
|
tabBarIcon: ({ color, size }) => <Logs size={size} color={color} />,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/* <Tabs.Screen
|
{/* <Tabs.Screen
|
||||||
@@ -51,6 +92,15 @@ export default function TabsLayout() {
|
|||||||
parseInt(serverPort || "0", 10) >= 50000 ? null : "/(tabs)/logs",
|
parseInt(serverPort || "0", 10) >= 50000 ? null : "/(tabs)/logs",
|
||||||
}}
|
}}
|
||||||
/> */}
|
/> */}
|
||||||
|
<Tabs.Screen
|
||||||
|
name="config"
|
||||||
|
options={{
|
||||||
|
title: "settings",
|
||||||
|
tabBarIcon: ({ color, size }) => (
|
||||||
|
<Settings size={size} color={color} />
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import { Link } from "expo-router";
|
|
||||||
import { Text, View } from "react-native";
|
|
||||||
import Setup from "../setup";
|
import Setup from "../setup";
|
||||||
|
|
||||||
export default function SettingsTab() {
|
export default function SettingsTab() {
|
||||||
return <Setup />
|
return <Setup />;
|
||||||
}
|
}
|
||||||
|
|||||||
26
lstMobile/src/app/(tabs)/dockScan.tsx
Normal file
26
lstMobile/src/app/(tabs)/dockScan.tsx
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { Text, View } from "react-native";
|
||||||
|
import { Button } from "../../components/ui/button";
|
||||||
|
|
||||||
|
export default function LaneCheck() {
|
||||||
|
const getInfo = async () => {
|
||||||
|
const info = "ho";
|
||||||
|
|
||||||
|
console.log(info);
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
//justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
marginTop: 50,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text>Dock Scanning</Text>
|
||||||
|
<Button onPress={getInfo}>
|
||||||
|
<Text>Check info</Text>
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
210
lstMobile/src/app/(tabs)/laneCheck.tsx
Normal file
210
lstMobile/src/app/(tabs)/laneCheck.tsx
Normal file
@@ -0,0 +1,210 @@
|
|||||||
|
import axios from "axios";
|
||||||
|
import { format } from "date-fns-tz";
|
||||||
|
import { useFocusEffect } from "expo-router";
|
||||||
|
import type React from "react";
|
||||||
|
import { useCallback, useEffect, useState } from "react";
|
||||||
|
import { ScrollView, Text, View } from "react-native";
|
||||||
|
import { SafeAreaView } from "react-native-safe-area-context";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
import { GlobalFooter } from "../../components/UpdateFooter";
|
||||||
|
import { Button } from "../../components/ui/button";
|
||||||
|
import { Card, CardContent, CardHeader } from "../../components/ui/card";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
DialogTrigger,
|
||||||
|
} from "../../components/ui/dialog";
|
||||||
|
import { useAppStore } from "../../hooks/useAppStore";
|
||||||
|
import { scannerFeedback } from "../../lib/feedbackScan";
|
||||||
|
import { type ZebraScanResult, zebraScanner } from "../../lib/ZebraScanner";
|
||||||
|
|
||||||
|
const InfoRow = ({
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
}: {
|
||||||
|
label: string;
|
||||||
|
value: React.ReactNode;
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<View className="flex-row justify-between gap-4 py-2 border-b border-gray-200">
|
||||||
|
<Text className="text-sm text-gray-500">{label}</Text>
|
||||||
|
<Text className="text-sm font-medium text-gray-900 text-right flex-1">
|
||||||
|
{value}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function LaneCheck() {
|
||||||
|
const [units, setUnits] = useState<any>(null);
|
||||||
|
const serverIp = useAppStore((s) => s.serverIp);
|
||||||
|
|
||||||
|
const handleScan = useCallback(
|
||||||
|
async (scan: ZebraScanResult) => {
|
||||||
|
setUnits(null);
|
||||||
|
await scannerFeedback({
|
||||||
|
type: "scan",
|
||||||
|
sound: true,
|
||||||
|
vibrate: true,
|
||||||
|
led: true,
|
||||||
|
});
|
||||||
|
if (!scan.data.startsWith("loc")) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Scan error",
|
||||||
|
text2: "The last scan was not a lane please try again",
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const res = await axios.post(
|
||||||
|
`http://${serverIp.trim()}:3000/lst/api/mobile/lanecheck`,
|
||||||
|
{
|
||||||
|
lane: scan.data,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timeout: 5000,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (res.status === 200) {
|
||||||
|
setUnits(res.data);
|
||||||
|
Toast.show({
|
||||||
|
type: "info",
|
||||||
|
text1: "Lane Data",
|
||||||
|
text2: "All Loading Units from this lane will be listed below",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Lane Data",
|
||||||
|
text2: "Error getting lane data please try again",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[serverIp.trim],
|
||||||
|
);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
zebraScanner.startListening();
|
||||||
|
|
||||||
|
const sub = zebraScanner.addScanListener((scan) => {
|
||||||
|
//console.log("SCAN:", scan);
|
||||||
|
handleScan(scan);
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
sub.remove();
|
||||||
|
zebraScanner.stopListening();
|
||||||
|
//setUnits(null);
|
||||||
|
};
|
||||||
|
}, [handleScan]),
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
//justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
marginTop: 50,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{units ? (
|
||||||
|
// <SafeAreaView className={`flex-1 w-full items-center`}>
|
||||||
|
// <ScrollView className="w-full flex-1">
|
||||||
|
// <View className="flex items-center gap-2 w-full">
|
||||||
|
// {units.data?.map((i: any, index: any) => (
|
||||||
|
// <View key={`${i.runningNumber}-${index}`}>
|
||||||
|
// <Text>example</Text>
|
||||||
|
// </View>
|
||||||
|
// ))}
|
||||||
|
// </View>
|
||||||
|
// </ScrollView>
|
||||||
|
// </SafeAreaView>
|
||||||
|
<SafeAreaView className={`w-full items-center`}>
|
||||||
|
<View style={{ padding: 2 }}>
|
||||||
|
<Text>There Are {units.data.length} units in this lane</Text>
|
||||||
|
</View>
|
||||||
|
<ScrollView className="w-full" style={{ marginBottom: 20 }}>
|
||||||
|
<View>
|
||||||
|
{units.data.map((i, index) => (
|
||||||
|
<View
|
||||||
|
key={`${i.runningNumber}-${index}`}
|
||||||
|
style={{
|
||||||
|
justifyContent: "center",
|
||||||
|
margin: 2,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Dialog>
|
||||||
|
<DialogTrigger>
|
||||||
|
<Card
|
||||||
|
className="w-full"
|
||||||
|
style={{
|
||||||
|
borderColor:
|
||||||
|
i.state === "QualityBlocked" ? "red" : undefined,
|
||||||
|
borderWidth: 4,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CardContent>
|
||||||
|
<Text>
|
||||||
|
{i.articleId} - {i.articleName}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<Text>
|
||||||
|
Running Number: {i.runningNumber ?? "Non barcoded"}
|
||||||
|
</Text>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</DialogTrigger>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>
|
||||||
|
Details for Article {i.articleId}, Rn:
|
||||||
|
{i.runningNumber ?? "Non barcoded"}{" "}
|
||||||
|
</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
<InfoRow
|
||||||
|
label="Production Date"
|
||||||
|
value={format(i.productionDate, "MM/dd/yyyy HH:mm")}
|
||||||
|
/>
|
||||||
|
<InfoRow label="Quantity" value={i.quantity} />
|
||||||
|
{i.state === "QualityBlocked" && (
|
||||||
|
<InfoRow
|
||||||
|
label="Defect"
|
||||||
|
value={i.mainDefectGroupDescription}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{i.state === "QualityBlocked" && (
|
||||||
|
<InfoRow
|
||||||
|
label="Description"
|
||||||
|
value={i.mainDefectDescription}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
</View>
|
||||||
|
))}
|
||||||
|
</View>
|
||||||
|
</ScrollView>
|
||||||
|
</SafeAreaView>
|
||||||
|
) : (
|
||||||
|
<View className="mt-50">
|
||||||
|
<Text className="text-2xl text-center">
|
||||||
|
Please scan a lane to see all Units that are in the lane.
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
<View>
|
||||||
|
<GlobalFooter />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,28 +1,30 @@
|
|||||||
|
import { PortalHost } from "@rn-primitives/portal";
|
||||||
import { Stack } from "expo-router";
|
import { Stack } from "expo-router";
|
||||||
import { StatusBar } from "expo-status-bar";
|
import { StatusBar } from "expo-status-bar";
|
||||||
import "../../global.css";
|
import "../../global.css";
|
||||||
import { PortalHost } from "@rn-primitives/portal";
|
import { useEffect } from "react";
|
||||||
import { View } from "react-native";
|
import Toast from "react-native-toast-message";
|
||||||
|
import useDeviceLock from "../hooks/useDeviceCheck";
|
||||||
|
import { zebraScanner } from "../lib/ZebraScanner";
|
||||||
|
|
||||||
export default function RootLayout() {
|
export default function RootLayout() {
|
||||||
|
useDeviceLock();
|
||||||
|
useEffect(() => {
|
||||||
|
zebraScanner.ensureProfile();
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<StatusBar style="dark" />
|
<StatusBar style="dark" />
|
||||||
<Stack screenOptions={{ headerShown: false }}>
|
<Stack screenOptions={{ headerShown: false }}>
|
||||||
<Stack.Screen name="index" />
|
<Stack.Screen name="index" />
|
||||||
<View className="items-center">
|
<Stack.Screen name="login" />
|
||||||
<Stack.Screen
|
<Stack.Screen name="setup" />
|
||||||
name="(tabs)"
|
<Stack.Screen name="updateScreen" />
|
||||||
options={{
|
<Stack.Screen name="(tabs)" />
|
||||||
title: "Pending update",
|
|
||||||
headerStyle: {
|
|
||||||
backgroundColor: "lightblue",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
<PortalHost />
|
<PortalHost />
|
||||||
|
<Toast />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,127 +1,31 @@
|
|||||||
import axios from "axios";
|
import { Redirect } from "expo-router";
|
||||||
import Constants from "expo-constants";
|
|
||||||
import { Redirect, useRouter } from "expo-router";
|
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
import { ActivityIndicator, Text, View } from "react-native";
|
import { ActivityIndicator, Text, View } from "react-native";
|
||||||
import { useAppStore } from "../hooks/useAppStore";
|
import { useAppStartup } from "../hooks/useAppStartup";
|
||||||
import { useMobileAuthStore } from "../hooks/useMobileAuth";
|
|
||||||
import { useServerStore } from "../hooks/useServerCheck";
|
const startupMessages = {
|
||||||
import { devDelay } from "../lib/devMode";
|
loading: "Loading app...",
|
||||||
|
validating: "Validating data...",
|
||||||
|
scannerMode: "Checking scanner mode...",
|
||||||
|
normalScanner: "Starting normal ALPLAprod scanner that has no LST rules",
|
||||||
|
checkingUpdates: "Checking for updates...",
|
||||||
|
opening: "Opening LST scan app...",
|
||||||
|
error: "Something went wrong during startup.",
|
||||||
|
};
|
||||||
|
|
||||||
export default function Index() {
|
export default function Index() {
|
||||||
const router = useRouter();
|
const { ready, startupRoute, status } = useAppStartup();
|
||||||
const [message, setMessage] = useState(<Text>Starting app...</Text>);
|
|
||||||
const [ready, setReady] = useState(false);
|
|
||||||
const setServerVersion = useServerStore((s) => s.setServerVersion);
|
|
||||||
//const { isUnlocked } = useMobileAuthStore();
|
|
||||||
|
|
||||||
const hasHydrated = useAppStore((s) => s.hasHydrated);
|
if (ready && startupRoute) {
|
||||||
const serverPort = useAppStore((s) => s.serverPort);
|
return <Redirect href={startupRoute as any} />;
|
||||||
const serverIp = useAppStore((s) => s.serverIp);
|
|
||||||
const build = Constants.expoConfig?.android?.versionCode ?? 1;
|
|
||||||
const hasValidSetup = useAppStore((s) => s.hasValidSetup);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!hasHydrated) {
|
|
||||||
setMessage(<Text>Loading app...</Text>);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const startup = async () => {
|
|
||||||
try {
|
|
||||||
await devDelay(1500);
|
|
||||||
|
|
||||||
setMessage(<Text>Validating data...</Text>);
|
|
||||||
await devDelay(1500);
|
|
||||||
|
|
||||||
if (!hasValidSetup()) {
|
|
||||||
router.replace("/setup");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// checking for lst.
|
|
||||||
console.log(
|
|
||||||
`http://${serverIp}:${parseInt(serverPort || "0", 10) >= 50000 ? "3000" : serverPort}/lst/api/mobile/version`,
|
|
||||||
);
|
|
||||||
try {
|
|
||||||
const res = await axios.get(
|
|
||||||
`http://${serverIp}:${parseInt(serverPort || "0", 10) >= 50000 ? "3000" : serverPort}/lst/api/mobile/version`,
|
|
||||||
{
|
|
||||||
timeout: 5000,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(res.data);
|
|
||||||
|
|
||||||
// if the build version dose not match the latest server version force update
|
|
||||||
if (res.status === 200) {
|
|
||||||
setServerVersion(res.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: change the header to show orange and theres a new version
|
|
||||||
// console.log(build < res.data.minSupportedVersionCode);
|
|
||||||
// if (build < res.data.minSupportedVersionCode) {
|
|
||||||
// router.replace("/updateScreen");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
} catch (error) {
|
|
||||||
console.log("Error: ", error);
|
|
||||||
}
|
|
||||||
|
|
||||||
setMessage(<Text>Checking scanner mode...</Text>);
|
|
||||||
await devDelay(1500);
|
|
||||||
|
|
||||||
if (parseInt(serverPort || "0", 10) >= 50000) {
|
|
||||||
setMessage(
|
|
||||||
<Text>
|
|
||||||
Starting normal alplaprod scanner that has no LST rules
|
|
||||||
</Text>,
|
|
||||||
);
|
|
||||||
await devDelay(1500);
|
|
||||||
//router.replace("/scanner");
|
|
||||||
setReady(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setMessage(<Text>Checking for updates</Text>);
|
|
||||||
await devDelay(1500);
|
|
||||||
// TODO if theres an update go to update screen message :D
|
|
||||||
setMessage(<Text>Opening LST scan app</Text>);
|
|
||||||
await devDelay(3250);
|
|
||||||
|
|
||||||
setReady(true);
|
|
||||||
} catch (error) {
|
|
||||||
console.log("Startup error", error);
|
|
||||||
setMessage(<Text>Something went wrong during startup.</Text>);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
startup();
|
|
||||||
}, [
|
|
||||||
hasHydrated,
|
|
||||||
hasValidSetup,
|
|
||||||
serverPort,
|
|
||||||
serverIp,
|
|
||||||
router,
|
|
||||||
setServerVersion,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// if (ready && !isUnlocked) {
|
|
||||||
// return <Redirect href={"/login"} />;
|
|
||||||
// }
|
|
||||||
if (ready) {
|
|
||||||
return <Redirect href="/(tabs)/scanner" />;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ready) {
|
||||||
|
return <Redirect href="/login" />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
|
||||||
style={{
|
<Text>{startupMessages[status]}</Text>
|
||||||
flex: 1,
|
|
||||||
justifyContent: "center",
|
|
||||||
alignItems: "center",
|
|
||||||
marginTop: 12,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{message}
|
|
||||||
<ActivityIndicator size="large" />
|
<ActivityIndicator size="large" />
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,27 +1,60 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import Constants from "expo-constants";
|
|
||||||
import { useRouter } from "expo-router";
|
import { useRouter } from "expo-router";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Alert, Button, Text, View } from "react-native";
|
import { Alert, Button, Text, View } from "react-native";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
import { Input } from "../components/ui/input";
|
import { Input } from "../components/ui/input";
|
||||||
import { useAppStore } from "../hooks/useAppStore";
|
import { useAppStore } from "../hooks/useAppStore";
|
||||||
import { useMobileAuthStore } from "../hooks/useMobileAuth";
|
import { useMobileAuthStore } from "../hooks/useMobileAuth";
|
||||||
|
|
||||||
|
const formatName = (name?: string) =>
|
||||||
|
name ? name.charAt(0).toUpperCase() + name.slice(1).toLowerCase() : "";
|
||||||
|
|
||||||
export default function Login() {
|
export default function Login() {
|
||||||
const { setUser } = useMobileAuthStore();
|
// doing this causes rerender and sub
|
||||||
|
//const { setUser } = useMobileAuthStore();
|
||||||
|
const [pin, setPin] = useState("");
|
||||||
const serverPort = useAppStore((s) => s.serverPort);
|
const serverPort = useAppStore((s) => s.serverPort);
|
||||||
const serverIp = useAppStore((s) => s.serverIp);
|
const serverIp = useAppStore((s) => s.serverIp);
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
const onLogin = async () => {
|
const onLogin = async () => {
|
||||||
|
if (pin.length < 6) {
|
||||||
|
console.log("pin must be min 6 ");
|
||||||
|
}
|
||||||
|
console.log(pin);
|
||||||
try {
|
try {
|
||||||
const res = await axios.get(
|
const res = await axios.post(
|
||||||
`http://${serverIp}:${parseInt(serverPort || "0", 10) >= 50000 ? "3000" : serverPort}/lst/api/mobile/version`,
|
`http://${serverIp}:${parseInt(serverPort || "0", 10) >= 50000 ? "3000" : serverPort}/lst/api/mobile/auth/pin`,
|
||||||
|
{ pin },
|
||||||
|
|
||||||
{
|
{
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(res.data);
|
if (res.status === 200) {
|
||||||
} catch (error) {}
|
// this way to set the user is direct and basically a 1 shot
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: `Welcome back ${formatName(res.data.data.name)}`,
|
||||||
|
});
|
||||||
|
useMobileAuthStore.getState().setUser(res.data.data);
|
||||||
|
return router.replace("/(tabs)/scanner");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
//Alert.alert("Login Error", `Invalid pin please try again`);
|
||||||
|
|
||||||
|
Toast.show({ type: "error", text1: `Invalid pin please try again` });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const config = () => {
|
||||||
|
console.log("config");
|
||||||
|
return router.replace("/setup");
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -43,10 +76,21 @@ export default function Login() {
|
|||||||
keyboardType="number-pad"
|
keyboardType="number-pad"
|
||||||
textContentType="oneTimeCode"
|
textContentType="oneTimeCode"
|
||||||
placeholder="Pin number"
|
placeholder="Pin number"
|
||||||
|
onChangeText={setPin}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<Button title="Login" onPress={onLogin} />
|
<View>
|
||||||
|
<Text className="p-3">
|
||||||
|
Warning: If you are logged into another scanner you will encounter
|
||||||
|
scan errors, please do not try to log into more than 1 scanner at a
|
||||||
|
time.
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
<View className="flex gap-2 flex-row">
|
||||||
|
<Button title="Login" onPress={onLogin} />
|
||||||
|
<Button title="Config" onPress={config} />
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import Constants from "expo-constants";
|
|||||||
import { useRouter } from "expo-router";
|
import { useRouter } from "expo-router";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Alert, Button, Text, TextInput, View } from "react-native";
|
import { Alert, Button, Text, TextInput, View } from "react-native";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
import { useAppStore } from "../hooks/useAppStore";
|
import { useAppStore } from "../hooks/useAppStore";
|
||||||
import { useServerStore } from "../hooks/useServerCheck";
|
import { useServerStore } from "../hooks/useServerCheck";
|
||||||
|
|
||||||
@@ -25,18 +26,29 @@ export default function Setup() {
|
|||||||
|
|
||||||
const server = useServerStore((s) => s.serverVersion);
|
const server = useServerStore((s) => s.serverVersion);
|
||||||
|
|
||||||
|
// TODO: if on lst version and the user is manager or admin just login
|
||||||
|
|
||||||
const authCheck = () => {
|
const authCheck = () => {
|
||||||
if (pin === "6971") {
|
if (pin === "6971") {
|
||||||
setAuth(true);
|
setAuth(true);
|
||||||
} else {
|
} else {
|
||||||
Alert.alert("Incorrect pin entered please try again");
|
//Alert.alert("Incorrect pin entered please try again");
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Incorrect pin entered please try again",
|
||||||
|
});
|
||||||
setPin("");
|
setPin("");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (!serverIp.trim() || !serverPort.trim()) {
|
if (!serverIp.trim() || !serverPort.trim()) {
|
||||||
Alert.alert("Missing info", "Please fill in both fields.");
|
//Alert.alert("Missing info", "Please fill in both fields.");
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Missing info",
|
||||||
|
text2: "Please fill in both fields.",
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +60,12 @@ export default function Setup() {
|
|||||||
isRegistered: true,
|
isRegistered: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
Alert.alert("Saved", "Config saved to device.");
|
//Alert.alert("Saved", "Config saved to device.");
|
||||||
|
Toast.show({
|
||||||
|
type: "info",
|
||||||
|
text1: "Saved",
|
||||||
|
text2: "Config saved to device.",
|
||||||
|
});
|
||||||
//router.replace("/");
|
//router.replace("/");
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
@@ -151,7 +168,7 @@ export default function Setup() {
|
|||||||
marginTop: "auto",
|
marginTop: "auto",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
padding: 10,
|
padding: 10,
|
||||||
marginBottom: 12,
|
marginBottom: 50,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text className="text-sm color-[#312f2f]">
|
<Text className="text-sm color-[#312f2f]">
|
||||||
|
|||||||
@@ -1,51 +1,240 @@
|
|||||||
import { useCallback, useEffect } from "react";
|
import axios from "axios";
|
||||||
import { Text, View } from "react-native";
|
import { format } from "date-fns-tz";
|
||||||
|
import { useFocusEffect } from "expo-router";
|
||||||
|
import { useCallback, useEffect, useState } from "react";
|
||||||
|
import { Alert, Button, Text, View } from "react-native";
|
||||||
|
import { useAppStore } from "../hooks/useAppStore";
|
||||||
|
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";
|
||||||
|
import { Separator } from "./ui/separator";
|
||||||
|
|
||||||
import { zebraScanner } from "../lib/ZebraScanner";
|
const STX = "\x02";
|
||||||
|
const ETX = "\x03";
|
||||||
|
|
||||||
|
const formatName = (name?: string) =>
|
||||||
|
name ? name.charAt(0).toUpperCase() + name.slice(1).toLowerCase() : "";
|
||||||
|
|
||||||
export default function LSTScanner() {
|
export default function LSTScanner() {
|
||||||
const handleScan = useCallback(async (scan: any) => {
|
const user = useMobileAuthStore((s) => s.user);
|
||||||
console.log(scan);
|
const logout = useMobileAuthStore((s) => s.logout);
|
||||||
}, []);
|
|
||||||
|
// TODO : move to off tcp stuff after od
|
||||||
|
const lastScan = useScannerStore((s) => s.lastScan);
|
||||||
|
const setLastScan = useScannerStore((s) => s.setLastScan);
|
||||||
|
const [tagScans, setTagScans] = useState<any>([]);
|
||||||
|
const scannerIdFromStore = useAppStore((s) => s.scannerId);
|
||||||
|
const serverIp = useAppStore((s) => s.serverIp);
|
||||||
|
const serverPort = useAppStore((s) => s.serverPort);
|
||||||
|
const [bgColor, setBGColor] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const handleScan = useCallback(
|
||||||
|
async (scan: ZebraScanResult) => {
|
||||||
|
await scannerFeedback({
|
||||||
|
type: "scan",
|
||||||
|
sound: true,
|
||||||
|
vibrate: true,
|
||||||
|
led: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const isAlphaStart = /^[a-zA-Z]/.test(scan.data);
|
||||||
|
const isExcluded = (user?.excludedCommand ?? []).some((cmd) =>
|
||||||
|
scan.data.toLowerCase().includes(cmd.toLowerCase()),
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(user?.excludedCommand);
|
||||||
|
|
||||||
|
if (isAlphaStart && isExcluded) {
|
||||||
|
Alert.alert(
|
||||||
|
"Command not allowed",
|
||||||
|
`Command: ${scan.data}\n\nPlease contact logistics if this is an error`,
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let commandToSend = `${STX}${user?.scannerId}@${scan.data}${ETX}`;
|
||||||
|
|
||||||
|
// if we are sscc we need to scan like this .... <STX>98@]C100090087710038712256<ETX>
|
||||||
|
if (scan.data.startsWith("000")) {
|
||||||
|
commandToSend = `${STX}${user?.scannerId}@]C1${scan.data}${ETX}`;
|
||||||
|
setTagScans((prev: any) => [
|
||||||
|
{
|
||||||
|
label: parseInt(scan.data.slice(10, -1) || "000", 10).toString(),
|
||||||
|
date: format(new Date(Date.now()), "HH:mm"),
|
||||||
|
},
|
||||||
|
...prev,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const scanned = (await sendTcpMessage(
|
||||||
|
commandToSend,
|
||||||
|
serverIp,
|
||||||
|
50004,
|
||||||
|
)) as any;
|
||||||
|
|
||||||
|
// send the logs to lst but allow it to time out if it dose not exist just bc.
|
||||||
|
|
||||||
|
try {
|
||||||
|
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()
|
||||||
|
: scan.data.startsWith("loc")
|
||||||
|
? scan.data
|
||||||
|
: "0",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
// const response = await sendTcpMessage(tcpMessage);
|
||||||
|
console.log(scanned.data);
|
||||||
|
if (scanned.data.status !== "error") {
|
||||||
|
await scannerFeedback({
|
||||||
|
type: "good",
|
||||||
|
sound: true,
|
||||||
|
vibrate: true,
|
||||||
|
led: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
setBGColor("bg-green-500");
|
||||||
|
|
||||||
|
// version check
|
||||||
|
versionCheck();
|
||||||
|
|
||||||
|
// auth update
|
||||||
|
useMobileAuthStore.getState().updateLastScan();
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
setBGColor(null);
|
||||||
|
}, 1 * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scanned.data.status === "error") {
|
||||||
|
await scannerFeedback({
|
||||||
|
type: scanned.data.status === "error" ? "bad" : "good",
|
||||||
|
sound: true,
|
||||||
|
vibrate: true,
|
||||||
|
led: true,
|
||||||
|
});
|
||||||
|
setBGColor("bg-red-500");
|
||||||
|
setTimeout(() => {
|
||||||
|
setBGColor(null);
|
||||||
|
}, 1 * 1000);
|
||||||
|
}
|
||||||
|
setLastScan(scanned.data);
|
||||||
|
|
||||||
|
// if we change commands we want to zero out the last scanned labels
|
||||||
|
if (isAlphaStart) {
|
||||||
|
setTagScans([]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[
|
||||||
|
serverIp,
|
||||||
|
setLastScan,
|
||||||
|
user?.scannerId,
|
||||||
|
user?.name,
|
||||||
|
user?.excludedCommand?.some,
|
||||||
|
user?.excludedCommand,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
const clearScans = () => {
|
const clearScans = () => {
|
||||||
// add in
|
setTagScans([]);
|
||||||
};
|
};
|
||||||
|
|
||||||
//console.log(lastScan);
|
//console.log(lastScan);
|
||||||
|
|
||||||
useEffect(() => {
|
useFocusEffect(
|
||||||
zebraScanner.ensureProfile();
|
useCallback(() => {
|
||||||
zebraScanner.startListening();
|
zebraScanner.startListening();
|
||||||
|
|
||||||
const sub = zebraScanner.addScanListener((scan) => {
|
const sub = zebraScanner.addScanListener((scan) => {
|
||||||
//console.log("SCAN:", scan);
|
//console.log("SCAN:", scan);
|
||||||
handleScan(scan);
|
handleScan(scan);
|
||||||
});
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
sub.remove();
|
sub.remove();
|
||||||
zebraScanner.stopListening();
|
zebraScanner.stopListening();
|
||||||
};
|
};
|
||||||
}, [handleScan]);
|
}, [handleScan]),
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<View>
|
<View className={`${bgColor ?? ""} flex-1 w-screen`}>
|
||||||
<View style={{ alignItems: "center", margin: 10 }}>
|
<View style={{ alignItems: "center", margin: 5 }}>
|
||||||
<Text style={{ fontSize: 20, fontWeight: "600" }}>LST Scanner</Text>
|
<Text style={{ fontSize: 14, fontWeight: "600" }}>
|
||||||
|
User: {formatName(user?.name ?? "")}
|
||||||
|
</Text>
|
||||||
|
<Text style={{ fontSize: 18, fontWeight: "600" }}>
|
||||||
|
LST Scanner id: {user?.scannerId}
|
||||||
|
</Text>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
marginTop: 5,
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{!lastScan ? (
|
||||||
|
<View style={{ marginTop: 10, alignItems: "center" }}>
|
||||||
|
<Text className="text-xl font-bold">Ready to scan</Text>
|
||||||
|
<Text>Waiting for first scan...</Text>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
marginTop: 10,
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{lastScan.lines
|
||||||
|
?.filter((line) => !/^\d+@$/.test(line))
|
||||||
|
.map((i) => {
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
style={{ marginTop: 10, alignItems: "center" }}
|
||||||
|
key={i}
|
||||||
|
>
|
||||||
|
<Text style={{ fontSize: 18, fontWeight: "600" }}>
|
||||||
|
{i}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View
|
<Separator className="m-2" />
|
||||||
style={{
|
<View className="flex-1 w-full px-4">
|
||||||
marginTop: 50,
|
<ScannedLabelBox
|
||||||
alignItems: "center",
|
labels={tagScans}
|
||||||
}}
|
color={bgColor}
|
||||||
>
|
clearScan={clearScans}
|
||||||
<Text>Relocate</Text>
|
/>
|
||||||
<Text>0 / 4</Text>
|
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* <View>
|
<View className="m-2">
|
||||||
<Text>List of recent scanned pallets TBA</Text>
|
{user && (
|
||||||
</View> */}
|
<View className="items-center">
|
||||||
|
<Button title="Logout" onPress={logout} />
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
<View>
|
||||||
|
<GlobalFooter />
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { format } from "date-fns-tz";
|
import { format } from "date-fns-tz";
|
||||||
|
import { useFocusEffect } from "expo-router";
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import { Text, View } from "react-native";
|
import { Text, View } from "react-native";
|
||||||
import { useAppStore } from "../hooks/useAppStore";
|
import { useAppStore } from "../hooks/useAppStore";
|
||||||
|
import { useMobileAuthStore } from "../hooks/useMobileAuth";
|
||||||
import { useScannerStore } from "../hooks/useScannerStore";
|
import { useScannerStore } from "../hooks/useScannerStore";
|
||||||
import { scannerFeedback } from "../lib/feedbackScan";
|
import { scannerFeedback } from "../lib/feedbackScan";
|
||||||
import { sendTcpMessage } from "../lib/tcpScan";
|
import { sendTcpMessage } from "../lib/tcpScan";
|
||||||
|
import { versionCheck } from "../lib/versionValidation";
|
||||||
import { type ZebraScanResult, zebraScanner } from "../lib/ZebraScanner";
|
import { type ZebraScanResult, zebraScanner } from "../lib/ZebraScanner";
|
||||||
import { ScannedLabelBox } from "./ScannedLabels";
|
import { ScannedLabelBox } from "./ScannedLabels";
|
||||||
import { GlobalFooter } from "./UpdateFooter";
|
import { GlobalFooter } from "./UpdateFooter";
|
||||||
@@ -25,6 +28,13 @@ export default function ProdScanner() {
|
|||||||
|
|
||||||
const handleScan = useCallback(
|
const handleScan = useCallback(
|
||||||
async (scan: ZebraScanResult) => {
|
async (scan: ZebraScanResult) => {
|
||||||
|
await scannerFeedback({
|
||||||
|
type: "scan",
|
||||||
|
sound: true,
|
||||||
|
vibrate: true,
|
||||||
|
led: true,
|
||||||
|
});
|
||||||
|
|
||||||
let commandToSend = `${STX}${scannerIdFromStore}@${scan.data}${ETX}`;
|
let commandToSend = `${STX}${scannerIdFromStore}@${scan.data}${ETX}`;
|
||||||
|
|
||||||
// if we are sscc we need to scan like this .... <STX>98@]C100090087710038712256<ETX>
|
// if we are sscc we need to scan like this .... <STX>98@]C100090087710038712256<ETX>
|
||||||
@@ -45,11 +55,18 @@ export default function ProdScanner() {
|
|||||||
parseInt(serverPort || "0", 10),
|
parseInt(serverPort || "0", 10),
|
||||||
)) as any;
|
)) as any;
|
||||||
// send the logs to lst but allow it to time out if it dose not exist just bc.
|
// send the logs to lst but allow it to time out if it dose not exist just bc.
|
||||||
|
const data = {
|
||||||
|
...scanned.data,
|
||||||
|
runningNumber: scan.data.startsWith("000")
|
||||||
|
? parseInt(scan.data.slice(10, -1) || "000", 10).toString()
|
||||||
|
: scan.data.startsWith("loc")
|
||||||
|
? scan.data
|
||||||
|
: "0",
|
||||||
|
};
|
||||||
try {
|
try {
|
||||||
await axios.post(
|
await axios.post(
|
||||||
`http://${serverIp.trim()}:3000/lst/api/mobile/logs`,
|
`http://${serverIp.trim()}:3000/lst/api/mobile/logs`,
|
||||||
scanned,
|
data,
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
@@ -64,6 +81,13 @@ export default function ProdScanner() {
|
|||||||
led: true,
|
led: true,
|
||||||
});
|
});
|
||||||
setBGColor("bg-green-500");
|
setBGColor("bg-green-500");
|
||||||
|
|
||||||
|
// version check
|
||||||
|
versionCheck();
|
||||||
|
|
||||||
|
// auth update
|
||||||
|
useMobileAuthStore.getState().updateLastScan();
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setBGColor(null);
|
setBGColor(null);
|
||||||
}, 1 * 1000);
|
}, 1 * 1000);
|
||||||
@@ -97,20 +121,21 @@ export default function ProdScanner() {
|
|||||||
|
|
||||||
//console.log(lastScan);
|
//console.log(lastScan);
|
||||||
|
|
||||||
useEffect(() => {
|
useFocusEffect(
|
||||||
zebraScanner.ensureProfile();
|
useCallback(() => {
|
||||||
zebraScanner.startListening();
|
zebraScanner.startListening();
|
||||||
|
|
||||||
const sub = zebraScanner.addScanListener((scan) => {
|
const sub = zebraScanner.addScanListener((scan) => {
|
||||||
//console.log("SCAN:", scan);
|
//console.log("SCAN:", scan);
|
||||||
handleScan(scan);
|
handleScan(scan);
|
||||||
});
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
sub.remove();
|
sub.remove();
|
||||||
zebraScanner.stopListening();
|
zebraScanner.stopListening();
|
||||||
};
|
};
|
||||||
}, [handleScan]);
|
}, [handleScan]),
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<View className={`${bgColor ?? ""} flex-1 w-screen`}>
|
<View className={`${bgColor ?? ""} flex-1 w-screen`}>
|
||||||
<View>
|
<View>
|
||||||
|
|||||||
140
lstMobile/src/components/ui/dialog.tsx
Normal file
140
lstMobile/src/components/ui/dialog.tsx
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
import { Icon } from '@/components/ui/icon';
|
||||||
|
import { NativeOnlyAnimatedView } from '@/components/ui/native-only-animated-view';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
import * as DialogPrimitive from '@rn-primitives/dialog';
|
||||||
|
import { X } from 'lucide-react-native';
|
||||||
|
import * as React from 'react';
|
||||||
|
import { Platform, Text, View, type ViewProps } from 'react-native';
|
||||||
|
import { FadeIn, FadeOut } from 'react-native-reanimated';
|
||||||
|
import { FullWindowOverlay as RNFullWindowOverlay } from 'react-native-screens';
|
||||||
|
|
||||||
|
const Dialog = DialogPrimitive.Root;
|
||||||
|
|
||||||
|
const DialogTrigger = DialogPrimitive.Trigger;
|
||||||
|
|
||||||
|
const DialogPortal = DialogPrimitive.Portal;
|
||||||
|
|
||||||
|
const DialogClose = DialogPrimitive.Close;
|
||||||
|
|
||||||
|
const FullWindowOverlay = Platform.OS === 'ios' ? RNFullWindowOverlay : React.Fragment;
|
||||||
|
|
||||||
|
function DialogOverlay({
|
||||||
|
className,
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}: Omit<React.ComponentProps<typeof DialogPrimitive.Overlay>, 'asChild'> & {
|
||||||
|
children?: React.ReactNode;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<FullWindowOverlay>
|
||||||
|
<DialogPrimitive.Overlay
|
||||||
|
className={cn(
|
||||||
|
'absolute bottom-0 left-0 right-0 top-0 flex items-center justify-center bg-black/50 p-2',
|
||||||
|
Platform.select({
|
||||||
|
web: 'animate-in fade-in-0 fixed cursor-default [&>*]:cursor-auto',
|
||||||
|
}),
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
asChild={Platform.OS !== 'web'}>
|
||||||
|
<NativeOnlyAnimatedView entering={FadeIn.duration(200)} exiting={FadeOut.duration(150)}>
|
||||||
|
<NativeOnlyAnimatedView entering={FadeIn.delay(50)} exiting={FadeOut.duration(150)}>
|
||||||
|
<>{children}</>
|
||||||
|
</NativeOnlyAnimatedView>
|
||||||
|
</NativeOnlyAnimatedView>
|
||||||
|
</DialogPrimitive.Overlay>
|
||||||
|
</FullWindowOverlay>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
function DialogContent({
|
||||||
|
className,
|
||||||
|
portalHost,
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
||||||
|
portalHost?: string;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<DialogPortal hostName={portalHost}>
|
||||||
|
<DialogOverlay>
|
||||||
|
<DialogPrimitive.Content
|
||||||
|
className={cn(
|
||||||
|
'bg-background border-border z-50 mx-auto flex w-full max-w-[calc(100%-2rem)] flex-col gap-4 rounded-lg border p-6 shadow-lg shadow-black/5 sm:max-w-lg',
|
||||||
|
Platform.select({
|
||||||
|
web: 'animate-in fade-in-0 zoom-in-95 duration-200',
|
||||||
|
}),
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}>
|
||||||
|
<>{children}</>
|
||||||
|
<DialogPrimitive.Close
|
||||||
|
className={cn(
|
||||||
|
'absolute right-4 top-4 rounded opacity-70 active:opacity-100',
|
||||||
|
Platform.select({
|
||||||
|
web: 'ring-offset-background focus:ring-ring data-[state=open]:bg-accent transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-offset-2',
|
||||||
|
})
|
||||||
|
)}
|
||||||
|
hitSlop={12}>
|
||||||
|
<Icon
|
||||||
|
as={X}
|
||||||
|
className={cn('text-accent-foreground web:pointer-events-none size-4 shrink-0')}
|
||||||
|
/>
|
||||||
|
<Text className="sr-only">Close</Text>
|
||||||
|
</DialogPrimitive.Close>
|
||||||
|
</DialogPrimitive.Content>
|
||||||
|
</DialogOverlay>
|
||||||
|
</DialogPortal>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogHeader({ className, ...props }: ViewProps) {
|
||||||
|
return (
|
||||||
|
<View className={cn('flex flex-col gap-2 text-center sm:text-left', className)} {...props} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogFooter({ className, ...props }: ViewProps) {
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
className={cn('flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogTitle({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
||||||
|
return (
|
||||||
|
<DialogPrimitive.Title
|
||||||
|
className={cn('text-foreground text-lg font-semibold leading-none', className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogDescription({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
||||||
|
return (
|
||||||
|
<DialogPrimitive.Description
|
||||||
|
className={cn('text-muted-foreground text-sm', className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
Dialog,
|
||||||
|
DialogClose,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogOverlay,
|
||||||
|
DialogPortal,
|
||||||
|
DialogTitle,
|
||||||
|
DialogTrigger,
|
||||||
|
};
|
||||||
57
lstMobile/src/components/ui/icon.tsx
Normal file
57
lstMobile/src/components/ui/icon.tsx
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
import { TextClassContext } from '@/components/ui/text';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
import type { LucideIcon, LucideProps } from 'lucide-react-native';
|
||||||
|
import { cssInterop } from 'nativewind';
|
||||||
|
import * as React from 'react';
|
||||||
|
|
||||||
|
type IconProps = LucideProps & {
|
||||||
|
as: LucideIcon;
|
||||||
|
} & React.RefAttributes<LucideIcon>;
|
||||||
|
|
||||||
|
function IconImpl({ as: IconComponent, ...props }: IconProps) {
|
||||||
|
return <IconComponent {...props} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
cssInterop(IconImpl, {
|
||||||
|
className: {
|
||||||
|
target: 'style',
|
||||||
|
nativeStyleToProp: {
|
||||||
|
height: 'size',
|
||||||
|
width: 'size',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A wrapper component for Lucide icons with Nativewind `className` support via `cssInterop`.
|
||||||
|
*
|
||||||
|
* This component allows you to render any Lucide icon while applying utility classes
|
||||||
|
* using `nativewind`. It avoids the need to wrap or configure each icon individually.
|
||||||
|
*
|
||||||
|
* @component
|
||||||
|
* @example
|
||||||
|
* ```tsx
|
||||||
|
* import { ArrowRight } from 'lucide-react-native';
|
||||||
|
* import { Icon } from '@/registry/components/ui/icon';
|
||||||
|
*
|
||||||
|
* <Icon as={ArrowRight} className="text-red-500" size={16} />
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @param {LucideIcon} as - The Lucide icon component to render.
|
||||||
|
* @param {string} className - Utility classes to style the icon using Nativewind.
|
||||||
|
* @param {number} size - Icon size (defaults to 14).
|
||||||
|
* @param {...LucideProps} ...props - Additional Lucide icon props passed to the "as" icon.
|
||||||
|
*/
|
||||||
|
function Icon({ as: IconComponent, className, size = 14, ...props }: IconProps) {
|
||||||
|
const textClass = React.useContext(TextClassContext);
|
||||||
|
return (
|
||||||
|
<IconImpl
|
||||||
|
as={IconComponent}
|
||||||
|
className={cn('text-foreground', textClass, className)}
|
||||||
|
size={size}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Icon };
|
||||||
23
lstMobile/src/components/ui/native-only-animated-view.tsx
Normal file
23
lstMobile/src/components/ui/native-only-animated-view.tsx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { Platform } from 'react-native';
|
||||||
|
import Animated from 'react-native-reanimated';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This component is used to wrap animated views that should only be animated on native.
|
||||||
|
* @param props - The props for the animated view.
|
||||||
|
* @returns The animated view if the platform is native, otherwise the children.
|
||||||
|
* @example
|
||||||
|
* <NativeOnlyAnimatedView entering={FadeIn} exiting={FadeOut}>
|
||||||
|
* <Text>I am only animated on native</Text>
|
||||||
|
* </NativeOnlyAnimatedView>
|
||||||
|
*/
|
||||||
|
function NativeOnlyAnimatedView(
|
||||||
|
props: React.ComponentProps<typeof Animated.View> & React.RefAttributes<typeof Animated.View>
|
||||||
|
) {
|
||||||
|
if (Platform.OS === 'web') {
|
||||||
|
return <>{props.children as React.ReactNode}</>;
|
||||||
|
} else {
|
||||||
|
return <Animated.View {...props} />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { NativeOnlyAnimatedView };
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import * as Slot from '@rn-primitives/slot';
|
import { Slot } from '@rn-primitives/slot';
|
||||||
import { cva, type VariantProps } from 'class-variance-authority';
|
import { cva, type VariantProps } from 'class-variance-authority';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Platform, Text as RNText, type Role } from 'react-native';
|
import { Platform, Text as RNText, type Role } from 'react-native';
|
||||||
@@ -70,11 +70,12 @@ function Text({
|
|||||||
variant = 'default',
|
variant = 'default',
|
||||||
...props
|
...props
|
||||||
}: React.ComponentProps<typeof RNText> &
|
}: React.ComponentProps<typeof RNText> &
|
||||||
|
React.RefAttributes<typeof RNText> &
|
||||||
TextVariantProps & {
|
TextVariantProps & {
|
||||||
asChild?: boolean;
|
asChild?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const textClass = React.useContext(TextClassContext);
|
const textClass = React.useContext(TextClassContext);
|
||||||
const Component = asChild ? Slot.Text : RNText;
|
const Component = asChild ? Slot : RNText;
|
||||||
return (
|
return (
|
||||||
<Component
|
<Component
|
||||||
className={cn(textVariants({ variant }), textClass, className)}
|
className={cn(textVariants({ variant }), textClass, className)}
|
||||||
|
|||||||
111
lstMobile/src/hooks/useAppStartup.tsx
Normal file
111
lstMobile/src/hooks/useAppStartup.tsx
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
import axios from "axios";
|
||||||
|
import Constants from "expo-constants";
|
||||||
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
import { devDelay } from "../lib/devMode";
|
||||||
|
import { versionCheck } from "../lib/versionValidation";
|
||||||
|
import { useAppStore } from "./useAppStore";
|
||||||
|
import { useServerStore } from "./useServerCheck";
|
||||||
|
|
||||||
|
type StartupStatus =
|
||||||
|
| "loading"
|
||||||
|
| "validating"
|
||||||
|
| "scannerMode"
|
||||||
|
| "normalScanner"
|
||||||
|
| "checkingUpdates"
|
||||||
|
| "opening"
|
||||||
|
| "error";
|
||||||
|
|
||||||
|
export function useAppStartup() {
|
||||||
|
const [ready, setReady] = useState(false);
|
||||||
|
const [status, setStatus] = useState<StartupStatus>("loading");
|
||||||
|
const [startupRoute, setStartupRoute] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const hasRunKey = useRef<string | null>(null);
|
||||||
|
|
||||||
|
const hasHydrated = useAppStore((s) => s.hasHydrated);
|
||||||
|
const serverPort = useAppStore((s) => s.serverPort);
|
||||||
|
const serverIp = useAppStore((s) => s.serverIp);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!hasHydrated) {
|
||||||
|
setStatus("loading");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const runKey = `${serverIp}:${serverPort}`;
|
||||||
|
|
||||||
|
if (hasRunKey.current === runKey) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hasRunKey.current = runKey;
|
||||||
|
|
||||||
|
let cancelled = false;
|
||||||
|
|
||||||
|
const startup = async () => {
|
||||||
|
try {
|
||||||
|
setReady(false);
|
||||||
|
setStartupRoute(null);
|
||||||
|
|
||||||
|
await devDelay(1500);
|
||||||
|
if (cancelled) return;
|
||||||
|
|
||||||
|
setStatus("validating");
|
||||||
|
await devDelay(1500);
|
||||||
|
if (cancelled) return;
|
||||||
|
|
||||||
|
const hasValidSetup = useAppStore.getState().hasValidSetup;
|
||||||
|
|
||||||
|
if (!hasValidSetup()) {
|
||||||
|
setStartupRoute("/setup");
|
||||||
|
setReady(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await versionCheck();
|
||||||
|
|
||||||
|
setStatus("scannerMode");
|
||||||
|
await devDelay(1500);
|
||||||
|
if (cancelled) return;
|
||||||
|
|
||||||
|
if (parseInt(serverPort || "0", 10) >= 50000) {
|
||||||
|
setStatus("normalScanner");
|
||||||
|
await devDelay(1500);
|
||||||
|
|
||||||
|
setStartupRoute("/scanner");
|
||||||
|
setReady(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setStatus("checkingUpdates");
|
||||||
|
console.log("checking updates");
|
||||||
|
await devDelay(1500);
|
||||||
|
if (cancelled) return;
|
||||||
|
|
||||||
|
setStatus("opening");
|
||||||
|
console.log("opening");
|
||||||
|
await devDelay(1500);
|
||||||
|
if (cancelled) return;
|
||||||
|
|
||||||
|
setStartupRoute("/(tabs)/scanner");
|
||||||
|
console.log("scanner");
|
||||||
|
setReady(true);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Startup error:", error);
|
||||||
|
setStatus("error");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
startup();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
cancelled = true;
|
||||||
|
};
|
||||||
|
}, [hasHydrated, serverIp, serverPort]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
ready,
|
||||||
|
startupRoute,
|
||||||
|
status,
|
||||||
|
};
|
||||||
|
}
|
||||||
37
lstMobile/src/hooks/useDeviceCheck.tsx
Normal file
37
lstMobile/src/hooks/useDeviceCheck.tsx
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
import { AppState, type AppStateStatus } from "react-native";
|
||||||
|
import { useMobileAuthStore } from "./useMobileAuth";
|
||||||
|
|
||||||
|
export default function useDeviceLock() {
|
||||||
|
const [appState, setAppState] = useState<AppStateStatus>(
|
||||||
|
AppState.currentState,
|
||||||
|
);
|
||||||
|
const appStateRef = useRef<AppStateStatus>(AppState.currentState);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const subscription = AppState.addEventListener("change", (nextAppState) => {
|
||||||
|
const previousAppState = appStateRef.current;
|
||||||
|
|
||||||
|
const wasActive = previousAppState === "active";
|
||||||
|
|
||||||
|
// if the we see aggressive locking then we should remove inactive.
|
||||||
|
const isNowInactive =
|
||||||
|
nextAppState === "background" || nextAppState === "inactive";
|
||||||
|
|
||||||
|
if (wasActive && isNowInactive) {
|
||||||
|
const auth = useMobileAuthStore.getState();
|
||||||
|
|
||||||
|
if (auth.shouldLockForIdle()) {
|
||||||
|
auth.lock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
appStateRef.current = nextAppState;
|
||||||
|
setAppState(nextAppState);
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => subscription.remove();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return appState;
|
||||||
|
}
|
||||||
@@ -1,28 +1,52 @@
|
|||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
|
|
||||||
|
const ONE_HOUR = 1000 * 60 * 60;
|
||||||
|
|
||||||
type MobileUser = {
|
type MobileUser = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
role: "user" | "lead" | "manager" | "admin";
|
role: "user" | "lead" | "manager" | "admin";
|
||||||
excludedCommand: string[];
|
excludedCommand: string[];
|
||||||
|
scannerId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type AuthState = {
|
type AuthState = {
|
||||||
user: MobileUser | null;
|
user: MobileUser | null;
|
||||||
isUnlocked: boolean;
|
isUnlocked: boolean;
|
||||||
|
lastScanAt: number | null;
|
||||||
|
|
||||||
setUser: (user: MobileUser) => void;
|
setUser: (user: MobileUser) => void;
|
||||||
|
updateLastScan: () => void;
|
||||||
lock: () => void;
|
lock: () => void;
|
||||||
logout: () => void;
|
logout: () => void;
|
||||||
|
shouldLockForIdle: () => boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useMobileAuthStore = create<AuthState>((set) => ({
|
export const useMobileAuthStore = create<AuthState>((set, get) => ({
|
||||||
user: null,
|
user: null,
|
||||||
isUnlocked: false,
|
isUnlocked: false,
|
||||||
|
lastScanAt: null,
|
||||||
|
|
||||||
setUser: (user) => set({ user, isUnlocked: true }),
|
setUser: (user) =>
|
||||||
|
set({
|
||||||
|
user,
|
||||||
|
isUnlocked: true,
|
||||||
|
lastScanAt: Date.now(),
|
||||||
|
}),
|
||||||
|
updateLastScan: () => set({ lastScanAt: Date.now() }),
|
||||||
lock: () => set({ isUnlocked: false }),
|
lock: () => set({ isUnlocked: false }),
|
||||||
|
|
||||||
logout: () => set({ user: null, isUnlocked: false }),
|
logout: () =>
|
||||||
|
set({
|
||||||
|
user: null,
|
||||||
|
isUnlocked: false,
|
||||||
|
lastScanAt: null,
|
||||||
|
}),
|
||||||
|
shouldLockForIdle: () => {
|
||||||
|
const lastScanAt = get().lastScanAt;
|
||||||
|
|
||||||
|
if (!lastScanAt) return true;
|
||||||
|
|
||||||
|
return Date.now() - lastScanAt > ONE_HOUR;
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -37,4 +37,7 @@ export const zebraScanner = {
|
|||||||
): EmitterSubscription {
|
): EmitterSubscription {
|
||||||
return scannerEmitter.addListener("barcodeScanned", callback);
|
return scannerEmitter.addListener("barcodeScanned", callback);
|
||||||
},
|
},
|
||||||
|
disableScannerInput() {
|
||||||
|
ZebraScanner.disableScannerInput();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ import { createAudioPlayer } from "expo-audio";
|
|||||||
import * as Haptics from "expo-haptics";
|
import * as Haptics from "expo-haptics";
|
||||||
|
|
||||||
export type ScanFeedback = {
|
export type ScanFeedback = {
|
||||||
type: "good" | "bad";
|
type: "good" | "bad" | "scan";
|
||||||
sound?: boolean;
|
sound?: boolean;
|
||||||
vibrate?: boolean;
|
vibrate?: boolean;
|
||||||
led?: boolean;
|
led?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const scan = createAudioPlayer(require("../../assets/sounds/scan.wav"));
|
||||||
const goodSound = createAudioPlayer(require("../../assets/sounds/good.wav"));
|
const goodSound = createAudioPlayer(require("../../assets/sounds/good.wav"));
|
||||||
const badSound = createAudioPlayer(require("../../assets/sounds/bad.wav"));
|
const badSound = createAudioPlayer(require("../../assets/sounds/bad.wav"));
|
||||||
|
|
||||||
@@ -18,14 +19,15 @@ export async function scannerFeedback({
|
|||||||
led = true,
|
led = true,
|
||||||
}: ScanFeedback) {
|
}: ScanFeedback) {
|
||||||
if (sound) {
|
if (sound) {
|
||||||
const player = type === "good" ? goodSound : badSound;
|
const player =
|
||||||
|
type === "scan" ? scan : type === "good" ? goodSound : badSound;
|
||||||
player.seekTo(0);
|
player.seekTo(0);
|
||||||
player.play();
|
player.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vibrate) {
|
if (vibrate) {
|
||||||
await Haptics.notificationAsync(
|
await Haptics.notificationAsync(
|
||||||
type === "good"
|
type === "good" || type === "scan"
|
||||||
? Haptics.NotificationFeedbackType.Success
|
? Haptics.NotificationFeedbackType.Success
|
||||||
: Haptics.NotificationFeedbackType.Error,
|
: Haptics.NotificationFeedbackType.Error,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,43 +1,73 @@
|
|||||||
|
import axios from "axios";
|
||||||
|
import { useAppStore } from "../hooks/useAppStore";
|
||||||
|
import { useServerStore } from "../hooks/useServerCheck";
|
||||||
|
|
||||||
export type ServerVersionInfo = {
|
export type ServerVersionInfo = {
|
||||||
packageName: string;
|
packageName: string;
|
||||||
versionName: string;
|
versionName: string;
|
||||||
versionCode: number;
|
versionCode: number;
|
||||||
minSupportedVersionCode: number;
|
minSupportedVersionCode: number;
|
||||||
fileName: string;
|
fileName: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type StartupStatus =
|
export type StartupStatus =
|
||||||
| { state: "checking" }
|
| { state: "checking" }
|
||||||
| { state: "needs-config" }
|
| { state: "needs-config" }
|
||||||
| { state: "offline" }
|
| { state: "offline" }
|
||||||
| { state: "blocked"; reason: string; server: ServerVersionInfo }
|
| { state: "blocked"; reason: string; server: ServerVersionInfo }
|
||||||
| { state: "warning"; message: string; server: ServerVersionInfo }
|
| { state: "warning"; message: string; server: ServerVersionInfo }
|
||||||
| { state: "ready"; server: ServerVersionInfo | null };
|
| { state: "ready"; server: ServerVersionInfo | null };
|
||||||
|
|
||||||
export function evaluateVersion(
|
export function evaluateVersion(
|
||||||
appBuildCode: number,
|
appBuildCode: number,
|
||||||
server: ServerVersionInfo
|
server: ServerVersionInfo,
|
||||||
): StartupStatus {
|
): StartupStatus {
|
||||||
if (appBuildCode < server.minSupportedVersionCode) {
|
if (appBuildCode < server.minSupportedVersionCode) {
|
||||||
return {
|
return {
|
||||||
state: "blocked",
|
state: "blocked",
|
||||||
reason: "This scanner app is too old and must be updated before use.",
|
reason: "This scanner app is too old and must be updated before use.",
|
||||||
server,
|
server,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appBuildCode !== server.versionCode) {
|
if (appBuildCode !== server.versionCode) {
|
||||||
return {
|
return {
|
||||||
state: "warning",
|
state: "warning",
|
||||||
message: `A newer version is available. Installed build: ${appBuildCode}, latest build: ${server.versionCode}.`,
|
message: `A newer version is available. Installed build: ${appBuildCode}, latest build: ${server.versionCode}.`,
|
||||||
server,
|
server,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
state: "ready",
|
state: "ready",
|
||||||
server,
|
server,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const versionCheck = async () => {
|
||||||
|
const { setServerVersion } = useServerStore.getState();
|
||||||
|
const { serverPort, serverIp } = useAppStore.getState();
|
||||||
|
|
||||||
|
const port = parseInt(serverPort || "0", 10) >= 50000 ? "3000" : serverPort;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await axios.get(
|
||||||
|
`http://${serverIp}:${port}/lst/api/mobile/version`,
|
||||||
|
{ timeout: 5000 },
|
||||||
|
);
|
||||||
|
|
||||||
|
if (res.status === 200) {
|
||||||
|
setServerVersion(res.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// const build = Constants.expoConfig?.android?.versionCode ?? 1;
|
||||||
|
|
||||||
|
// if (build < res.data.minSupportedVersionCode) {
|
||||||
|
// setStartupRoute("/updateScreen");
|
||||||
|
// setReady(true);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Version check error:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
3
migrations/0045_quick_khan.sql
Normal file
3
migrations/0045_quick_khan.sql
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
ALTER TABLE "scan_users" ALTER COLUMN "excluded_commands" SET DATA TYPE jsonb;--> statement-breakpoint
|
||||||
|
ALTER TABLE "scan_users" ALTER COLUMN "excluded_commands" SET DEFAULT '';--> statement-breakpoint
|
||||||
|
ALTER TABLE "scan_log" ADD COLUMN "user" text;
|
||||||
1
migrations/0046_chemical_the_leader.sql
Normal file
1
migrations/0046_chemical_the_leader.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE "scan_users" ALTER COLUMN "excluded_commands" SET DEFAULT '[]'::jsonb;
|
||||||
1
migrations/0047_spotty_queen_noir.sql
Normal file
1
migrations/0047_spotty_queen_noir.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE "scan_log" ADD COLUMN "running_number" text DEFAULT '0';
|
||||||
2149
migrations/meta/0045_snapshot.json
Normal file
2149
migrations/meta/0045_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
2149
migrations/meta/0046_snapshot.json
Normal file
2149
migrations/meta/0046_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
2156
migrations/meta/0047_snapshot.json
Normal file
2156
migrations/meta/0047_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -316,6 +316,27 @@
|
|||||||
"when": 1777666145468,
|
"when": 1777666145468,
|
||||||
"tag": "0044_steady_magneto",
|
"tag": "0044_steady_magneto",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 45,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1778059667805,
|
||||||
|
"tag": "0045_quick_khan",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 46,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1778059910210,
|
||||||
|
"tag": "0046_chemical_the_leader",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 47,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1778068577325,
|
||||||
|
"tag": "0047_spotty_queen_noir",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "lst_v3",
|
"name": "lst_v3",
|
||||||
"version": "0.0.2-alpha.7",
|
"version": "0.0.2-alpha.9",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "lst_v3",
|
"name": "lst_v3",
|
||||||
"version": "0.0.2-alpha.7",
|
"version": "0.0.2-alpha.9",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dotenvx/dotenvx": "^1.57.0",
|
"@dotenvx/dotenvx": "^1.57.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lst_v3",
|
"name": "lst_v3",
|
||||||
"version": "0.0.2-alpha.7",
|
"version": "0.0.2-alpha.9",
|
||||||
"description": "The tool that supports us in our everyday alplaprod",
|
"description": "The tool that supports us in our everyday alplaprod",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user