diff --git a/src/components/ServiceProject/ServiceProjectBranch/ServiceBranch.jsx b/src/components/ServiceProject/ServiceProjectBranch/ServiceBranch.jsx index 63bdb09c..61a4c011 100644 --- a/src/components/ServiceProject/ServiceProjectBranch/ServiceBranch.jsx +++ b/src/components/ServiceProject/ServiceProjectBranch/ServiceBranch.jsx @@ -8,6 +8,7 @@ import { useParams } from "react-router-dom"; import Pagination from "../../common/Pagination"; import ConfirmModal from "../../common/ConfirmModal"; import { SpinnerLoader } from "../../common/Loader"; +import ViewBranchDetails from "./ViewBranchDetails"; const ServiceBranch = () => { const { projectId } = useParams(); @@ -19,6 +20,7 @@ const ServiceBranch = () => { }); const { mutate: DeleteBranch, isPending } = useDeleteBranch(); const [deletingId, setDeletingId] = useState(null); + const [ViewRequest, setViewRequest] = useState({ requestId: null, view: false }); const [search, setSearch] = useState(""); const [currentPage, setCurrentPage] = useState(1); @@ -84,7 +86,7 @@ const ServiceBranch = () => {
- Branchs + Branches
@@ -171,37 +173,67 @@ const ServiceBranch = () => { !isError && data?.data?.length > 0 && data.data.map((branch) => ( - + { + if (!e.target.closest(".dropdown") && !e.target.closest(".bx-show")) { + setViewRequest({ branchId: branch.id, view: true }); + } + }} + > {columns.map((col) => ( {col.getValue(branch)} ))} -
- - +
@@ -277,6 +297,17 @@ const ServiceBranch = () => { /> )} + {ViewRequest.view && ( + setViewRequest({ branchId: null, view: false })} + > + + + + )} diff --git a/src/components/ServiceProject/ServiceProjectBranch/ViewBranchDetails.jsx b/src/components/ServiceProject/ServiceProjectBranch/ViewBranchDetails.jsx new file mode 100644 index 00000000..db67ea8b --- /dev/null +++ b/src/components/ServiceProject/ServiceProjectBranch/ViewBranchDetails.jsx @@ -0,0 +1,142 @@ +import React from "react"; +import { useBranchDetails } from "../../../hooks/useServiceProject"; +import Avatar from "../../common/Avatar"; +import { formatUTCToLocalTime } from "../../../utils/dateUtils"; + +const ViewBranchDetails = ({ BranchToEdit }) => { + const { data, isLoading, isError, error: requestError } = useBranchDetails(BranchToEdit); + + console.log("branch details:", data); + + if (isLoading) return

Loading...

; + if (isError) return

Error: {requestError?.message}

; + + return ( +
+
+
Branch Details
+
+
+
+
+ +
{data?.branchName || "N/A"}
+
+
+
+
+ +
{data?.branchName || "N/A"}
+
+
+
+
+ +
{data?.project?.name || "N/A"}
+
+
+ +
+
+ + <> + + + {`${data.updatedBy.firstName ?? ""} ${data.updatedBy.lastName ?? "" + }`.trim() || "N/A"} + + +
+
+
+
+ + + + {`${data?.createdBy?.firstName ?? ""} ${data?.createdBy?.lastName ?? "" + }`.trim() || "N/A"} + +
+
+
+
+ +
+ {data?.createdAt + ? formatUTCToLocalTime(data.createdAt, true) + : "N/A"} +
+
+
+
+ +
+ {data?.contactInformation ? ( + JSON.parse(data.contactInformation).map((contact, index) => ( +
+
Person {index + 1}:-
+
+ {contact.contactPerson || "N/A"} +
+
+ {contact.designation || "N/A"} +
+
+ {contact.contactEmails?.join(", ") || "N/A"} +
+
+ {contact.contactNumbers?.join(", ") || "N/A"} +
+
+ )) + ) : ( + "N/A" + )} +
+
+
+
+ ); +}; + +export default ViewBranchDetails;