Skip to content

Commit 4d55bb8

Browse files
committed
fixed issue with google calendar imports, only show button when duties are assigned
1 parent 14377ae commit 4d55bb8

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

src/lib/utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,14 @@ export const generateIcs = (assignments, wcif, fileName: string) => {
181181
const startDate = new Date(item.activity.startTime);
182182
const endDate = new Date(item.activity.endTime);
183183

184+
let alarm = [
185+
{
186+
action: 'display',
187+
description: titleFormatted,
188+
trigger: { minutes: 5, before: true },
189+
},
190+
];
191+
184192
const startDateArray: ics.DateArray = [
185193
startDate.getFullYear(),
186194
startDate.getMonth() + 1, // Months are 1-indexed in ics format
@@ -209,6 +217,7 @@ export const generateIcs = (assignments, wcif, fileName: string) => {
209217
...(wcif.schedule.venues.length > 1 ? {} : { geo: location }),
210218
start: startDateArray,
211219
end: endDateArray,
220+
alarms: alarm,
212221
};
213222

214223
events.push(icalEvent);
@@ -228,6 +237,5 @@ export const generateIcs = (assignments, wcif, fileName: string) => {
228237

229238
document.body.appendChild(a);
230239
a.click();
231-
232240
document.body.removeChild(a);
233241
};

src/pages/Competition/Person/index.tsx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -441,20 +441,24 @@ export default function PersonPage() {
441441
<DisclaimerText />
442442
<hr className="my-2" />
443443
{person?.assignments && person.assignments.length > 0 ? (
444-
renderAssignments()
444+
<div>
445+
{renderAssignments()}
446+
<div className="flex items-center justify-center">
447+
<button
448+
onClick={() =>
449+
generateIcs(assignmentsWithParsedDate, wcif, `${wcif?.name} ${person.name}`)
450+
}
451+
className="my-2 bg-white text-blue-500 border border-blue-500 p-2 rounded-md"
452+
style={{ width: '300px' }}>
453+
Download Calendar Export
454+
</button>
455+
</div>
456+
</div>
445457
) : (
446-
<div>No Assignments</div>
458+
<div className="flex items-center justify-center">
459+
<div>No Assignments</div>
460+
</div>
447461
)}
448-
<div className="flex items-center justify-center">
449-
<button
450-
onClick={() =>
451-
generateIcs(assignmentsWithParsedDate, wcif, `${wcif?.name} ${person.name}`)
452-
}
453-
className="my-2 bg-white text-blue-500 border border-blue-500 p-2 rounded-md"
454-
style={{ width: '300px' }}>
455-
Download Calendar Export
456-
</button>
457-
</div>
458462
</div>
459463
);
460464
}

0 commit comments

Comments
 (0)