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 ?? [];
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { keepPreviousData, queryOptions } from "@tanstack/react-query";
|
||||
import axios from "axios";
|
||||
|
||||
import { api } from "../apiHelper";
|
||||
|
||||
export function getScannerIds() {
|
||||
return queryOptions({
|
||||
@@ -16,10 +17,7 @@ const fetch = async () => {
|
||||
await new Promise((res) => setTimeout(res, 1500));
|
||||
}
|
||||
|
||||
const { data } = await axios.get("/lst/api/mobile/available", {
|
||||
withCredentials: true,
|
||||
timeout: 5000,
|
||||
});
|
||||
const { data } = await api.get("/mobile/available");
|
||||
|
||||
return data.data;
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||
import { createColumnHelper } from "@tanstack/react-table";
|
||||
import axios from "axios";
|
||||
import { format } from "date-fns-tz";
|
||||
import { CircleFadingArrowUp, Trash } from "lucide-react";
|
||||
import { Trash } from "lucide-react";
|
||||
import { Suspense, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { Button } from "../../components/ui/button";
|
||||
@@ -19,7 +19,7 @@ import NewScanUser from "./-components/NewScanUser";
|
||||
export const Route = createFileRoute("/admin/scanUsers")({
|
||||
beforeLoad: async ({ location }) => {
|
||||
const { data: session } = await authClient.getSession();
|
||||
const allowedRole = ["systemAdmin", "admin"];
|
||||
const allowedRole = ["systemAdmin", "admin", "manager"];
|
||||
|
||||
if (!session?.user) {
|
||||
throw redirect({
|
||||
@@ -111,7 +111,7 @@ const ScanUserTable = () => {
|
||||
<div>
|
||||
<EditableCellInput
|
||||
value={getValue()}
|
||||
id={row.original.name}
|
||||
id={row.original.id}
|
||||
field="value"
|
||||
onSubmit={({ id, field, value }) => {
|
||||
updateSetting.mutate({ id, field, value });
|
||||
|
||||
Reference in New Issue
Block a user