diff --git a/src/app/components/property/PartModal.tsx b/src/app/components/property/PartModal.tsx index e69de29..e367e65 100644 --- a/src/app/components/property/PartModal.tsx +++ b/src/app/components/property/PartModal.tsx @@ -0,0 +1,107 @@ +import { Dialog, Transition } from "@headlessui/react"; +import { Dispatch, Fragment, SetStateAction, useState } from "react"; +import { TanButton } from "../button"; +import { EpcRating } from "@/types/epc"; + +export default function PartModal({ + isOpen, + setIsOpen, + title, + targetEpcRating, + currentEpcRating, +}: { + isOpen: boolean; + setIsOpen: Dispatch>; + title: string; + targetEpcRating: EpcRating | ""; + currentEpcRating: EpcRating; +}) { + function handleEditModalClose() { + setIsOpen(false); + } + + const [modalEpcTarget, setModalEpcTarget] = useState( + targetEpcRating + ); + + function handleModalSubmit() { + setIsOpen(false); + } + + function getEpcOptions( + epc: EpcRating + ): { label: EpcRating; value: EpcRating }[] { + const alphabet = "ABCDEFG"; + const index = alphabet.indexOf(epc.toUpperCase()); + + if (index === -1) { + throw new Error("Invalid letter input"); + } + + const epcOptions = alphabet.slice(0, index + 1).split(""); + + return epcOptions.map((opt) => ({ + label: opt as EpcRating, + value: opt as EpcRating, + })); + } + + return ( + <> + + setIsOpen(false)} + > + +
+ + +
+
+ + + + {title} + +
+ +
+ + +
+
+
+
+
+
+
+ + ); +} diff --git a/src/app/components/property/partCard.tsx b/src/app/components/property/partCard.tsx index d897055..2090e0a 100644 --- a/src/app/components/property/partCard.tsx +++ b/src/app/components/property/partCard.tsx @@ -1,6 +1,7 @@ import { Dialog } from "@headlessui/react"; import { PencilSquareIcon } from "@heroicons/react/24/outline"; import { useState } from "react"; +import PartModal from "./PartModal"; export default function PartCard({ title, @@ -10,6 +11,7 @@ export default function PartCard({ description: string; }) { const [isDetailModalOpen, setIsDetailModalOpen] = useState(false); + return (
@@ -25,24 +27,13 @@ export default function PartCard({

{description}

- setIsDetailModalOpen(false)} - className="fixed inset-0 z-10" - > -
- - -
- Card Details - - This is the modal content for the card details. - - - {/* Add your card details and actions here */} -
-
-
+
); }