import { useTranslation } from 'react-i18next';
import { SectionTitleArrow } from '@/entities/common/ui/section-title-arrow';
import { InfoSectionKeys, InfoSectionProps } from '../../model/types';
import { SlideDown } from 'react-slidedown';
import 'react-slidedown/lib/slidedown.css';

export const MerchantInfoSection = ({
  merchantInfo,
  isOpen,
  onClickToOpenInfo
}: InfoSectionProps) => {
  const { t } = useTranslation();

  const onClickToSetOpenInfo = () => {
    if(!!onClickToOpenInfo){
      onClickToOpenInfo(InfoSectionKeys.Merchant);
    }
  };

  return (
    <>
      <div className="txn-section">
        <div
          className="section-title with-toggle"
          onClick={ () => onClickToSetOpenInfo() }
        >
          {t('transaction.sections.merchantInfo')} <SectionTitleArrow isOpen={ isOpen }></SectionTitleArrow>
        </div>
        <SlideDown className={'my-dropdown-slidedown'}>
        { !!isOpen &&
          <ul className="kv-list">
            <li className="kv-row">
              <span className="k">·&nbsp;&nbsp;{t('transaction.fields.companyName')}</span>
              <span className="v">{ merchantInfo?.companyName }</span>
            </li>
            <li className="kv-row">
              <span className="k">·&nbsp;&nbsp;{t('transaction.fields.gid')}</span>
              <span className="v">{ merchantInfo?.gid }</span>
            </li>
            <li className="kv-row">
              <span className="k">·&nbsp;&nbsp;{t('transaction.fields.aid')}</span>
              <span className="v">{ merchantInfo?.aid }</span>
            </li>
          </ul>
        }
        </SlideDown>
      </div>
    </>
  );
};