import { PATHS } from '@/shared/constants/paths';
import { useNavigate } from '@/shared/lib/hooks/use-navigate';
import {
  MerchantTabKeys,
  MerchantTabProps
} from '../model/types';

export const MerchantTab = ({
  activeTab
}: MerchantTabProps) => {
  const { navigate } = useNavigate();

  const onClickToNavigation = (tab: MerchantTabKeys) => {
    if(activeTab !== tab){
      if(tab === MerchantTabKeys.Info){
        navigate(PATHS.merchant.info);
      }
      else if(tab === MerchantTabKeys.RegistrationStatus){
        navigate(PATHS.merchant.registrationStatus);
      }
    }
  };
  return(
    <>
      <div className="subTab">
        <button 
          className={`subtab-btn ${(activeTab === MerchantTabKeys.Info)? 'active': ''}` }
          onClick={ () => onClickToNavigation(MerchantTabKeys.Info) } 
        >가맹점 정보</button>
        <button 
          className={`subtab-btn ${(activeTab === MerchantTabKeys.RegistrationStatus)? 'active': ''}` }
          onClick={ () => onClickToNavigation(MerchantTabKeys.RegistrationStatus) } 
        >등록현황</button>
      </div>
    </>
  );
};