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 <OrgDetailsSkeleton />;
  if (isError) return <div>{error.message}</div>;
  return (
    <div className="row text-black  text-black text-start ">
      {/* Header */}
      <div className="col-12 mb-3">
        <div className="d-flex justify-content-between align-items-center text-start mb-1">
          <div className="d-flex flex-row gap-2 align-items-center text-wrap">
            <img
              src="/public/assets/img/orgLogo.png"
              alt="logo"
              width={40}
              height={40}
            />{" "}
            <p className="fw-semibold fs-6 m-0">{data?.name}</p>
          </div>
          <div className="text-end">
            <span
              className={`badge bg-label-${
                data?.isActive ? "primary" : "secondary"
              } `}
            >
              {data?.isActive ? "Active" : "In-Active"}{" "}
            </span>
          </div>
        </div>
      </div>
      <div className="d-flex text-secondary mb-2">
        {" "}
        <i className="bx bx-sm bx-info-circle me-1" /> Organization Info
      </div>
      {/* Contact Info */}
      <div className="col-md-6 mb-3">
        <div className="d-flex">
          <label
            className="form-label me-2 mb-0 fw-semibold"
            style={{ minWidth: "130px" }}
          >
            <i className="bx bx-sm bx-user me-1" /> Contact Person :
          </label>
          <div className="text-muted">{data?.contactPerson}</div>
        </div>
      </div>
      <div className="col-md-6 mb-3">
        <div className="d-flex">
          <label
            className="form-label me-2 mb-0 fw-semibold"
            style={{ minWidth: "130px" }}
          >
            <i className="bx bx-sm me-1 bx-phone"></i> Contact Number :
          </label>
          <div className="text-muted">{data?.contactNumber}</div>
        </div>
      </div>
      <div className="col-md-12 mb-3">
        <div className="d-flex">
          <label
            className="form-label me-2 mb-0 fw-semibold"
            style={{ minWidth: "130px" }}
          >
            <i className="bx bx-sm me-1 bx-envelope"></i> Email Address :
          </label>
          <div className="text-muted">{data?.email}</div>
        </div>
      </div>
      <div className="col-6 mb-3">
        <div className="d-flex">
          <label
            className="form-label me-2 mb-0 fw-semibold"
            style={{ maxWidth: "130px" }}
          >
            <i className="bx bx-sm me-1 bx-barcode"></i>
            Service Provider Id (SPRID) :
          </label>
          <div className="text-muted">{data?.sprid}</div>
        </div>
      </div>

      <div className="col-6 mb-3">
        <div className="d-flex">
          <label
            className="form-label me-2 mb-0 fw-semibold"
            style={{ maxWidth: "130px" }}
          >
            <i className="bx bx-sm me-1 bx-group"></i>
            Employees :
          </label>
          <div className="text-muted">{data?.activeEmployeeCount}</div>
        </div>
      </div>
      <div className="col-12 mb-3">
        <div className="d-flex">
          <label
            className="form-label me-1 mb-0 fw-semibold"
            style={{ minWidth: "130px" }}
          >
            <i className="bx bx-sm me-1 bx-map"></i> Address :
          </label>
          <div className="text-muted text-start">{data?.address}</div>
        </div>
      </div>
      <div className="d-flex text-secondary mb-2">
        {" "}
        <i className="bx bx-sm bx-briefcase me-1" /> Projects And Services
      </div>
    </div>
  );
};

export default VieworgDataanization;
