"use client";

import { FiChevronRight } from "react-icons/fi";

import { SETTINGS_TABS } from "../constants/tabs";
import { SettingsTab } from "../types/settings";

interface Props {
  activeTab: SettingsTab;
  onChange: (tab: SettingsTab) => void;
}

export default function SettingsSidebar({
  activeTab,
  onChange,
}: Props) {
  return (
    <div className="w-full overflow-x-auto xl:overflow-x-visible">
      <div className="flex gap-2 2xl:block 2xl:space-y-4 min-w-max 2xl:min-w-0">
        {SETTINGS_TABS.map((item) => (
          <button
            key={item.key}
            onClick={() => onChange(item.key)}
            className={`flex 2xl:w-full items-center whitespace-nowrap justify-center xl:justify-between
              rounded-md md:rounded-xl px-3 py-2 xl:px-4 xl:py-3 2xl:p-5 text-sm text-center xl:text-left 2xl:text-lg font-medium cursor-pointer

              ${
                activeTab === item.key
                  ? "gradient1 text-white"
                  : "bg-white 2xl:glass-card-v2 text-heading"
              }
            `}
          >
            <span className="w-full">
              {item.label}
            </span>

            <FiChevronRight className="hidden xl:block"/>
          </button>
        ))}
      </div>
    </div>
  );
}