import { useEffect, useState } from 'react';
import { useLocation } from 'react-router';
import { PATHS } from '@/shared/constants/paths';
import { useNavigate } from '@/shared/lib/hooks/use-navigate';
import { HeaderType } from '@/entities/common/model/types';
import { 
  useSetHeaderTitle,
  useSetHeaderType,
  useSetFooterMode,
  useSetOnBack
} from '@/widgets/sub-layout/use-sub-layout';

export const UserMenuAuthPage = () => {
  const { navigate } = useNavigate();
  const location = useLocation();
  const [tid, setTid] = useState<string>(location?.state.tid);
  const [menuId, setMenuId] = useState<string>(location?.state.menuId);

  useSetHeaderTitle('사용자 설정');
  useSetHeaderType(HeaderType.LeftArrow);
  useSetFooterMode(true);
  useSetOnBack(() => {
    navigate(PATHS.account.user.accountAuth, {
      state: {
        tid: tid
      }
    });
  });

  useEffect(() => {
    console.log('tid : ', tid);
    console.log('menuId : ', menuId);
  });

  return (
    <>
      <main>
        <div className="tab-content">
          <div className="tab-pane sub active">
            <div className="ing-list sev">
              <div className="desc service-tip">메뉴별 사용 권한을 설정해 주세요.</div>
              <div className="desc service-tip">선택한 권한에 따라 기능 이용이 제한됩니다.</div>

              <div className="settings-section nopadding">
                <div className="settings-row">
                  <div className="settings-row-title bd-style">거래내역 조회</div>
                  <label className="settings-switch">
                    <input 
                      type="checkbox" 
                      checked 
                    />
                    <span className="slider"></span>
                  </label>
                </div>
                <div className="set-divider"></div>
                <div className="settings-row">
                  <span className="settings-row-title bd-sub dot">등록</span>
                  <label className="settings-switch">
                    <input 
                      type="checkbox" 
                      checked 
                    />
                    <span className="slider"></span>
                  </label>
                </div>
                <div className="settings-row">
                  <span className="settings-row-title bd-sub dot">수정</span>
                  <label className="settings-switch">
                    <input 
                      type="checkbox" 
                      checked 
                    />
                    <span className="slider"></span>
                  </label>
                </div>
                <div className="settings-row">
                  <span className="settings-row-title bd-sub dot">삭제</span>
                  <label className="settings-switch">
                    <input 
                      type="checkbox" 
                      checked 
                    />
                    <span className="slider"></span>
                  </label>
                </div>
                <div className="settings-row">
                  <span className="settings-row-title bd-sub dot">다운로드</span>
                  <label className="settings-switch">
                    <input 
                      type="checkbox" 
                      checked 
                    />
                    <span className="slider"></span>
                  </label>
                </div>
              </div>
              <div className="ht-20"></div>
                <div className="settings-section">
                  <div className="settings-row">
                    <div className="settings-row-title bd-style">현금영수증 발행</div>
                    <label className="settings-switch">
                      <input type="checkbox" />
                      <span className="slider"></span>
                    </label>
                  </div>
                  <div className="settings-row">
                    <div className="settings-row-title bd-style">에스크로</div>
                    <label className="settings-switch">
                      <input type="checkbox" />
                      <span className="slider"></span>
                    </label>
                  </div>
                  <div className="settings-row">
                    <div className="settings-row-title bd-style">빌링</div>
                    <label className="settings-switch">
                      <input type="checkbox" />
                      <span className="slider"></span>
                    </label>
                  </div>
              </div>

              <div className="apply-row">
                <button 
                  className="btn-50 btn-blue flex-1"
                  type="button" 
                >저장</button>
              </div>
            </div>
          </div>
        </div>
      </main>
    </>
  );
};