refactor(scanner): more scanner admin stuff
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
import { keepPreviousData, queryOptions } from "@tanstack/react-query";
|
||||
import axios from "axios";
|
||||
import { api } from "../apiHelper";
|
||||
|
||||
export function getScanUsers() {
|
||||
return queryOptions({
|
||||
queryKey: ["getScanUsers"],
|
||||
queryFn: () => fetch(),
|
||||
queryFn: () => dataFetch(),
|
||||
staleTime: 5000,
|
||||
refetchOnWindowFocus: true,
|
||||
placeholderData: keepPreviousData,
|
||||
});
|
||||
}
|
||||
|
||||
const fetch = async () => {
|
||||
const dataFetch = async () => {
|
||||
if (window.location.hostname === "localhost") {
|
||||
await new Promise((res) => setTimeout(res, 1500));
|
||||
}
|
||||
|
||||
const { data } = await axios.get("/lst/api/mobile/auth/user", {
|
||||
withCredentials: true,
|
||||
timeout: 5000,
|
||||
});
|
||||
const { data } = await api.get("/mobile/auth/user");
|
||||
if (!data.success) {
|
||||
throw new Error(data.message ?? "Failed to load scan users");
|
||||
}
|
||||
|
||||
return data.data;
|
||||
return data.data ?? [];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user