fix: schedule hours merging

This commit is contained in:
Matthieu Bessat 2020-08-04 12:24:58 +02:00
parent 4817bc216d
commit 9c403260b7
2 changed files with 25 additions and 30 deletions

View file

@ -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)