diff --git a/frontend/src/components/logistics/siloAdjustments/AttachSilo.tsx b/frontend/src/components/logistics/siloAdjustments/AttachSilo.tsx
new file mode 100644
index 0000000..564a7e3
--- /dev/null
+++ b/frontend/src/components/logistics/siloAdjustments/AttachSilo.tsx
@@ -0,0 +1,164 @@
+import { Button } from "@/components/ui/button";
+import {
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ DialogTrigger,
+} from "@/components/ui/dialog";
+
+import { useAppForm } from "@/utils/formStuff";
+import { getMachineConnected } from "@/utils/querys/logistics/machineConnected";
+import { getMachineNotConnected } from "@/utils/querys/logistics/notConnected";
+import { useQuery } from "@tanstack/react-query";
+import axios from "axios";
+import { useState } from "react";
+import { toast } from "sonner";
+
+export function AttachSilo(props: any) {
+ const [open, setOpen] = useState(false);
+ const { data, isError, isLoading, refetch } = useQuery(
+ getMachineNotConnected({
+ siloID: props.silo.LocationID,
+ connectionType: "detached",
+ })
+ );
+ const { refetch: attached } = useQuery(
+ getMachineConnected({
+ siloID: props.silo.LocationID,
+ connectionType: "connected",
+ })
+ );
+
+ const form = useAppForm({
+ defaultValues: {
+ laneId: props.silo.LocationID,
+ productionLotId: "",
+ machineId: "",
+ },
+ onSubmit: async ({ value }) => {
+ console.log(value);
+ try {
+ const res = await axios.post(
+ "/api/logistics/attachsilo",
+ value
+ );
+
+ if (res.data.success) {
+ toast.success(res.data.message);
+ refetch();
+ attached();
+ form.reset();
+ setOpen(!open);
+ } else {
+ console.log(res.data);
+ toast.error(res.data.message);
+ refetch();
+ form.reset();
+ setOpen(!open);
+ }
+ } catch (error) {
+ console.log(error);
+ toast.error(
+ "There was an error attaching the silo please try again, if persist please enter a helpdesk ticket."
+ );
+ }
+ },
+ });
+
+ if (isError)
+ return (
+
+
There was an error loading data
+
+ );
+
+ if (isLoading)
+ return (
+
+ );
+
+ // convert the array that comes over to label and value
+ const tranMachine = data.map((i: any) => ({
+ value: i.machineId.toString(),
+ label: i.name,
+ }));
+
+ return (
+
+ );
+}
diff --git a/frontend/src/components/logistics/siloAdjustments/DetachSilo.tsx b/frontend/src/components/logistics/siloAdjustments/DetachSilo.tsx
new file mode 100644
index 0000000..9bf8d09
--- /dev/null
+++ b/frontend/src/components/logistics/siloAdjustments/DetachSilo.tsx
@@ -0,0 +1,145 @@
+import { Button } from "@/components/ui/button";
+import {
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ DialogTrigger,
+} from "@/components/ui/dialog";
+
+import { useAppForm } from "@/utils/formStuff";
+import { getMachineConnected } from "@/utils/querys/logistics/machineConnected";
+import { getMachineNotConnected } from "@/utils/querys/logistics/notConnected";
+
+import { useQuery } from "@tanstack/react-query";
+import axios from "axios";
+import { useState } from "react";
+import { toast } from "sonner";
+
+export function DetachSilo(props: any) {
+ const [open, setOpen] = useState(false);
+ const { data, isError, isLoading, refetch } = useQuery(
+ getMachineConnected({
+ siloID: props.silo.LocationID,
+ connectionType: "connected",
+ })
+ );
+
+ const { refetch: notConnected } = useQuery(
+ getMachineNotConnected({
+ siloID: props.silo.LocationID,
+ connectionType: "detached",
+ })
+ );
+
+ const form = useAppForm({
+ defaultValues: {
+ laneId: props.silo.LocationID,
+ machineId: 0,
+ },
+ onSubmit: async ({ value }) => {
+ try {
+ const res = await axios.post(
+ "/api/logistics/detachsilo",
+ value
+ );
+
+ if (res.status === 200) {
+ toast.success(res.data.message);
+
+ refetch();
+ notConnected();
+ form.reset();
+ setOpen(!open);
+ } else {
+ console.log(res.data);
+ toast.error(res.data.message);
+ refetch();
+ form.reset();
+ setOpen(!open);
+ }
+ } catch (error) {
+ console.log(error);
+ toast.error(
+ "There was an error detaching the silo please try again, if persist please enter a helpdesk ticket."
+ );
+ }
+ },
+ });
+
+ if (isError)
+ return (
+
+
There was an error loading data
+
+ );
+
+ if (isLoading)
+ return (
+
+ );
+
+ // convert the array that comes over to label and value
+ const tranMachine = data.map((i: any) => ({
+ value: i.machineId.toString(),
+ label: i.name,
+ }));
+ return (
+
+ );
+}
diff --git a/frontend/src/components/logistics/siloAdjustments/SiloCard.tsx b/frontend/src/components/logistics/siloAdjustments/SiloCard.tsx
index 8a191b9..67b4b63 100644
--- a/frontend/src/components/logistics/siloAdjustments/SiloCard.tsx
+++ b/frontend/src/components/logistics/siloAdjustments/SiloCard.tsx
@@ -19,6 +19,8 @@ import { CircleAlert } from "lucide-react";
import { useState } from "react";
import { toast } from "sonner";
import ChartData from "./ChartData";
+import { AttachSilo } from "./AttachSilo";
+import { DetachSilo } from "./DetachSilo";
export default function SiloCard(data: any) {
const token = localStorage.getItem("auth_token");
@@ -151,6 +153,7 @@ export default function SiloCard(data: any) {
/>