-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea68e05
commit 844a945
Showing
4 changed files
with
63 additions
and
69 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
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,39 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { addQueryArgs } from '@wordpress/url'; | ||
import { Button, ButtonGroup } from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { useEvents } from '../store/event-context'; | ||
|
||
const Feed = () => { | ||
const { teams, team } = useEvents(); | ||
const selected = teams.find( ( option ) => team === option.value ); | ||
|
||
const getCalendarUrl = () => { | ||
const baseUrl = window.location.origin; | ||
if ( ! selected ) { | ||
return `${baseUrl}/meetings.ics`; | ||
} | ||
return `${baseUrl}/meetings-${selected.value}.ics`; | ||
}; | ||
|
||
const getGoogleCalendarUrl = () => { | ||
const calendarUrl = getCalendarUrl().replace('https://', 'webcal://'); | ||
return addQueryArgs('https://www.google.com/calendar/render', { | ||
cid: calendarUrl, | ||
}); | ||
}; | ||
|
||
return ( | ||
<div className="wporg-meeting-calendar__feed"> | ||
<span>{ __( 'Subscribe to this calendar:', 'wporg-meeting-calendar' ) }</span> <a href={ getGoogleCalendarUrl() }>Google Calendar ↗</a> · <a href={ getCalendarUrl() }>ICS</a> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Feed; |
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