diff --git a/src/controllers/PublicController.ts b/src/controllers/PublicController.ts index fc58eb8..06e46d2 100644 --- a/src/controllers/PublicController.ts +++ b/src/controllers/PublicController.ts @@ -101,7 +101,7 @@ export default class PublicController { let formatPhone = (phone: string) => { if (phone.indexOf('+33') === 0) { phone = '0' + phone.substr(3) - } + } let phoneSplit = '' let partEnd = false for (var i = 0; i < phone.length; i++) { @@ -111,7 +111,7 @@ export default class PublicController { } partEnd = !partEnd } - return [ "+33" + phone.substr(1), phoneSplit ] + return ["+33" + phone.substr(1), phoneSplit] } if (Utils.isUsable(version.contacts)) { @@ -142,28 +142,23 @@ export default class PublicController { // TODO: Rassembler les horaires qui sont dans le même jour, uniquement pour le front - // version.schedule = version.schedule.map((s: any) => { - // let newWhens: any = [] - // console.log(s) - // // s.when.foreach((w: any) => { - // // // if there is already a when with the same day add it - // // let scheduleObject: any = { from: w.from, to: w.to } - // // if (newWhens.filter((_n: any) => _n.day === w.day).length > 0) { - // // newWhens.map((newWhen: any) => { - // // if (newWhen.day === w.day) { - // // newWhen.hours.push(scheduleObject) - // // } - // // return newWhen - // // }) - // // } else { - // // w.hours = [scheduleObject] - // // newWhens.push(w) - // // } - // // }) - // // s.when = newWhens - // return s - // }) - + version.schedule = version.schedule.map((s: any) => { + let days = [...new Set(s.when.map((w: any) => w.day))] + return { + when: days.map((day: any) => { + return { + day, + wow: 'wow', + hours: s.when + .filter((w: any) => w.day === day) + .map((hour: any) => { return { from: hour.from, to: hour.to } }) + } + }), + name: s.name, + description: s.description + } + }) + // if (version.cutDescription) { // version.descriptionFirstHalf = version.descriptionLong.substr(0, 200) // not gonna lie // version.descriptionSecondHalf = version.descriptionLong.substr(200) diff --git a/views/organization.twig b/views/organization.twig index 50bedbb..8cf57b6 100644 --- a/views/organization.twig +++ b/views/organization.twig @@ -106,7 +106,7 @@
- {{ item.name }} - {{ item.description }} + {{ item.name }} {% if item.description is not empty %}- {{ item.description }}{% endif %}
- {% for when in item.when %} + {# {% for when in item.when %}
{{ when.day }} @@ -124,8 +124,8 @@ {{ when.from }} - {{ when.to }}
- {% endfor %} - {# {% for when in item.when %} + {% endfor %} #} + {% for when in item.when %}
{{ when.day }} @@ -133,12 +133,12 @@
{% for i in when.hours %} - {{ i.from }} - {{ i.to }} + {{ i.from }} - {{ i.to }}{% if not loop.last %},{% endif %} {% endfor %}
- {% endfor %} #} + {% endfor %}