"use client";
import React from "react";
import styles from "./styles.module.css";

import { usePathname, useRouter } from "next/navigation";

const Sidebar = () => {
  const router = useRouter();
  const navToHome = () => {
    router.push("/home");
  };
  const navToOrganization = () => {
    router.push("/organization");
  };
  const navToProject = () => {
    router.push("/projects");
  };
  const navToUsers = () => {
    router.push("/users");
  };
  const navToRoles = () => {
    router.push("/roles");
  };
  const navToCredentials = () => {
    router.push("/credentials");
  };
  const navToAgents = () => {
    router.push("/agents");
  };

  const pathname = usePathname();
  console.log(pathname);
  return (
    <div className={styles.mainContainer}>
      <div className={styles.topContainer}>
        {/* Logo Container */}
        <div className={styles.logoContainer}>
          <div>
            <div className={styles.logoIconContainer}>
              <svg
                xmlns="http://www.w3.org/2000/svg"
                width="37"
                height="36"
                viewBox="0 0 37 36"
                fill="none"
              >
                <path
                  d="M15.465 11.0234C13.7773 12.2949 12.0608 13.7836 10.3874 15.457C2.90925 22.9352 -0.879626 31.2707 1.92467 34.0751C4.72895 36.8792 13.0645 33.0904 20.5426 25.6123C22.2161 23.9388 23.7048 22.2224 24.9762 20.5347"
                  stroke="#969AF9"
                  strokeWidth={2}
                  strokeLinecap="round"
                  strokeLinejoin="round"
                  style={{ strokeOpacity: 1 }}
                  fill="none"
                />
                <path
                  d="M24.9762 20.5353C29.3864 26.3895 31.1822 31.8988 29.0053 34.0757C26.201 36.88 17.8655 33.091 10.3874 25.6129C2.90925 18.1348 -0.879626 9.79927 1.92467 6.99498C4.10141 4.81824 9.61081 6.61397 15.465 11.0241"
                  stroke="#969AF9"
                  strokeWidth={2}
                  strokeLinecap="round"
                  strokeLinejoin="round"
                  style={{ strokeOpacity: 1 }}
                  fill="none"
                />
                <path
                  d="M14.1504 20.5347C14.1504 21.261 14.7391 21.8497 15.4654 21.8497C16.1916 21.8497 16.7804 21.261 16.7804 20.5347C16.7804 19.8085 16.1916 19.2197 15.4654 19.2197C14.7391 19.2197 14.1504 19.8085 14.1504 20.5347Z"
                  stroke="#969AF9"
                  strokeWidth={2}
                  strokeLinecap="round"
                  strokeLinejoin="round"
                  style={{ strokeOpacity: 1 }}
                  fill="none"
                />
                <path
                  d="M20.7505 9.08429C19.9243 8.94056 19.9243 7.75456 20.7505 7.61083C23.7436 7.09012 26.124 4.81039 26.7737 1.84263L26.8236 1.61514C27.0022 0.798617 28.1649 0.793535 28.3509 1.60847L28.4114 1.87358C29.0849 4.82732 31.4661 7.0878 34.4509 7.60707C35.2814 7.75154 35.2814 8.94358 34.4509 9.08805C31.4661 9.60732 29.0849 11.8678 28.4114 14.8216L28.3509 15.0867C28.1649 15.9016 27.0022 15.8965 26.8236 15.08L26.7737 14.8525C26.124 11.8848 23.7436 9.605 20.7505 9.08429Z"
                  stroke="#969AF9"
                  strokeWidth={2}
                  strokeLinecap="round"
                  strokeLinejoin="round"
                  style={{ strokeOpacity: 1 }}
                  fill="none"
                />
              </svg>
            </div>
            <div className={styles.logoDescription}>
              <p>Internal Developer Platform</p>
              <p>By Project Moonshot Inc.</p>
            </div>
          </div>
        </div>
        {/* Navigations */}
        <div className={styles.navContainer}>
          <div
            className={`${styles.nav} ${pathname.includes("/home") ? styles.active : ""}`}
            onClick={navToHome}
          >
            <svg
              xmlns="http://www.w3.org/2000/svg"
              width="24"
              height="24"
              viewBox="0 0 24 24"
              fill="none"
            >
              <path
                d="M5.4375 12H3.5625L12 3.5625L20.4375 12H18.5625"
                stroke="#969AF9"
                strokeWidth="1.5"
                strokeLinecap="round"
                strokeLinejoin="round"
              />
              <path
                d="M5.4375 12V18.5625C5.4375 19.0598 5.63504 19.5367 5.98667 19.8883C6.33831 20.24 6.81522 20.4375 7.3125 20.4375H16.6875C17.1848 20.4375 17.6617 20.24 18.0133 19.8883C18.365 19.5367 18.5625 19.0598 18.5625 18.5625V12"
                stroke="#969AF9"
                strokeWidth="1.5"
                strokeLinecap="round"
                strokeLinejoin="round"
              />
              <path
                d="M10.125 12H13.875V15.75H10.125V12Z"
                stroke="#969AF9"
                strokeWidth="1.5"
                strokeLinecap="round"
                strokeLinejoin="round"
              />
            </svg>
            <p>Home</p>
          </div>
          <div
            className={`${styles.nav} ${pathname.includes("/organization") ? styles.active : ""}`}
            onClick={navToOrganization}
          >
            <svg
              xmlns="http://www.w3.org/2000/svg"
              width="24"
              height="24"
              viewBox="0 0 24 24"
              fill="none"
            >
              <path
                d="M17.3653 7.69688C16.4048 6.7122 15.1917 6.01095 13.8591 5.67M10.1362 5.67C8.78152 6.01744 7.55105 6.73708 6.58406 7.7475M4.82062 10.7616C4.60749 11.4669 4.49946 12.1997 4.5 12.9366C4.5 13.6284 4.59375 14.2987 4.76906 14.9353M6.60656 18.1491C7.56883 19.1461 8.7887 19.8568 10.1306 20.2022M13.8806 20.2022C15.2181 19.856 16.4338 19.1467 17.3934 18.1528M19.2328 14.9372C19.4119 14.2864 19.5024 13.6144 19.5019 12.9394C19.5019 12.2231 19.4016 11.5303 19.2141 10.8741M10.125 5.4375C10.125 5.93478 10.3225 6.41169 10.6742 6.76333C11.0258 7.11496 11.5027 7.3125 12 7.3125C12.4973 7.3125 12.9742 7.11496 13.3258 6.76333C13.6775 6.41169 13.875 5.93478 13.875 5.4375C13.875 4.94022 13.6775 4.46331 13.3258 4.11167C12.9742 3.76004 12.4973 3.5625 12 3.5625C11.5027 3.5625 11.0258 3.76004 10.6742 4.11167C10.3225 4.46331 10.125 4.94022 10.125 5.4375ZM3.5625 16.6875C3.5625 17.1848 3.76004 17.6617 4.11167 18.0133C4.46331 18.365 4.94022 18.5625 5.4375 18.5625C5.93478 18.5625 6.41169 18.365 6.76333 18.0133C7.11496 17.6617 7.3125 17.1848 7.3125 16.6875C7.3125 16.1902 7.11496 15.7133 6.76333 15.3617C6.41169 15.01 5.93478 14.8125 5.4375 14.8125C4.94022 14.8125 4.46331 15.01 4.11167 15.3617C3.76004 15.7133 3.5625 16.1902 3.5625 16.6875ZM16.6875 16.6875C16.6875 17.1848 16.885 17.6617 17.2367 18.0133C17.5883 18.365 18.0652 18.5625 18.5625 18.5625C19.0598 18.5625 19.5367 18.365 19.8883 18.0133C20.24 17.6617 20.4375 17.1848 20.4375 16.6875C20.4375 16.1902 20.24 15.7133 19.8883 15.3617C19.5367 15.01 19.0598 14.8125 18.5625 14.8125C18.0652 14.8125 17.5883 15.01 17.2367 15.3617C16.885 15.7133 16.6875 16.1902 16.6875 16.6875Z"
                stroke="#858699"
                strokeWidth="1.5"
                strokeLinecap="round"
                strokeLinejoin="round"
              />
            </svg>
            <p>Organization</p>
          </div>
          <div
            onClick={navToProject}
            className={`${styles.nav} ${pathname.includes("/projects") ? styles.active : ""}`}
          >
            <svg
              xmlns="http://www.w3.org/2000/svg"
              width="24"
              height="24"
              viewBox="0 0 24 24"
              fill="none"
            >
              <path
                d="M5.4375 18.5625L8.02219 11.6709C8.08916 11.4923 8.20905 11.3383 8.36585 11.2296C8.52265 11.1209 8.70889 11.0626 8.89969 11.0625H20.4375M5.4375 18.5625H18.5869C19.0231 18.5624 19.4456 18.4102 19.7817 18.1321C20.1177 17.8541 20.3463 17.4675 20.4281 17.0391L21.3619 12.1538C21.3842 12.0195 21.377 11.882 21.3408 11.7508C21.3047 11.6196 21.2404 11.4979 21.1524 11.394C21.0645 11.2902 20.9549 11.2068 20.8315 11.1495C20.708 11.0923 20.5736 11.0626 20.4375 11.0625M5.4375 18.5625C4.94022 18.5625 4.46331 18.365 4.11167 18.0133C3.76004 17.6617 3.5625 17.1848 3.5625 16.6875V6.375C3.5625 5.87772 3.76004 5.40081 4.11167 5.04917C4.46331 4.69754 4.94022 4.5 5.4375 4.5H9.1875L12 7.3125H18.5625C19.0598 7.3125 19.5367 7.51004 19.8883 7.86167C20.24 8.21331 20.4375 8.69022 20.4375 9.1875V11.0625"
                stroke="#858699"
                strokeWidth="1.5"
                strokeLinecap="round"
                strokeLinejoin="round"
              />
            </svg>
            <p>Project</p>
          </div>
          <div
            onClick={navToUsers}
            className={`${styles.nav} ${pathname.includes("/users") ? styles.active : ""}`}
          >
            <svg
              xmlns="http://www.w3.org/2000/svg"
              width="24"
              height="24"
              viewBox="0 0 24 24"
              fill="none"
            >
              <path
                d="M3.5625 20.4375V18.5625C3.5625 17.5679 3.95759 16.6141 4.66085 15.9108C5.36411 15.2076 6.31794 14.8125 7.3125 14.8125H11.0625C12.0571 14.8125 13.0109 15.2076 13.7142 15.9108C14.4174 16.6141 14.8125 17.5679 14.8125 18.5625V20.4375M15.75 3.68438C16.5566 3.89091 17.2716 4.36003 17.7822 5.01779C18.2927 5.67555 18.5699 6.48453 18.5699 7.31719C18.5699 8.14985 18.2927 8.95883 17.7822 9.61658C17.2716 10.2743 16.5566 10.7435 15.75 10.95M20.4375 20.4375V18.5625C20.4327 17.7348 20.1543 16.932 19.6456 16.2791C19.1368 15.6263 18.4264 15.16 17.625 14.9531M5.4375 7.3125C5.4375 8.30706 5.83259 9.26089 6.53585 9.96415C7.23911 10.6674 8.19294 11.0625 9.1875 11.0625C10.1821 11.0625 11.1359 10.6674 11.8392 9.96415C12.5424 9.26089 12.9375 8.30706 12.9375 7.3125C12.9375 6.31794 12.5424 5.36411 11.8392 4.66085C11.1359 3.95759 10.1821 3.5625 9.1875 3.5625C8.19294 3.5625 7.23911 3.95759 6.53585 4.66085C5.83259 5.36411 5.4375 6.31794 5.4375 7.3125Z"
                stroke="#858699"
                strokeWidth="1.5"
                strokeLinecap="round"
                strokeLinejoin="round"
              />
            </svg>
            <p>Users</p>
          </div>
          <div
            onClick={navToRoles}
            className={`${styles.nav} ${pathname.includes("/roles") ? styles.active : ""}`}
          >
            <svg
              xmlns="http://www.w3.org/2000/svg"
              width="24"
              height="24"
              viewBox="0 0 24 24"
              fill="none"
            >
              <g clipPath="url(#clip0_306_15337)">
                <path
                  d="M10.6205 9.86809C10.4245 9.9532 10.2131 9.99711 9.99942 9.99711C9.78573 9.99711 9.57434 9.9532 9.37835 9.86809L1.8462 6.37952C1.72389 6.31783 1.62111 6.2234 1.54929 6.10675C1.47748 5.99009 1.43945 5.85579 1.43945 5.7188C1.43945 5.58181 1.47748 5.44751 1.54929 5.33086C1.62111 5.21421 1.72389 5.11979 1.8462 5.05809L9.37835 1.54309C9.57434 1.45798 9.78573 1.41406 9.99942 1.41406C10.2131 1.41406 10.4245 1.45798 10.6205 1.54309L18.1526 5.03166C18.275 5.09336 18.3778 5.18779 18.4495 5.30443C18.5214 5.42108 18.5593 5.55538 18.5593 5.69237C18.5593 5.82937 18.5214 5.96366 18.4495 6.08032C18.3778 6.19697 18.275 6.2914 18.1526 6.35309L10.6205 9.86809Z"
                  stroke="#858699"
                  strokeWidth={1.5}
                  strokeLinecap="round"
                  strokeLinejoin="round"
                  style={{ strokeOpacity: 1 }}
                />
                <path
                  d="M18.5887 10.4629L10.528 14.1761C10.3559 14.2546 10.1688 14.2953 9.97962 14.2953C9.79041 14.2953 9.60338 14.2546 9.43123 14.1761L1.41016 10.4629"
                  stroke="#858699"
                  strokeWidth={1.5}
                  strokeLinecap="round"
                  strokeLinejoin="round"
                  style={{ strokeOpacity: 1 }}
                />
                <path
                  d="M18.5887 14.7578L10.528 18.471C10.3559 18.5495 10.1688 18.5902 9.97962 18.5902C9.79041 18.5902 9.60338 18.5495 9.43123 18.471L1.41016 14.7578"
                  stroke="#858699"
                  strokeWidth={1.5}
                  strokeLinecap="round"
                  strokeLinejoin="round"
                  style={{ strokeOpacity: 1 }}
                />
              </g>
              <defs>
                <clipPath id="clip0_306_15337">
                  <rect
                    width="20"
                    height="20"
                    fill="white"
                    style={{ fillOpacity: 1 }}
                  />
                </clipPath>
              </defs>
            </svg>
            <p>Roles</p>
          </div>
          <div
            onClick={navToCredentials}
            className={`${styles.nav} ${pathname.includes("/credentials") ? styles.active : ""}`}
          >
            <svg
              xmlns="http://www.w3.org/2000/svg"
              width="24"
              height="24"
              viewBox="0 0 24 24"
              fill="none"
            >
              <path
                d="M4.03125 5.90625L5.4375 7.3125L7.78125 4.96875M4.03125 11.5312L5.4375 12.9375L7.78125 10.5938M4.03125 17.1562L5.4375 18.5625L7.78125 16.2188M11.0625 6.375H19.5M11.0625 12H19.5M11.0625 17.625H19.5"
                stroke="#858699"
                strokeWidth="1.5"
                strokeLinecap="round"
                strokeLinejoin="round"
              />
            </svg>
            <p>Credentials</p>
          </div>
          <div
            onClick={navToAgents}
            className={`${styles.nav} ${pathname.includes("/agents") ? styles.active : ""}`}
          >
            <svg
              xmlns="http://www.w3.org/2000/svg"
              width="24"
              height="24"
              viewBox="0 0 24 24"
              fill="none"
            >
              <g clipPath="url(#clip0_306_15353)">
                <path
                  d="M8.57278 4.14746H7.66494C7.44193 4.14812 7.22431 4.21611 7.0406 4.34254C6.85688 4.46898 6.71563 4.64794 6.63534 4.85601L6.15928 6.08489L4.52076 7.01487L3.21437 6.81558C2.99685 6.78606 2.77546 6.82186 2.57833 6.91846C2.3812 7.01505 2.21724 7.16807 2.10727 7.35807L1.66443 8.13303C1.55095 8.32607 1.49867 8.54895 1.51448 8.7723C1.5303 8.99565 1.61346 9.20896 1.753 9.38407L2.58332 10.4137V12.2736L1.77514 13.3032C1.6356 13.4783 1.55244 13.6916 1.53663 13.915C1.52081 14.1383 1.5731 14.3612 1.68657 14.5543L2.12941 15.3292C2.23938 15.5192 2.40335 15.6722 2.60046 15.7688C2.79759 15.8654 3.019 15.9012 3.23652 15.8718L4.54291 15.6725L6.15928 16.6024L6.63534 17.8313C6.71563 18.0393 6.85688 18.2183 7.0406 18.3448C7.22431 18.4711 7.44193 18.5392 7.66494 18.5399H8.59491C8.81793 18.5392 9.03556 18.4711 9.21927 18.3448C9.40299 18.2183 9.54424 18.0393 9.62453 17.8313L10.1006 16.6024L11.717 15.6725L13.0234 15.8718C13.2409 15.9012 13.4623 15.8654 13.6594 15.7688C13.8565 15.6722 14.0206 15.5192 14.1305 15.3292L14.5733 14.5543C14.6868 14.3612 14.739 14.1383 14.7233 13.915C14.7074 13.6916 14.6243 13.4783 14.4848 13.3032L13.6544 12.2736V11.0744M5.90464 11.3436C5.90464 11.7816 6.03451 12.2097 6.27781 12.5738C6.52112 12.9379 6.86692 13.2217 7.27152 13.3893C7.67611 13.5569 8.12131 13.6007 8.55083 13.5153C8.98035 13.4299 9.37489 13.219 9.68455 12.9093C9.99421 12.5997 10.2051 12.2051 10.2905 11.7756C10.376 11.3461 10.3321 10.9009 10.1645 10.4963C9.99693 10.0917 9.71313 9.7459 9.34901 9.5026C8.98489 9.2593 8.55679 9.12943 8.11886 9.12943C7.53161 9.12943 6.96842 9.36272 6.55317 9.77796C6.13793 10.1932 5.90464 10.7564 5.90464 11.3436Z"
                  stroke="#858699"
                  strokeWidth={1.5}
                  strokeLinecap="round"
                  strokeLinejoin="round"
                  style={{ strokeOpacity: 1 }}
                />
                <path
                  d="M11.4547 5.43105C11.049 5.36047 11.049 4.77804 11.4547 4.70745C12.9245 4.45174 14.0936 3.33217 14.4126 1.87474L14.437 1.76303C14.5249 1.36204 15.0958 1.35954 15.1871 1.75975L15.2168 1.88994C15.5477 3.3405 16.717 4.4506 18.1829 4.70561C18.5907 4.77656 18.5907 5.36195 18.1829 5.4329C16.717 5.68791 15.5477 6.79801 15.2168 8.24857L15.1871 8.37876C15.0958 8.77897 14.5249 8.77647 14.437 8.37548L14.4126 8.26377C14.0936 6.80634 12.9245 5.68677 11.4547 5.43105Z"
                  stroke="#858699"
                  strokeWidth={1.5}
                  strokeLinecap="round"
                  strokeLinejoin="round"
                  style={{ strokeOpacity: 1 }}
                />
              </g>
              <defs>
                <clipPath id="clip0_306_15353">
                  <rect
                    width="20"
                    height="20"
                    fill="white"
                    style={{ fillOpacity: 1 }}
                  />
                </clipPath>
              </defs>
            </svg>
            <p>Agents</p>
          </div>
        </div>
      </div>
      {/* Footers */}
      <div className={styles.navFooterContainer}>
        <div>
          <div>
            <p>Download ICTL v3</p>
            <svg
              xmlns="http://www.w3.org/2000/svg"
              width="24"
              height="24"
              viewBox="0 0 24 24"
              fill="none"
            >
              <g clipPath="url(#clip0_306_15402)">
                <path
                  d="M7.98047 13.6074L11.9983 17.6253L16.0162 13.6074"
                  stroke="#8287FF"
                  strokeWidth={1.5}
                  strokeLinecap="round"
                  strokeLinejoin="round"
                  style={{ strokeOpacity: 1 }}
                />
                <path
                  d="M12 17.625V6.375"
                  stroke="#8287FF"
                  strokeWidth={1.5}
                  strokeLinecap="round"
                  strokeLinejoin="round"
                  style={{ strokeOpacity: 1 }}
                />
                <path
                  d="M11.9992 22.4466C17.7686 22.4466 22.4456 17.7696 22.4456 12.0001C22.4456 6.23074 17.7686 1.55371 11.9992 1.55371C6.22976 1.55371 1.55273 6.23074 1.55273 12.0001C1.55273 17.7696 6.22976 22.4466 11.9992 22.4466Z"
                  stroke="#8287FF"
                  strokeWidth={1.5}
                  strokeLinecap="round"
                  strokeLinejoin="round"
                  style={{ strokeOpacity: 1 }}
                />
              </g>
              <defs>
                <clipPath id="clip0_306_15402">
                  <rect
                    width="24"
                    height="24"
                    fill="white"
                    style={{ fillOpacity: 1 }}
                  />
                </clipPath>
              </defs>
            </svg>
          </div>
        </div>
      </div>
    </div>
  );
};

export default Sidebar;
