Add google calendar link to events · codeday/web@0a3d96d · GitHub
Skip to content

Commit 0a3d96d

Browse files
committed
Add google calendar link to events
1 parent 6c7b359 commit 0a3d96d

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎package.json‎

Lines changed: 1 addition & 0 deletions

‎src/components/EventInfo.js‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useToasts, apiFetch } from '@codeday/topo/utils';
99
import { DateTime } from 'luxon';
1010
import TimeAgo from 'javascript-time-ago';
1111
import en from 'javascript-time-ago/locale/en';
12+
import { stringify as urlencode } from 'urlencode';
1213
import { SubscribeToEvent } from './EventInfo.gql'
1314

1415
const SERVER_TIMEZONE = 'America/Los_Angeles';
@@ -17,6 +18,18 @@ function SubscribeBox({ event, ...rest }) {
1718
const { success, error } = useToasts();
1819
const [isLoading, setIsLoading] = useState(false);
1920
const [destination, setDestination] = useState('');
21+
const dtFormat = `yyyyLLdd'T'HHmmssZZZ`;
22+
const start = DateTime.fromISO(event.start).toFormat(dtFormat);
23+
const end = DateTime.fromISO(event.end).toFormat(dtFormat);
24+
const addLinkGoogleParams = urlencode({
25+
action: 'TEMPLATE',
26+
text: event.title,
27+
dates: `${start}/${end}`,
28+
location: event.location,
29+
sf: 'true',
30+
output: 'xml',
31+
});
32+
const addLinkGoogle = `https://www.google.com/calendar/render?${addLinkGoogleParams}`;
2033
return (
2134
<Box {...rest}>
2235
<Input
@@ -47,6 +60,7 @@ function SubscribeBox({ event, ...rest }) {
4760
>
4861
Remind Me
4962
</Button>
63+
<Button as="a" href={addLinkGoogle} target="_blank" ml={2}>Add to Google Calendar</Button>
5064
</Box>
5165
)
5266
}

‎yarn.lock‎

Lines changed: 8 additions & 1 deletion

0 commit comments

Comments
 (0)