fix(export inv): added the button to exprot data
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
export default function MaterialHelperPage() {
|
||||||
|
return <div>materialHelperPage</div>;
|
||||||
|
}
|
||||||
@@ -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 { useForm } from "@tanstack/react-form";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { toast } from "sonner";
|
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() {
|
export default function ExportInventoryData() {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
|
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
age: "",
|
age: "",
|
||||||
},
|
},
|
||||||
onSubmit: async ({ value }) => {
|
onSubmit: async ({ value }) => {
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
try {
|
try {
|
||||||
const res = await axios.get(
|
const res = await axios.get(
|
||||||
`/api/logistics/getcyclecount?age=${value.age}`,
|
`/lst/old/api/logistics/getcyclecount?age=${value.age}`,
|
||||||
{
|
{
|
||||||
responseType: "blob",
|
responseType: "blob",
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const blob = new Blob([res.data], {
|
const blob = new Blob([res.data], {
|
||||||
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||||
});
|
});
|
||||||
|
|
||||||
const link = document.createElement("a");
|
const link = document.createElement("a");
|
||||||
link.href = window.URL.createObjectURL(blob);
|
link.href = window.URL.createObjectURL(blob);
|
||||||
link.download = `CycleCount-${format(new Date(Date.now()), "M-d-yyyy")}.xlsx`; // You can make this dynamic
|
link.download = `CycleCount-${format(new Date(Date.now()), "M-d-yyyy")}.xlsx`; // You can make this dynamic
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
|
|
||||||
// Clean up
|
// Clean up
|
||||||
document.body.removeChild(link);
|
document.body.removeChild(link);
|
||||||
window.URL.revokeObjectURL(link.href);
|
window.URL.revokeObjectURL(link.href);
|
||||||
toast.success(`File Downloaded`);
|
toast.success(`File Downloaded`);
|
||||||
setSaving(false);
|
setSaving(false);
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
form.reset();
|
form.reset();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
console.log(`There was an error getting cycle counts.`);
|
console.log(`There was an error getting cycle counts.`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Dialog
|
<Dialog
|
||||||
open={open}
|
open={open}
|
||||||
onOpenChange={(isOpen) => {
|
onOpenChange={(isOpen) => {
|
||||||
if (!open) {
|
if (!open) {
|
||||||
form.reset();
|
form.reset();
|
||||||
}
|
}
|
||||||
setOpen(isOpen);
|
setOpen(isOpen);
|
||||||
// toast.message("Model was something", {
|
// toast.message("Model was something", {
|
||||||
// description: isOpen ? "Modal is open" : "Modal is closed",
|
// description: isOpen ? "Modal is open" : "Modal is closed",
|
||||||
// });
|
// });
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DialogTrigger asChild>
|
<DialogTrigger asChild>
|
||||||
<Button variant="outline">Export Inventory Check</Button>
|
<Button variant="outline">Export Inventory Check</Button>
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
<DialogContent className="sm:max-w-[425px]">
|
<DialogContent className="sm:max-w-[425px]">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>Export Inventory lane check</DialogTitle>
|
<DialogTitle>Export Inventory lane check</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
Exports all lanes based on the age you enter, except
|
Exports all lanes based on the age you enter, except empty lanes.
|
||||||
empty lanes.
|
</DialogDescription>
|
||||||
</DialogDescription>
|
</DialogHeader>
|
||||||
</DialogHeader>
|
<form
|
||||||
<form
|
onSubmit={(e) => {
|
||||||
onSubmit={(e) => {
|
e.preventDefault();
|
||||||
e.preventDefault();
|
e.stopPropagation();
|
||||||
e.stopPropagation();
|
}}
|
||||||
}}
|
>
|
||||||
>
|
<div>
|
||||||
<div>
|
<>
|
||||||
<>
|
<form.Field
|
||||||
<form.Field
|
name="age"
|
||||||
name="age"
|
// validators={{
|
||||||
// validators={{
|
// // We can choose between form-wide and field-specific validators
|
||||||
// // We can choose between form-wide and field-specific validators
|
// onChange: ({ value }) =>
|
||||||
// onChange: ({ value }) =>
|
// value.length > 3
|
||||||
// value.length > 3
|
// ? undefined
|
||||||
// ? undefined
|
// : "Username must be longer than 3 letters",
|
||||||
// : "Username must be longer than 3 letters",
|
// }}
|
||||||
// }}
|
children={(field) => {
|
||||||
children={(field) => {
|
return (
|
||||||
return (
|
<div className="m-2 min-w-48 max-w-96 p-2 flex flex-row">
|
||||||
<div className="m-2 min-w-48 max-w-96 p-2 flex flex-row">
|
<Label htmlFor="active">Age</Label>
|
||||||
<Label htmlFor="active">
|
<Input
|
||||||
Age
|
className="ml-2"
|
||||||
</Label>
|
name={field.name}
|
||||||
<Input
|
onBlur={field.handleBlur}
|
||||||
className="ml-2"
|
type="number"
|
||||||
name={field.name}
|
onChange={(e) => field.handleChange(e.target.value)}
|
||||||
onBlur={field.handleBlur}
|
/>
|
||||||
type="number"
|
</div>
|
||||||
onChange={(e) =>
|
);
|
||||||
field.handleChange(
|
}}
|
||||||
e.target.value
|
/>
|
||||||
)
|
</>
|
||||||
}
|
</div>
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<div className="flex justify-end mt-2">
|
<div className="flex justify-end mt-2">
|
||||||
<Button onClick={() => setOpen(false)}>
|
<Button onClick={() => setOpen(false)}>Close</Button>
|
||||||
Close
|
<Button
|
||||||
</Button>
|
type="submit"
|
||||||
<Button
|
disabled={saving}
|
||||||
type="submit"
|
onClick={form.handleSubmit}
|
||||||
disabled={saving}
|
>
|
||||||
onClick={form.handleSubmit}
|
{saving ? (
|
||||||
>
|
<>
|
||||||
{saving ? (
|
<span>Saving....</span>
|
||||||
<>
|
</>
|
||||||
<span>Saving....</span>
|
) : (
|
||||||
</>
|
<span>Save setting</span>
|
||||||
) : (
|
)}
|
||||||
<span>Save setting</span>
|
</Button>
|
||||||
)}
|
</div>
|
||||||
</Button>
|
</DialogFooter>
|
||||||
</div>
|
</form>
|
||||||
</DialogFooter>
|
</DialogContent>
|
||||||
</form>
|
</Dialog>
|
||||||
</DialogContent>
|
</div>
|
||||||
</Dialog>
|
);
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import { useAuth, useLogout } from "../../../lib/authClient";
|
|||||||
import { AddCards } from "./-components/dashboard/AddCards";
|
import { AddCards } from "./-components/dashboard/AddCards";
|
||||||
import { AppSidebar } from "./-components/layout/lst-sidebar";
|
import { AppSidebar } from "./-components/layout/lst-sidebar";
|
||||||
import DMButtons from "./-components/logistics/dm/DMButtons";
|
import DMButtons from "./-components/logistics/dm/DMButtons";
|
||||||
|
import ExportInventoryData from "./-components/logistics/warehouse/ExportInventoryData";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_old/old")({
|
export const Route = createFileRoute("/_old/old")({
|
||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
@@ -39,7 +40,7 @@ function RouteComponent() {
|
|||||||
{location.pathname === "/lst/app/old" ||
|
{location.pathname === "/lst/app/old" ||
|
||||||
(location.pathname === "/lst/app/old/" && (
|
(location.pathname === "/lst/app/old/" && (
|
||||||
<div className="m-auto pr-2 flex flex-row gap-2">
|
<div className="m-auto pr-2 flex flex-row gap-2">
|
||||||
{/* <ExportInventoryData /> */}
|
<ExportInventoryData />
|
||||||
<AddCards />
|
<AddCards />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Reference in New Issue
Block a user