feat(silo adjustments): added in email if % wrong

This commit is contained in:
2025-04-06 07:47:39 -05:00
parent 85e3d46b2e
commit 95bebbde2b
10 changed files with 178 additions and 11 deletions

View File

@@ -82,7 +82,7 @@ export function LogisticsSideBar({
const { subModules } = useSubModuleStore();
const items = subModules.filter((m) => m.moduleName === "logistics");
console.log(items);
//console.log(items);
return (
<SidebarGroup>
<SidebarGroupLabel>Logistics</SidebarGroupLabel>

View File

@@ -0,0 +1,14 @@
import { LstCard } from "@/components/extendedUI/LstCard";
import { CardHeader } from "@/components/ui/card";
export default function SiloCard(data: any) {
const silo = data.silo;
return (
<LstCard>
<CardHeader>{silo.Description}</CardHeader>
<div>
<hr />
</div>
</LstCard>
);
}

View File

@@ -0,0 +1,26 @@
import { getStockSilo } from "@/utils/querys/logistics/siloAdjustments/getStockSilo";
import { useQuery } from "@tanstack/react-query";
import SiloCard from "./SiloCard";
export default function SiloPage() {
const { data, isError, error, isLoading } = useQuery(getStockSilo());
if (isLoading) return;
if (isError) return;
if (error)
return (
<div>
{" "}
There was an error getting the silos please notify your admin if
this continues to be an issue
</div>
);
return (
<div className="flex flex-row gap-2">
{data?.map((s: any) => <SiloCard silo={s} />)}
</div>
);
}

View File

@@ -1,9 +1,28 @@
import { createFileRoute } from '@tanstack/react-router'
import SiloPage from "@/components/logistics/siloAdjustments/SiloPage";
import { createFileRoute, redirect } from "@tanstack/react-router";
export const Route = createFileRoute('/(logistics)/siloAdjustments/')({
component: RouteComponent,
})
export const Route = createFileRoute("/(logistics)/siloAdjustments/")({
component: RouteComponent,
beforeLoad: async () => {
const auth = localStorage.getItem("auth_token");
if (!auth) {
throw redirect({
to: "/login",
search: {
// Use the current location to power a redirect after login
// (Do not use `router.state.resolvedLocation` as it can
// potentially lag behind the actual current location)
redirect: location.pathname + location.search,
},
});
}
},
});
function RouteComponent() {
return <div>Hello "/(logistics)/siloAdjustments/"!</div>
return (
<div>
<SiloPage />
</div>
);
}

View File

@@ -0,0 +1,26 @@
import { queryOptions } from "@tanstack/react-query";
import axios from "axios";
export function getStockSilo() {
const token = localStorage.getItem("auth_token");
return queryOptions({
queryKey: ["getUsers"],
queryFn: () => fetchStockSilo(token),
enabled: !!token, // Prevents query if token is null
staleTime: 1000,
//refetchInterval: 2 * 2000,
refetchOnWindowFocus: true,
});
}
const fetchStockSilo = async (token: string | null) => {
const { data } = await axios.get(`/api/logistics/getstocksilo`, {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
});
// if we are not localhost ignore the devDir setting.
//const url: string = window.location.host.split(":")[0];
return data.data ?? [];
};