xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

calendar merge date

calendar merge date


  componentDidMount () {
    const {
      monthDays,
      // monthDates,
    } = this.props;
    const defaultMonthDays = [...new Uint8Array(monthDays)];
    // default days
    const dateDays = defaultMonthDays.map((item, i) => i+1).map((item, i) => ({
      day: item,
      visible: true,
      selected: false,
      disabled: false,
    }));
    const monthDates = [
      {
        "id": 210404,
        "start": 1617532218562,
        "end": 1617532218562,
        "lowPrice": 127.00,
        "status": 0,
        "priceLowest": false,
        "hasTicket": true,
        "availableNumbers": [
          1,
          2,
          3,
          4,
          5,
          6
        ],
        day: 12,
      },
    ];
    // merge dates
    monthDates.forEach(
      (obj, i) => {
        const {
          day,
        } = obj;
        dateDays.forEach((item, j) => {
          if(item.day === day) {
            dateDays[j] = {
              ...item,
              ...obj,
            };
          }
        })
      }
    )
    log(`merged dateDays`, dateDays);
    this.setState({
      dateDays,
    })
  }

refs



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


posted @ 2020-04-09 20:39  xgqfrms  阅读(149)  评论(1编辑  收藏  举报