Skip to content

Commit

Permalink
Merge pull request #253 from ucsdds3/215-create-way-for-users-to-sync…
Browse files Browse the repository at this point in the history
…-to-local-calendar

Added button which allows the creation of an event in the user's calendar
  • Loading branch information
jonathanlo411 authored Jan 16, 2024
2 parents d9bcfa4 + b02acaa commit 36a0857
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/calendarInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ interface CleanEvent {
title: string,
date: string,
time: string,
dateTime: string,
image?: string,
location: {
mapsLocation?: string,
Expand Down
8 changes: 8 additions & 0 deletions src/routes/events/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function handleGoogleCalendarResponse(raw: GoogleCalendarResponse): CleanEvent[]
title: event['summary'].replaceAll("[autogen]", ""),
date: dtString[0],
time: dtString[1],
datetime: dateToRFC5545(event["start"]["dateTime"],event["end"]["dateTime"]),
location: {
mapsLocation: (event["location"]) ? event["location"].trim() : undefined,
roomLocation: (parsed) ? parsed["roomLocation"] : undefined
Expand All @@ -63,6 +64,13 @@ function handleGoogleCalendarResponse(raw: GoogleCalendarResponse): CleanEvent[]
return cleanedEvents
}

function dateToRFC5545(start: string, end: string): string {
start = new Date(start).toISOString().replace(/-|:/g, "")
end = new Date(end).toISOString().replace(/-|:/g, "")

return start + "/" + end
}


export async function load() {

Expand Down
33 changes: 33 additions & 0 deletions src/routes/events/eventCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@
<button class="reg disabled" disabled>Register</button>
</div>
{/if}
{#if event.location.roomLocation != undefined}
<span>
<div id="button-wrapper">
<a href="https://calendar.google.com/calendar/u/0/r/eventedit?text={event.title}&dates={event.dateTime}&details={eventDescription}&location={event.location.roomLocation}" rel="external noreferrer" target="_blank" style="text-decoration:none">Add to Calendar</a>
</div>
</span>
{:else}
<span>
<div id="button-wrapper">
<a href="https://calendar.google.com/calendar/u/0/r/eventedit?text={event.title}&dates={event.dateTime}&details={eventDescription}" rel="external noreferrer" target="_blank" style="text-decoration:none">Add to Calendar</a>
</div>
</span>
{/if}

<div id="modal-spacer">.</div>
</div>
</div>
Expand Down Expand Up @@ -228,6 +242,25 @@
width: 100%;
display: inline-block;
}
#button-wrapper a {
background-color: var(--ds3-orange);
display: inline-block;
border: none;
font-size: 1.5vh;
font-weight: bold;
padding: 1.5% 4%;
color: white;
border-radius: 5px;
text-align: center;
display: inline-block;
align-items: center;
width: auto;
margin-top: 1.5vh;
}
#button-wrapper a:hover {
cursor: pointer;
background-color: var(--ds3-orange-lighten);
}
#button-wrapper button {
background-color: var(--ds3-orange);
display: inline-block;
Expand Down

1 comment on commit 36a0857

@vercel
Copy link

@vercel vercel bot commented on 36a0857 Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ds3-site – ./

ds3ucsd.com
www.ds3ucsd.com
ds3-site-git-main-ds3.vercel.app
ds3-site-ds3.vercel.app
ds3-site.vercel.app

Please sign in to comment.