forked from fossasia/open-event-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add to Google Calendar (fossasia#5392)
Co-authored-by: Areeb Jamal <jamal.areeb@gmail.com>
- Loading branch information
Showing
5 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div class="ui list basic segment m-0 pb-0"> | ||
<div class="item"> | ||
<i class="clock alternate outline icon pt-1"></i> | ||
<div class="content"> | ||
{{#if this.isSingleDay}} | ||
{{general-date @event.startsAt @event.timezone "dddd, MMMM DD, YYYY"}}<br>{{general-date @event.startsAt @event.timezone "h:mm A"}} {{t 'to'}} {{general-date @event.endsAt @event.timezone "h:mm A"}} | ||
{{else}} | ||
{{general-date @event.startsAt @event.timezone "dddd, MMMM DD, YYYY h:mm A"}} {{t 'to'}} {{general-date @event.endsAt @event.timezone "dddd, MMMM DD, YYYY h:mm A"}} | ||
{{/if}} | ||
({{this.timezone}}) | ||
<br> | ||
<a href={{this.calendarUrl}} target="_blank" rel="noreferrer nofollow">{{t 'Add to Google Calendar'}}</a> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Component from '@glimmer/component'; | ||
import moment, { Moment } from 'moment'; | ||
import Event from 'open-event-frontend/models/event'; | ||
|
||
interface Args { | ||
event: Event, | ||
location: string | ||
} | ||
|
||
export default class AddToCalender extends Component<Args> { | ||
|
||
get timezone(): string { | ||
return moment.tz(this.args.event.timezone).format('z'); | ||
} | ||
|
||
get startsAt(): Moment { | ||
const { event } = this.args; | ||
return moment(event.startsAt).tz(event.timezone); | ||
} | ||
|
||
get endsAt(): Moment { | ||
const { event } = this.args; | ||
return moment(event.endsAt).tz(event.timezone); | ||
} | ||
|
||
get isSingleDay(): boolean { | ||
return this.startsAt.isSame(this.endsAt, 'day'); | ||
} | ||
|
||
get calendarUrl(): string { | ||
const { event } = this.args; | ||
const startTime = this.startsAt.utc().format('YYYYMMDD[T]HHmmSS[Z]'); | ||
const endTime = this.endsAt.utc().format('YYYYMMDD[T]HHmmSS[Z]'); | ||
return `https://calendar.google.com/calendar/render?action=TEMPLATE&dates=${startTime}/${endTime}&text=${event.name}&location=${this.args.location}&ctz=${event.timezone}&details=${event.description}`; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters