import React, { useEffect, useState } from "react";
import moment from "moment";
import { getProjectStatusName } from "../../utils/projectStatus";
const AboutProject = ({ data }) => {
  const [CurrentProject, setCurrentProject] = useState(data);

  useEffect(() => {
    setCurrentProject(data);
  }, [data]);

  return (
    <>
      {data && (
        <div className="card mb-6">
          <div className="card-body">
            <small className="card-text text-uppercase text-muted small">
              Profile
            </small>
            <ul className="list-unstyled my-3">
              <li className="d-flex align-items-center mb-4">
                <i className="bx bx-check"></i>
                <span className="fw-medium mx-2">Start Date:</span>{" "}
                <span>
                  {data.startDate
                    ? moment(data.startDate).format("DD-MMM-YYYY")
                    : "N/A"}
                </span>
              </li>
              <li className="d-flex align-items-center mb-4">
                <i className="bx bx-stop-circle"></i>{" "}
                <span className="fw-medium mx-2">End Date:</span>{" "}
                <span>
                  {data.endDate
                    ? moment(data.endDate).format("DD-MMM-YYYY")
                    : "N/A"}
                </span>
              </li>
              <li className="d-flex align-items-center mb-2">
                <i className="bx bx-trophy"></i>
                <span className="fw-medium mx-2">Status:</span>{" "}
                <span>{getProjectStatusName(data.projectStatusId)}</span>
              </li>
              <li className="d-flex align-items-center mb-4">
                <i className="bx bx-user"></i>
                <span className="fw-medium mx-2">Contact:</span>{" "}
                <span>{data.contactPerson}</span>
              </li>
              <li className="d-flex flex-column align-items-start mb-4">
                <div className="d-flex align-items-center">
                  <i className="bx bx-flag"></i>
                  <span className="fw-medium mx-2">Address:</span>
                  {data.projectAddress?.length <= 20 && (
                    <span>{data.projectAddress}</span>
                  )}
                </div>
                {data.projectAddress?.length > 20 && (
                  <div className="ms-4 text-start">{data.projectAddress}</div>
                )}
              </li>
            </ul>
          </div>
        </div>
      )}

      {!data && <span>loading...</span>}
    </>
  );
};

export default AboutProject;
