diff --git a/assets/dist/calendar.min.js b/assets/dist/calendar.min.js
index af0622d..e23dc8d 100644
--- a/assets/dist/calendar.min.js
+++ b/assets/dist/calendar.min.js
@@ -1 +1 @@
-function getDatesInMonth(e){const t=dayjs().month(e).year(),a=dayjs(new Date(t,e,0)).daysInMonth(),n={};for(let o=1;o<=a;o++){const a=dayjs(new Date(t,e,o)),s=a.format("dd")[0].toUpperCase();n[parseInt(a.format("DD"))]={sessions:[],full:a.format("DD-MM-YYYY"),initial:s}}return n}async function getMapadoEvent(e){const t="ticketings/"+e,a={method:"POST",body:JSON.stringify({requestEndPoint:t,requestParams:[],requestFields:[{name:"startDate"},{name:"bookableStock"},{name:"eventDateList",subfields:[{name:"@id"},{name:"bookableStock"}]}]})},n=await fetch("/mapado-api.json",a),o=(await n.json())["hydra:member"];console.log("Événement Mapado",o)}async function getMapadoDates(e){const t=dayjs().month(e).startOf("month").format("YYYY-MM-DD"),a=[{name:"itemsPerPage",value:100},{name:"contract",value:"1941"},{name:"after",value:t},{name:"before",value:dayjs(t).add(1,"month").format("YYYY-MM-DD")},{name:"order",value:"asc"}],n={method:"POST",body:JSON.stringify({requestEndPoint:"event_dates",requestParams:a,requestFields:[{name:"startDate"},{name:"bookableStock"},{name:"ticketing",subfields:[{name:"@id"},{name:"title"},{name:"slug"},{name:"venue",subfields:[{name:"@id"},{name:"address"},{name:"zipCode"},{name:"city"},{name:"countryCode"},{name:"timezone"}]}]}]})},o=await fetch("/mapado-api.json",n),s=(await o.json())["hydra:member"];console.log(`Événements Mapado de ${dayjs(t).format("MMMM")} ${dayjs(t).format("YYYY")}`,s);return s.map((e=>({day:getDay(e),title:e.ticketing.title,startTime:getStartTime(e),ticketingUrl:getTicketingUrl(e),id:getId(e)})))}function getDay(e){return e.startDate.slice(0,10).split("-")[2]}function getStartTime(e){const t=e.startDate.slice(11,19);return dayjs(`2000-01-01T${t}`).format("HH[h]mm")}function getTicketingUrl(e){return"https://cdn-besancon.mapado.com/event/"+e.ticketing.slug}function getId(e){const t=e.ticketing["@id"].split("/");return parseInt(t[3])}function createEmptyCalendar(){const e={};for(let t=9;t<21;t++){const a=(t-1)%12+1,n=dayjs().month(a-1).daysInMonth();e[a]={};for(let t=1;t<=n;t++){const n=dayjs().month(a-1).date(t),o=n.format("dd")[0].toUpperCase();e[a][t]={sessions:[],full:n.format("DD-MM-YYYY"),initial:o,index:parseInt(n.format("DD")),indexInWeek:0===n.day()?7:n.day()}}}return e}async function getCurrentSeasonCalendar(e,t){const a={calendar:createEmptyCalendar()},n={method:"POST",body:JSON.stringify(a)},o=await fetch("/get-current-season-calendar.json",n);return await o.json()}async function updateMapadoEvent(e){const t={method:"POST",headers:new Headers,redirect:"follow",body:JSON.stringify({pageUri:e})},a=await fetch("/update-mapado-event.json",t),n=await a.json();return console.log("Séance récupérées de Mapado",n),n}function dateToFrench(e){return(e=dayjs(e)).format("D MMMM YYYY")}dayjs.locale("fr");
\ No newline at end of file
+function getDatesInMonth(e){const t=dayjs().month(e).year(),a=dayjs(new Date(t,e,0)).daysInMonth(),n={};for(let o=1;o<=a;o++){const a=dayjs(new Date(t,e,o)),s=a.format("dd")[0].toUpperCase();n[parseInt(a.format("DD"))]={sessions:[],full:a.format("DD-MM-YYYY"),initial:s}}return n}async function getMapadoEvent(e){const t="ticketings/"+e,a={method:"POST",body:JSON.stringify({requestEndPoint:t,requestParams:[],requestFields:[{name:"startDate"},{name:"bookableStock"},{name:"eventDateList",subfields:[{name:"@id"},{name:"bookableStock"}]}]})},n=await fetch("/mapado-api.json",a),o=(await n.json())["hydra:member"];console.log("Événement Mapado",o)}async function getMapadoDates(e){const t=dayjs().month(e).startOf("month").format("YYYY-MM-DD"),a=[{name:"itemsPerPage",value:100},{name:"contract",value:"1941"},{name:"after",value:t},{name:"before",value:dayjs(t).add(1,"month").format("YYYY-MM-DD")},{name:"order",value:"asc"}],n={method:"POST",body:JSON.stringify({requestEndPoint:"event_dates",requestParams:a,requestFields:[{name:"startDate"},{name:"bookableStock"},{name:"ticketing",subfields:[{name:"@id"},{name:"title"},{name:"slug"},{name:"venue",subfields:[{name:"@id"},{name:"address"},{name:"zipCode"},{name:"city"},{name:"countryCode"},{name:"timezone"}]}]}]})},o=await fetch("/mapado-api.json",n),s=(await o.json())["hydra:member"];console.log(`Événements Mapado de ${dayjs(t).format("MMMM")} ${dayjs(t).format("YYYY")}`,s);return s.map((e=>({day:getDay(e),title:e.ticketing.title,startTime:getStartTime(e),ticketingUrl:getTicketingUrl(e),id:getId(e)})))}function getDay(e){return e.startDate.slice(0,10).split("-")[2]}function getStartTime(e){const t=e.startDate.slice(11,19);return dayjs(`2000-01-01T${t}`).format("HH[h]mm")}function getTicketingUrl(e){return"https://cdn-besancon.mapado.com/event/"+e.ticketing.slug}function getId(e){const t=e.ticketing["@id"].split("/");return parseInt(t[3])}function createEmptyCalendar(){const e={};for(let t=dayjs().month();t<21;t++){const a=(t-1)%12+1,n=dayjs().month(a-1).daysInMonth();e[a]={};for(let t=1;t<=n;t++){const n=dayjs().month(a-1).date(t),o=n.format("dd")[0].toUpperCase();e[a][t]={sessions:[],full:n.format("DD-MM-YYYY"),initial:o,index:parseInt(n.format("DD")),indexInWeek:0===n.day()?7:n.day()}}}return e}async function getCurrentSeasonCalendar(){const e={calendar:createEmptyCalendar()},t={method:"POST",body:JSON.stringify(e)},a=await fetch("/get-current-season-calendar.json",t);return await a.json()}async function updateMapadoEvent(e){const t={method:"POST",headers:new Headers,redirect:"follow",body:JSON.stringify({pageUri:e})},a=await fetch("/update-mapado-event.json",t),n=await a.json();return console.log("Séance récupérées de Mapado",n),n}function dateToFrench(e){return(e=dayjs(e)).format("D MMMM YYYY")}dayjs.locale("fr");
\ No newline at end of file
diff --git a/assets/js/calendar.js b/assets/js/calendar.js
index 4a7cc6e..c9f5be4 100644
--- a/assets/js/calendar.js
+++ b/assets/js/calendar.js
@@ -149,7 +149,9 @@ function getId(eventData) {
function createEmptyCalendar() {
const calendar = {};
- for (let month = 9; month < 21; month++) {
+ const currentMonth = dayjs().month();
+
+ for (let month = currentMonth; month < 21; month++) {
const normalizedMonth = ((month - 1) % 12) + 1;
const daysInMonth = dayjs()
@@ -178,7 +180,7 @@ function createEmptyCalendar() {
return calendar;
}
-async function getCurrentSeasonCalendar(monthNumb, dates) {
+async function getCurrentSeasonCalendar() {
const calendar = createEmptyCalendar();
const requestParams = {
diff --git a/site/models/event.php b/site/models/event.php
index 96ca828..a67ef0b 100644
--- a/site/models/event.php
+++ b/site/models/event.php
@@ -4,6 +4,10 @@ class EventPage extends Page {
public function schedule() {
$sessions = $this->isMapadoEvent() != 'true' ? $this->sessions()->toStructure() : $this->remoteSessions()->toStructure();
+ if ($sessions->isEmpty()) {
+ throw new Exception('Can\'t define sessions for event "' . $this->title()->value() . '". No sessions found.', 1);
+ }
+
try {
$firstSession = $sessions->first()->date();
$lastSession = $sessions->last()->date();
@@ -18,6 +22,7 @@ class EventPage extends Page {
$isSameMonth = $firstSession->toDate('y-M') === $lastSession->toDate('y-M');
$isSameDay = $firstSession->toDate('d') === $lastSession->toDate('d');
+
if ($isSameMonth) {
if ($isSameDay) {
return $startDay . ' ' . $endMonth;
@@ -28,4 +33,4 @@ class EventPage extends Page {
return $startDay . ' ' . $startMonth . ' - ' . $endDay . ' ' . $endMonth;
}
}
-}
\ No newline at end of file
+}
diff --git a/site/snippets/header.php b/site/snippets/header.php
index 99a39cd..4ed10ca 100644
--- a/site/snippets/header.php
+++ b/site/snippets/header.php
@@ -23,7 +23,7 @@
-
+
diff --git a/site/templates/program.php b/site/templates/program.php
index 558c0d4..7266bcc 100644
--- a/site/templates/program.php
+++ b/site/templates/program.php
@@ -25,11 +25,7 @@
x-text="title"
:class="tab === title ? 'strong' : ''"
@click="
- if (tab === title) {
- tab = 'Programme'
- } else {
- tab = title
- }
+ tab = title
const url = new URL(window.location.href);
url.searchParams.set('tab', tab);
@@ -47,11 +43,7 @@
x-text="title"
:class="tab === filterTitle ? 'strong' : ''"
@click="
- if (tab === filterTitle) {
- tab = 'Programme'
- } else {
- tab = filterTitle; filter = title
- }
+ tab = filterTitle; filter = title
const url = new URL(window.location.href);
url.searchParams.set('tab', tab);