diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index a6e4de5..3199526 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -15,6 +15,25 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@fullcalendar/core": { + "version": "6.1.20", + "resolved": "https://registry.npmjs.org/@fullcalendar/core/-/core-6.1.20.tgz", + "integrity": "sha512-1cukXLlePFiJ8YKXn/4tMKsy0etxYLCkXk8nUCFi11nRONF2Ba2CD5b21/ovtOO2tL6afTJfwmc1ed3HG7eB1g==", + "dev": true, + "dependencies": { + "preact": "~10.12.1" + } + }, + "node_modules/@fullcalendar/core/node_modules/preact": { + "version": "10.12.1", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.12.1.tgz", + "integrity": "sha512-l8386ixSsBdbreOAkqtrwqHwdvR35ID8c3rKPa8lCWuO86dBi32QWHV4vfsZK1utLLFMvw+Z5Ad4XLkZzchscg==", + "dev": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/preact" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.13", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", diff --git a/package-lock.json b/package-lock.json index 7d8399c..321f301 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,6 +6,7 @@ "": { "name": "riverside-therapeutics", "devDependencies": { + "@fullcalendar/core": "^6.1.20", "htm": "^3.1.1", "preact": "^10.29.2", "tailwindcss": "^3.4.17", @@ -24,6 +25,25 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@fullcalendar/core": { + "version": "6.1.20", + "resolved": "https://registry.npmjs.org/@fullcalendar/core/-/core-6.1.20.tgz", + "integrity": "sha512-1cukXLlePFiJ8YKXn/4tMKsy0etxYLCkXk8nUCFi11nRONF2Ba2CD5b21/ovtOO2tL6afTJfwmc1ed3HG7eB1g==", + "dev": true, + "dependencies": { + "preact": "~10.12.1" + } + }, + "node_modules/@fullcalendar/core/node_modules/preact": { + "version": "10.12.1", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.12.1.tgz", + "integrity": "sha512-l8386ixSsBdbreOAkqtrwqHwdvR35ID8c3rKPa8lCWuO86dBi32QWHV4vfsZK1utLLFMvw+Z5Ad4XLkZzchscg==", + "dev": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/preact" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.13", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", diff --git a/package.json b/package.json index 210a1a1..1db6890 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,11 @@ "private": true, "scripts": { "watch": "tailwindcss -i ./web/modules/custom/riverside_pt/css/tailwind.css -o ./web/modules/custom/riverside_pt/css/app.css --watch", - "build": "tailwindcss -i ./web/modules/custom/riverside_pt/css/tailwind.css -o ./web/modules/custom/riverside_pt/css/app.css --minify" + "build": "tailwindcss -i ./web/modules/custom/riverside_pt/css/tailwind.css -o ./web/modules/custom/riverside_pt/css/app.css --minify", + "typecheck": "tsc --noEmit" }, "devDependencies": { + "@fullcalendar/core": "^6.1.20", "htm": "^3.1.1", "preact": "^10.29.2", "tailwindcss": "^3.4.17", diff --git a/web/modules/custom/riverside_pt/js/components/rpt-booking.js b/web/modules/custom/riverside_pt/js/components/rpt-booking.js index fcc515a..07d8982 100644 --- a/web/modules/custom/riverside_pt/js/components/rpt-booking.js +++ b/web/modules/custom/riverside_pt/js/components/rpt-booking.js @@ -197,7 +197,7 @@ function BookingPanel({ service, settings }) { dayCellClassNames: function (/** @type {any} */ arg) { var date = arg.date.toISOString().substring(0, 10); - if (settings.holidays[date]) return ["is-holiday"]; + return settings.holidays[date] ? ["is-holiday"] : []; }, dateClick: function (/** @type {any} */ arg) { @@ -221,7 +221,9 @@ function BookingPanel({ service, settings }) { cal.render(); calRef.current = cal; - window.rptScrollTo(cal, true); + requestAnimationFrame(() => { + window.rptScrollTo(rootEl, true); + }) return function () { cal.destroy(); }; }, []); diff --git a/web/modules/custom/riverside_pt/js/globals.d.ts b/web/modules/custom/riverside_pt/js/globals.d.ts index 7e15ab1..0d49652 100644 --- a/web/modules/custom/riverside_pt/js/globals.d.ts +++ b/web/modules/custom/riverside_pt/js/globals.d.ts @@ -1,25 +1,42 @@ -interface RiversidePtSettings { - eventsUrl: string; - storeSlotUrl: string; - bookingUrl?: string; - holidays: Record; - scrollTo?: string; -} +import type { Calendar } from "@fullcalendar/core"; -interface RiversidePtEvent { - id: number | string; - title?: string; - start: string; - end: string; - startStr?: string; -} +declare global { + interface RiversidePtSettings { + eventsUrl: string; + storeSlotUrl: string; + bookingUrl?: string; + holidays: Record; + scrollTo?: string; + } -interface Window { - FullCalendar?: any; - rptScrollTo: (el: Element, animate?: boolean) => void; - drupalSettings?: { - riversidePt?: RiversidePtSettings; - }; -} + interface RiversidePtEvent { + id: number | string; + title?: string; + start: string; + end: string; + startStr?: string; + } -declare const FullCalendar: any; + interface ConfirmedAppointment { + start: string; + service: string; + firstName: string; + lastName: string; + email: string; + } + + // FullCalendar is loaded as a UMD global. The Calendar constructor accepts + // any options object because plugin-specific options (e.g. dateClick from + // @fullcalendar/interaction) are not reflected in @fullcalendar/core types. + namespace FullCalendar { + const Calendar: new (el: HTMLElement, options?: Record) => Calendar; + } + + interface Window { + FullCalendar?: typeof FullCalendar; + rptScrollTo: (el: Element, animate?: boolean) => void; + drupalSettings?: { + riversidePt?: RiversidePtSettings; + }; + } +}