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

export const ListDateGroup = ({
  additionalServiceCategory,
  date,
  items,
  mid,
  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 }
            bankName={ items[i]?.bankName}
            accountName={ items[i]?.accountName}
            accountNo={ items[i]?.accountNo }
            transferStatus={ items[i]?.transferStatus}
            resultStatus={ items[i]?.resultStatus }

            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 }

            transferAmount={ items[i]?.transferAmount }
            receiveBankName={ items[i]?.receiveBankName }
            receiveAccountNo={ items[i]?.receiveAccountNo }
            receiveAccountName={ items[i]?.receiveAccountName }
            status={ items[i]?.status }
            processDate={ items[i]?.processDate }

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

            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>
    </>
  );
};