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

export const BusinessMemberTab = ({
  activeTab
}: BusinessMemberTabProps) => {
  const { navigate } = useNavigate();

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