angular-calendar icon indicating copy to clipboard operation
angular-calendar copied to clipboard

angular-calendar Event is missing the `start` property

Open jimix974 opened this issue 3 years ago • 6 comments

Hello, I zak,

I try to use angular-calendar with my data from an API

this.events$ =  this.Api.getSchedule()
   .pipe(
       map(({ data }: { data: any }) => {
           return data.mydatas.map((user: Schedule) => {
                return user.myShedule.map((myShedule: Schedule) => {
                     return {
                        title: user.username,
                        start: new Date(myshedule.begin),
                        color: colors.yellow,
                        allDay: true,
                     }});
               });
            })
        );

I get an error angular-calendar Event is missing the start property

Do you know what is the problem please ? thanks a lot

Minimal reproduction of the problem with instructions

Versions

  • @angular/core: "^8.1.1"
  • angular-calendar: "0.27.13"
  • Browser name and version: chrome 89

jimix974 avatar Apr 30 '21 01:04 jimix974

Thanks so much for opening an issue! If you'd like me to give priority to answering your issue or would just like to support this project, then please consider sponsoring me

matts-bot[bot] avatar Apr 30 '21 01:04 matts-bot[bot]

@jimix974 Can you please update the description with the full logs of your error ?

billyjov avatar May 01 '21 22:05 billyjov

@billyjov I found where I get an error

this.events$ =  this.restApi.getSchedule()
            .pipe(
              map(({ data }: { data: Schedule[] }) => {
              return data.mydatas.map((user: Schedule) => {
                return {
                  title: user.username,
                  start: new Date(
                    user.period.begin + getTimezoneOffsetString(this.viewDate)
                  ),
                  color: colors.yellow,
                  allDay: true,

                };
              });
            })
          );

There is no error now, but my real problem is to map my datas

my json return something like this:

{
   "username":"jean",
   "period":[
      {
         "begin":"2021-02-07T15:57:30+0200",
         "title":"mytitle"
      },
      {
         "begin":"2021-02-09T15:57:30+0200",
         "title":"mytitle"
      },
   ],
}
{
   "username":"james",
   "period":[
      {
         "begin":"2021-02-08T15:57:30+0200",
         "title":"mytitle"
      },
      {
         "begin":"2021-02-09T15:57:30+0200",
         "title":"mytitle"
      },
   ],
}

I search how to map "begin" data to "start" property

Thanks

jimix974 avatar May 02 '21 11:05 jimix974

@billyjov I found where I get an error

this.events$ =  this.restApi.getSchedule()
            .pipe(
              map(({ data }: { data: Schedule[] }) => {
              return data.mydatas.map((user: Schedule) => {
                return {
                  title: user.username,
                  start: new Date(
                    user.period.begin + getTimezoneOffsetString(this.viewDate)
                  ),
                  color: colors.yellow,
                  allDay: true,

                };
              });
            })
          );

There is no error now, but my real problem is to map my datas

my json return something like this:

{
   "username":"jean",
   "period":[
      {
         "begin":"2021-02-07T15:57:30+0200",
         "title":"mytitle"
      },
      {
         "begin":"2021-02-09T15:57:30+0200",
         "title":"mytitle"
      },
   ],
}
{
   "username":"james",
   "period":[
      {
         "begin":"2021-02-08T15:57:30+0200",
         "title":"mytitle"
      },
      {
         "begin":"2021-02-09T15:57:30+0200",
         "title":"mytitle"
      },
   ],
}

I search how to map "begin" data to "start" property

Thanks

jimix974 avatar May 02 '21 11:05 jimix974

@billyjov I found where I get an error

this.events$ =  this.restApi.getSchedule()
            .pipe(
              map(({ data }: { data: Schedule[] }) => {
              return data.mydatas.map((user: Schedule) => {
                return {
                  title: user.username,
                  start: new Date(
                    user.period.begin + getTimezoneOffsetString(this.viewDate)
                  ),
                  color: colors.yellow,
                  allDay: true,

                };
              });
            })
          );

There is no error now, but my real problem is to map my datas

my json return something like this:

{
   "username":"jean",
   "period":[
      {
         "begin":"2021-02-07T15:57:30+0200",
         "title":"mytitle"
      },
      {
         "begin":"2021-02-09T15:57:30+0200",
         "title":"mytitle"
      },
   ],
}
{
   "username":"james",
   "period":[
      {
         "begin":"2021-02-08T15:57:30+0200",
         "title":"mytitle"
      },
      {
         "begin":"2021-02-09T15:57:30+0200",
         "title":"mytitle"
      },
   ],
}

I search how to map "begin" data to "start" property

Thanks

jimix974 avatar May 02 '21 11:05 jimix974

@jimix974 user.period is an array ? So user.period.begin will always return undefined I think ? :thinking:

GentileFulvio avatar Jun 01 '21 11:06 GentileFulvio