import moment from 'moment';
import 'moment/dist/locale/ko';
import { ListDateGroupProps } from '../model/types';
import { ListItem } from '../ui/list-item';

export const ListDateGroup = ({
  additionalServiceCategory,
  mid,
  date,
  items,
  onResendClick
}: ListDateGroupProps) => {
  moment.locale('ko');
  const getStateDate = () => {
    let stateDate = moment(date).format('YY.MM.DD(ddd)');
    return stateDate;
  };

  const getListItem = () => {
    let rs = [];
    if(!!items && items.length>0){
      for(let i=0;i<items.length;i++){
        let key = 'ListItem-'+i;
        rs.push(
          <ListItem
            additionalServiceCategory={ additionalServiceCategory }
            key={ key }
            mid={ mid }
            tid={ items[i]?.tid }
            paymentDate= { items[i]?.paymentDate}
            paymentStatus={ items[i]?.paymentStatus}
            requestDate={ items[i]?.requestDate }
            registDate={ items[i]?.registDate }
            bankName={ items[i]?.bankName}
            accountName={ items[i]?.accountName}
            accountNo={ items[i]?.accountNo }
            transferStatus={ items[i]?.transferStatus}
            resultStatus={ items[i]?.resultStatus }
            resultMessage={ items[i]?.resultMessage }
            applicationDate={ items[i]?.applicationDate }

            amount={ items[i]?.amount }
            sendDate={ items[i]?.sendDate }
            sendStatus={ items[i]?.sendStatus}
            sendMethod={ items[i]?.sendMethod}
            scheduledSendDate={ items[i]?.scheduledSendDate}
            processStatus={ items[i]?.processStatus}

            submallId={ items[i]?.submallId }
            settlementDate={ items[i]?.settlementDate }
            companyName={ items[i]?. companyName }
            disbursementStatus={ items[i]?.disbursementStatus }
            disbursementAmount={ items[i]?.disbursementAmount }

            orderStatus={ items[i]?.orderStatus }
            arsPaymentMethod={ items[i]?.arsPaymentMethod }

            buyerName={ items[i]?.buyerName}
            cursorId={ items[i]?.cursorId}
            subReqId={ items[i]?.subReqId}
            requestId={ items[i]?.requestId}
            detailExposure={ items[i]?.detailExposure}
            receiverInfo={ items[i]?.receiverInfo}
            

            alimCl={ items[i]?.alimCl }
            sendType={ items[i]?.sendType }
            sendCl={ items[i]?.sendCl }
            paymentMethod={ items[i]?.paymentMethod }
            receiverName={ items[i]?.receiverName }

            smsCl= { items[i]?.smsCl }
            onResendClick={ onResendClick }
          ></ListItem>
        )
      }  
    }
    
    return rs;
  };

  return (
    <>
      <div className="date-group">
        <div className="date-header">{ getStateDate() }</div>
        { getListItem() }
      </div>
    </>
  );
};