From 6392441f1b8330c33b0126942ab6bf21a8bb7bdc Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 27 Oct 2025 07:18:46 -0500 Subject: [PATCH] fix(export inv): added the button to exprot data --- .../materialHelper/materialHelperPage.tsx | 3 + .../warehouse/ExportInventoryData.tsx | 268 +++++++++--------- frontend/src/routes/_old/old/route.tsx | 3 +- 3 files changed, 134 insertions(+), 140 deletions(-) create mode 100644 frontend/src/routes/_old/old/-components/logistics/materialHelper/materialHelperPage.tsx diff --git a/frontend/src/routes/_old/old/-components/logistics/materialHelper/materialHelperPage.tsx b/frontend/src/routes/_old/old/-components/logistics/materialHelper/materialHelperPage.tsx new file mode 100644 index 0000000..0822990 --- /dev/null +++ b/frontend/src/routes/_old/old/-components/logistics/materialHelper/materialHelperPage.tsx @@ -0,0 +1,3 @@ +export default function MaterialHelperPage() { + return
materialHelperPage
; +} diff --git a/frontend/src/routes/_old/old/-components/logistics/warehouse/ExportInventoryData.tsx b/frontend/src/routes/_old/old/-components/logistics/warehouse/ExportInventoryData.tsx index 5de04c1..cc2f489 100644 --- a/frontend/src/routes/_old/old/-components/logistics/warehouse/ExportInventoryData.tsx +++ b/frontend/src/routes/_old/old/-components/logistics/warehouse/ExportInventoryData.tsx @@ -1,153 +1,143 @@ -import { Button } from "@/components/ui/button"; -import { - Dialog, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle, - DialogTrigger, -} from "@/components/ui/dialog"; -import { Input } from "@/components/ui/input"; -import { Label } from "@/components/ui/label"; - import { useForm } from "@tanstack/react-form"; import axios from "axios"; import { format } from "date-fns"; import { useState } from "react"; import { toast } from "sonner"; +import { Button } from "@/components/ui/button"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; export default function ExportInventoryData() { - const [open, setOpen] = useState(false); - const [saving, setSaving] = useState(false); + const [open, setOpen] = useState(false); + const [saving, setSaving] = useState(false); - const form = useForm({ - defaultValues: { - age: "", - }, - onSubmit: async ({ value }) => { - setSaving(true); - try { - const res = await axios.get( - `/api/logistics/getcyclecount?age=${value.age}`, - { - responseType: "blob", - } - ); + const form = useForm({ + defaultValues: { + age: "", + }, + onSubmit: async ({ value }) => { + setSaving(true); + try { + const res = await axios.get( + `/lst/old/api/logistics/getcyclecount?age=${value.age}`, + { + responseType: "blob", + }, + ); - const blob = new Blob([res.data], { - type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", - }); + const blob = new Blob([res.data], { + type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + }); - const link = document.createElement("a"); - link.href = window.URL.createObjectURL(blob); - link.download = `CycleCount-${format(new Date(Date.now()), "M-d-yyyy")}.xlsx`; // You can make this dynamic - document.body.appendChild(link); - link.click(); + const link = document.createElement("a"); + link.href = window.URL.createObjectURL(blob); + link.download = `CycleCount-${format(new Date(Date.now()), "M-d-yyyy")}.xlsx`; // You can make this dynamic + document.body.appendChild(link); + link.click(); - // Clean up - document.body.removeChild(link); - window.URL.revokeObjectURL(link.href); - toast.success(`File Downloaded`); - setSaving(false); - setOpen(false); - form.reset(); - } catch (error) { - console.log(error); - console.log(`There was an error getting cycle counts.`); - } - }, - }); + // Clean up + document.body.removeChild(link); + window.URL.revokeObjectURL(link.href); + toast.success(`File Downloaded`); + setSaving(false); + setOpen(false); + form.reset(); + } catch (error) { + console.log(error); + console.log(`There was an error getting cycle counts.`); + } + }, + }); - return ( -
- { - if (!open) { - form.reset(); - } - setOpen(isOpen); - // toast.message("Model was something", { - // description: isOpen ? "Modal is open" : "Modal is closed", - // }); - }} - > - - - - - - Export Inventory lane check - - Exports all lanes based on the age you enter, except - empty lanes. - - -
{ - e.preventDefault(); - e.stopPropagation(); - }} - > -
- <> - - // value.length > 3 - // ? undefined - // : "Username must be longer than 3 letters", - // }} - children={(field) => { - return ( -
- - - field.handleChange( - e.target.value - ) - } - /> -
- ); - }} - /> - -
+ return ( +
+ { + if (!open) { + form.reset(); + } + setOpen(isOpen); + // toast.message("Model was something", { + // description: isOpen ? "Modal is open" : "Modal is closed", + // }); + }} + > + + + + + + Export Inventory lane check + + Exports all lanes based on the age you enter, except empty lanes. + + + { + e.preventDefault(); + e.stopPropagation(); + }} + > +
+ <> + + // value.length > 3 + // ? undefined + // : "Username must be longer than 3 letters", + // }} + children={(field) => { + return ( +
+ + field.handleChange(e.target.value)} + /> +
+ ); + }} + /> + +
- -
- - -
-
- -
-
-
- ); + +
+ + +
+
+ +
+
+
+ ); } diff --git a/frontend/src/routes/_old/old/route.tsx b/frontend/src/routes/_old/old/route.tsx index 8a6e24c..ba75eca 100644 --- a/frontend/src/routes/_old/old/route.tsx +++ b/frontend/src/routes/_old/old/route.tsx @@ -20,6 +20,7 @@ import { useAuth, useLogout } from "../../../lib/authClient"; import { AddCards } from "./-components/dashboard/AddCards"; import { AppSidebar } from "./-components/layout/lst-sidebar"; import DMButtons from "./-components/logistics/dm/DMButtons"; +import ExportInventoryData from "./-components/logistics/warehouse/ExportInventoryData"; export const Route = createFileRoute("/_old/old")({ component: RouteComponent, @@ -39,7 +40,7 @@ function RouteComponent() { {location.pathname === "/lst/app/old" || (location.pathname === "/lst/app/old/" && (
- {/* */} +
))}