import { Cell } from '@taroify/core';
import classNames from 'classnames';
import { useCallback } from 'react';

import CertificationStatus from '@/components/certification-status';
import WechatCell from '@/components/wx-cell';
import { PageUrl } from '@/constants/app';
import { CertificationStatusType } from '@/constants/company';
import useUserInfo from '@/hooks/use-user-info';
import { navigateTo } from '@/utils/route';

import './index.less';

const PREFIX = 'user-fragment-company';

export default function CompanyFragment() {
  const userInfo = useUserInfo();
  // const [showPublish, setShowPublish] = useState(false);

  const handlePublishJob = useCallback(async () => {
    if (userInfo.bossAuthStatus !== CertificationStatusType.Success) {
      navigateTo(PageUrl.CertificationStart);
      return;
    }
    navigateTo(PageUrl.CertificationManage);
  }, [userInfo]);

  return (
    <div className={PREFIX}>
      <CertificationStatus className={`${PREFIX}__cell`} />
      <WechatCell className={`${PREFIX}__cell`} />
      <Cell
        isLink
        align="center"
        title="发通告，让主播主动报单"
        className={classNames(`${PREFIX}__cell`, `${PREFIX}__go-publish-cell`)}
        onClick={handlePublishJob}
      >
        去发布
      </Cell>
      {/* <div>{showPublish && <CompanyPublishJobDialog userInfo={userInfo} onClose={() => setShowPublish(false)} />}</div> */}
    </div>
  );
}
