"use client";

import React, { useEffect } from "react";
import { PlusCircle, Home, User, LogOut, BarChart } from "lucide-react";
import Link from "next/link";
import { useRouter } from "next/navigation";
function SideBar() {
  const navigate = useRouter();
  const logOut = () => {
    localStorage.removeItem("access_token_vendor");
    navigate?.push("/account/login");
  };

  useEffect(() => {
    // first
    const condition = localStorage.getItem("access_token_vendor");
    if (!condition) {
      navigateTo("/account/login");
    }

    return () => {};
  }, []);
  const navigateTo = (url) => navigate?.push(url);
  return (
    <aside className="w-64 bg-white shadow-lg hidden md:block">
      <div className="p-6 border-b">
        <h1 className="text-xl font-bold text-blue-600">Vendor Panel</h1>
      </div>
      <nav className="p-4 space-y-2">
        <Link
          href="/account/deshboard"
          className="flex items-center gap-2 p-2 rounded-lg hover:bg-blue-50"
        >
          <Home className="w-5 h-5 text-blue-600" />
          Dashboard
        </Link>
        <Link
          href="/account/property-list"
          className="flex items-center gap-2 p-2 rounded-lg hover:bg-blue-50"
        >
          <BarChart className="w-5 h-5 text-blue-600" />
          My Properties
        </Link>
        <Link
          href="/account/profile"
          className="flex items-center gap-2 p-2 rounded-lg hover:bg-blue-50"
        >
          <User className="w-5 h-5 text-blue-600" />
          Profile
        </Link>
        <Link
          href="/account/kyc"
          className="flex items-center gap-2 p-2 rounded-lg hover:bg-blue-50"
        >
          <User className="w-5 h-5 text-blue-600" />
          Kyc
        </Link>
        <a
          href="#"
          onClick={logOut}
          className="flex items-center gap-2 p-2 rounded-lg hover:bg-blue-50 text-red-600"
        >
          <LogOut className="w-5 h-5" />
          Logout
        </a>
      </nav>
    </aside>
  );
}

export default SideBar;
