fix(scanner): logut out corrections
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 1m24s
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 1m24s
refs #17
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
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 { Redirect, useFocusEffect, useRouter } from "expo-router";
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import { Alert, Button, Text, View } from "react-native";
|
import { Alert, Button, Text, View } from "react-native";
|
||||||
import { useAppStore } from "../hooks/useAppStore";
|
import { useAppStore } from "../hooks/useAppStore";
|
||||||
@@ -23,14 +23,13 @@ const formatName = (name?: string) =>
|
|||||||
export default function LSTScanner() {
|
export default function LSTScanner() {
|
||||||
const user = useMobileAuthStore((s) => s.user);
|
const user = useMobileAuthStore((s) => s.user);
|
||||||
const logout = useMobileAuthStore((s) => s.logout);
|
const logout = useMobileAuthStore((s) => s.logout);
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
// TODO : move to off tcp stuff after od
|
// TODO : move to off tcp stuff after od
|
||||||
const lastScan = useScannerStore((s) => s.lastScan);
|
const lastScan = useScannerStore((s) => s.lastScan);
|
||||||
const setLastScan = useScannerStore((s) => s.setLastScan);
|
const setLastScan = useScannerStore((s) => s.setLastScan);
|
||||||
const [tagScans, setTagScans] = useState<any>([]);
|
const [tagScans, setTagScans] = useState<any>([]);
|
||||||
const scannerIdFromStore = useAppStore((s) => s.scannerId);
|
|
||||||
const serverIp = useAppStore((s) => s.serverIp);
|
const serverIp = useAppStore((s) => s.serverIp);
|
||||||
const serverPort = useAppStore((s) => s.serverPort);
|
|
||||||
const [bgColor, setBGColor] = useState<string | null>(null);
|
const [bgColor, setBGColor] = useState<string | null>(null);
|
||||||
|
|
||||||
const handleScan = useCallback(
|
const handleScan = useCallback(
|
||||||
@@ -154,6 +153,13 @@ export default function LSTScanner() {
|
|||||||
setTagScans([]);
|
setTagScans([]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const logoutScanner = () => {
|
||||||
|
setTagScans([]);
|
||||||
|
setLastScan(null);
|
||||||
|
logout();
|
||||||
|
router.replace("/");
|
||||||
|
};
|
||||||
|
|
||||||
//console.log(lastScan);
|
//console.log(lastScan);
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
@@ -228,7 +234,7 @@ export default function LSTScanner() {
|
|||||||
<View className="m-2">
|
<View className="m-2">
|
||||||
{user && (
|
{user && (
|
||||||
<View className="items-center">
|
<View className="items-center">
|
||||||
<Button title="Logout" onPress={logout} />
|
<Button title="Logout" onPress={logoutScanner} />
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
Reference in New Issue
Block a user