try fix event
This commit is contained in:
parent
3809d96504
commit
ece995352f
5 changed files with 14 additions and 15 deletions
2
assets/dist/calendar.min.js
vendored
2
assets/dist/calendar.min.js
vendored
|
|
@ -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");
|
||||
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");
|
||||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/locale/fr.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/plugin/weekOfYear.js"></script>
|
||||
<script src="<?= url('/assets/dist/calendar.min.js') ?>"></script>
|
||||
<script src="<?= url('/assets/js/calendar.js') ?>"></script>
|
||||
<?php endif ?>
|
||||
|
||||
<!-- Swiper -->
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue