Skip to content

Commit 091ef1d

Browse files
committed
docs(demos): add holiday meta
1 parent ad99b55 commit 091ef1d

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

projects/demos/app/demo-modules/public-holidays/component.ts

+21-11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ const HOLIDAY_API_KEY = '8eb2582d-3a4c-4fc5-94c8-3e21487d4e23';
1414
// change this to your own country
1515
const COUNTRY_CODE = 'US';
1616

17+
interface Holiday {
18+
date: string;
19+
name: string;
20+
}
21+
22+
type CalendarEventWithMeta = CalendarEvent<
23+
{ type: 'holiday'; holiday: Holiday } | { type: 'normal' }
24+
>;
25+
1726
@Component({
1827
selector: 'mwl-demo-component',
1928
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -24,7 +33,7 @@ export class DemoComponent implements OnInit {
2433

2534
viewDate = startOfYear(subYears(new Date(), 1));
2635

27-
events: CalendarEvent[] = [];
36+
events: CalendarEventWithMeta[] = [];
2837

2938
constructor(private http: HttpClient, private cdr: ChangeDetectorRef) {}
3039

@@ -34,22 +43,23 @@ export class DemoComponent implements OnInit {
3443

3544
private fetchHolidays() {
3645
this.http
37-
.get<{ holidays: { date: string; name: string }[] }>(
38-
'https://holidayapi.com/v1/holidays',
39-
{
40-
params: {
41-
country: COUNTRY_CODE,
42-
year: String(new Date().getFullYear() - 1),
43-
key: HOLIDAY_API_KEY,
44-
},
45-
}
46-
)
46+
.get<{ holidays: Holiday[] }>('https://holidayapi.com/v1/holidays', {
47+
params: {
48+
country: COUNTRY_CODE,
49+
year: String(new Date().getFullYear() - 1),
50+
key: HOLIDAY_API_KEY,
51+
},
52+
})
4753
.subscribe(({ holidays }) => {
4854
this.events = holidays.map((holiday) => {
4955
return {
5056
start: new Date(holiday.date),
5157
title: holiday.name,
5258
allDay: true,
59+
meta: {
60+
type: 'holiday',
61+
holiday,
62+
},
5363
};
5464
});
5565
this.cdr.markForCheck();

0 commit comments

Comments
 (0)