feat(intial auth): intial auth setup for the scanner
Some checks failed
Build and Push LST Docker Image / docker (push) Has been cancelled
Some checks failed
Build and Push LST Docker Image / docker (push) Has been cancelled
This commit is contained in:
@@ -1,13 +1,26 @@
|
||||
import React from 'react'
|
||||
import { Text, View } from 'react-native'
|
||||
import React from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { Button } from "../../components/ui/button";
|
||||
|
||||
export default function Logs() {
|
||||
return (
|
||||
<View style={{
|
||||
const getInfo = async () => {
|
||||
const info = "ho";
|
||||
|
||||
console.log(info);
|
||||
};
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
//justifyContent: "center",
|
||||
alignItems: "center",
|
||||
marginTop: 50,
|
||||
}}><Text>Logs</Text></View>
|
||||
)
|
||||
}}
|
||||
>
|
||||
<Text>Logs</Text>
|
||||
<Button onPress={getInfo}>
|
||||
<Text>Check info</Text>
|
||||
</Button>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import React from "react";
|
||||
import { View } from "react-native";
|
||||
|
||||
import { useAppStore } from "../../hooks/useAppStore";
|
||||
import ProdScanner from "../../components/ProdScanner";
|
||||
import { View } from "react-native";
|
||||
import LSTScanner from "../../components/LSTScanner";
|
||||
import ProdScanner from "../../components/ProdScanner";
|
||||
import { useAppStore } from "../../hooks/useAppStore";
|
||||
|
||||
export default function scanner() {
|
||||
export default function Scanner() {
|
||||
const serverPort = useAppStore((s) => s.serverPort);
|
||||
return (
|
||||
<View
|
||||
@@ -16,7 +14,11 @@ export default function scanner() {
|
||||
marginTop: 50,
|
||||
}}
|
||||
>
|
||||
{parseInt(serverPort || "0", 10) >= 50000 ? <ProdScanner /> : <LSTScanner />}
|
||||
{parseInt(serverPort || "0", 10) >= 50000 ? (
|
||||
<ProdScanner />
|
||||
) : (
|
||||
<LSTScanner />
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Redirect, useRouter } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { ActivityIndicator, Text, View } from "react-native";
|
||||
import { useAppStore } from "../hooks/useAppStore";
|
||||
import { useMobileAuthStore } from "../hooks/useMobileAuth";
|
||||
import { useServerStore } from "../hooks/useServerCheck";
|
||||
import { devDelay } from "../lib/devMode";
|
||||
|
||||
@@ -12,6 +13,7 @@ export default function Index() {
|
||||
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);
|
||||
const serverPort = useAppStore((s) => s.serverPort);
|
||||
@@ -86,7 +88,7 @@ export default function Index() {
|
||||
// TODO if theres an update go to update screen message :D
|
||||
setMessage(<Text>Opening LST scan app</Text>);
|
||||
await devDelay(3250);
|
||||
//router.replace("/scanner");
|
||||
|
||||
setReady(true);
|
||||
} catch (error) {
|
||||
console.log("Startup error", error);
|
||||
@@ -104,6 +106,9 @@ export default function Index() {
|
||||
setServerVersion,
|
||||
]);
|
||||
|
||||
// if (ready && !isUnlocked) {
|
||||
// return <Redirect href={"/login"} />;
|
||||
// }
|
||||
if (ready) {
|
||||
return <Redirect href="/(tabs)/scanner" />;
|
||||
}
|
||||
|
||||
52
lstMobile/src/app/login.tsx
Normal file
52
lstMobile/src/app/login.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
import axios from "axios";
|
||||
import Constants from "expo-constants";
|
||||
import { useRouter } from "expo-router";
|
||||
import { useState } from "react";
|
||||
import { Alert, Button, Text, View } from "react-native";
|
||||
import { Input } from "../components/ui/input";
|
||||
import { useAppStore } from "../hooks/useAppStore";
|
||||
import { useMobileAuthStore } from "../hooks/useMobileAuth";
|
||||
|
||||
export default function Login() {
|
||||
const { setUser } = useMobileAuthStore();
|
||||
const serverPort = useAppStore((s) => s.serverPort);
|
||||
const serverIp = useAppStore((s) => s.serverIp);
|
||||
const onLogin = async () => {
|
||||
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);
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
//justifyContent: "center",
|
||||
alignItems: "center",
|
||||
marginTop: 50,
|
||||
}}
|
||||
>
|
||||
<View className="flex items-center m-5">
|
||||
<Text style={{ fontSize: 20, fontWeight: "600" }}>
|
||||
LST Scanner Login
|
||||
</Text>
|
||||
<View className="w-64 p-4">
|
||||
<Input
|
||||
className="w-fit"
|
||||
keyboardType="number-pad"
|
||||
textContentType="oneTimeCode"
|
||||
placeholder="Pin number"
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<Button title="Login" onPress={onLogin} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -154,10 +154,10 @@ export default function Setup() {
|
||||
marginBottom: 12,
|
||||
}}
|
||||
>
|
||||
<Text className="text-[12] color-#666">
|
||||
<Text className="text-sm color-[#312f2f]">
|
||||
App v{version}-{build}
|
||||
</Text>
|
||||
<Text className="text-[12] color-#666">
|
||||
<Text className="text-sm color-[#312f2f]">
|
||||
Server version - v{server?.versionName}-{server?.versionCode}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user