Skip to content

Commit

Permalink
- adjust showing upcoming meetup (#85)
Browse files Browse the repository at this point in the history
* - adjust showing upcoming meetup

* - fix closing images in gallery

* - fix closing images in gallery

* - adjust processing past meetups

* - cr fix

* Update public/application.js

Co-authored-by: Dawid Rudnik <48356242+dawidrudnik@users.noreply.github.com>

* - fix

* - cr fix

* - cr fix

* - cr fix

---------

Co-authored-by: Dawid Rudnik <48356242+dawidrudnik@users.noreply.github.com>
  • Loading branch information
EwelinaSkrzypacz and dawidrudnik authored Sep 24, 2024
1 parent 98df8fc commit cd7c5ce
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
33 changes: 21 additions & 12 deletions public/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function initialize() {
await this.fetchData()
this.calculateCounters()
this.processPastMeetups()
this.loadUpcomingMeetup()
setInterval(() => {
this.calculateCounters()
}, 1000)
Expand Down Expand Up @@ -79,9 +80,15 @@ function initialize() {
}
},
loadUpcomingMeetup: function () {
const upcomingMeetup = this.meetups.find(
(meetup) => new Date(meetup.datetime) > new Date()
)
const now = moment()
const endOfDay = moment().endOf('day')

const upcomingMeetup = this.meetups.find((meetup) => {
const meetupDate = moment(meetup.datetime)

return meetupDate.isSameOrAfter(now, 'day')
})

if (upcomingMeetup) {
this.processMeetup(upcomingMeetup)
}
Expand All @@ -92,15 +99,18 @@ function initialize() {
)
if (specificMeetup) {
this.processMeetup(specificMeetup)
} else {
console.error('Meetup not found')
}
},
processMeetup: function (meetup) {
let time = moment(meetup.datetime).locale('pl')
meetup.date = time.format('DD MMMM')
meetup.time = time.format('HH:mm')
meetup.year = time.format('Y')
const meetupDate = moment(meetup.datetime)
const endOfMeetupDay = meetupDate.endOf('day')

meetup.isPastEndOfDay = moment().isAfter(endOfMeetupDay)

meetup.agenda = meetup.agenda.map((lecture) => ({
...lecture,
expanded: false,
Expand Down Expand Up @@ -135,9 +145,13 @@ function initialize() {
}
},
processPastMeetups: function () {
const now = new Date()
const now = moment()

this.pastMeetups = this.meetups
.filter((meetup) => new Date(meetup.datetime) < now)
.filter((meetup) => {
const meetupDate = moment(meetup.datetime)
return meetupDate.isBefore(now, 'day')
})
.map((meetup) => ({
...meetup,
formattedDate: this.formatDate(meetup.datetime),
Expand Down Expand Up @@ -174,11 +188,6 @@ function initialize() {
).padStart(2, '0')
}
},
initializeSpeakers: function () {
if (this.meetup && this.meetup.lineup && this.meetup.lineup.length > 0) {
this.selectedSpeakerIndex = 0
}
},
selectPreviousSpeaker: function () {
if (this.meetup && this.meetup.lineup) {
this.selectedSpeakerIndex =
Expand Down
1 change: 1 addition & 0 deletions public/meetup.html
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ <h2 class="text-5xl font-bold">Galeria</h2>
x-show="lightbox.visible"
x-transition
class="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-70"
@click.self="closeLightbox()"
>
<button
@click="closeLightbox()"
Expand Down

0 comments on commit cd7c5ce

Please sign in to comment.