DEV Community

Discussion on: Google Calendar Events with React

Collapse
 
danielmugisha profile image
Daniel MUGISHA

what about creating an event?

Collapse
 
nouran96 profile image
Nouran Samy

This snippet is from the official docs of Google Calendar API

// Refer to the JavaScript quickstart on how to setup the environment:
// https://developers.google.com/calendar/quickstart/js
// Change the scope to 'https://www.googleapis.com/auth/calendar' and delete any
// stored credentials.

var event = {
  'summary': 'Google I/O 2015',
  'location': '800 Howard St., San Francisco, CA 94103',
  'description': 'A chance to hear more about Google\'s developer products.',
  'start': {
    'dateTime': '2015-05-28T09:00:00-07:00',
    'timeZone': 'America/Los_Angeles'
  },
  'end': {
    'dateTime': '2015-05-28T17:00:00-07:00',
    'timeZone': 'America/Los_Angeles'
  },
  'recurrence': [
    'RRULE:FREQ=DAILY;COUNT=2'
  ],
  'attendees': [
    {'email': 'lpage@example.com'},
    {'email': 'sbrin@example.com'}
  ],
  'reminders': {
    'useDefault': false,
    'overrides': [
      {'method': 'email', 'minutes': 24 * 60},
      {'method': 'popup', 'minutes': 10}
    ]
  }
};

var request = gapi.client.calendar.events.insert({
  'calendarId': 'primary',
  'resource': event
});

request.execute(function(event) {
  appendPre('Event created: ' + event.htmlLink);
});
Enter fullscreen mode Exit fullscreen mode

You can find more details about creating events from here
developers.google.com/calendar/api...

Collapse
 
joyfortheppl profile image
joyfortheppl

Hello Dev I have 3 questions.

  1. is all of this code supposed to be on one page ? (App.js)
  2. is all of this code supposed to be inside of the main react component and then return the full calendar function underneath it ?
  3. I'm a tech teacher in the states and this is the best walk thru I have seen. Thank you so much. Is there a github repository for this example ?

thanks.

Thread Thread
 
nouran96 profile image
Nouran Samy • Edited

Hello there,

1,2- All of this code is in the same component but it is just for demo purposes. Feel free to divide it into utils files for the main functions if you want.

3- Thank you so much. You can find the code in here
github.com/Nouran96/full-calendar-...