import React from "react";
import { useOrganization } from "../../hooks/useOrganization";
import { OrgDetailsSkeleton } from "./OrganizationSkeleton";
const VieworgDataanization = ({ orgId }) => {
const { data, isLoading, isError, error } = useOrganization(orgId);
if (isLoading) return ;
if (isError) return
{error.message}
;
return (
{/* Header */}

{" "}
{data?.name}
{data?.isActive ? "Active" : "In-Active"}{" "}
{" "}
Organization Info
{/* Contact Info */}
{data?.contactPerson}
{data?.contactNumber}
{data?.email}
{data?.sprid}
{data?.activeEmployeeCount}
{data?.address}
{/* remove "show" from className */}
{data?.projects && data.projects.length > 0 ? (
data.projects
.reduce((acc, curr) => {
const projectId = curr.project.id;
if (!acc.find((p) => p.id === projectId)) {
acc.push(curr.project);
}
return acc;
}, [])
.map((project) => (
{data.projects
.filter((p) => p.project.id === project.id)
.map((p) => (
{p.service.name}
))}
))
) : (
No projects available
)}
{/* Services Section */}
{/* collapse is closed initially */}
{data?.services && data.services.length > 0 ? (
{data.services.map((service) => (
{service.name}
{service.description || "No description available."}
))}
) : (
No services available
)}
);
};
export default VieworgDataanization;