Skip to content

Commit

Permalink
Limit partner event listing to current partner
Browse files Browse the repository at this point in the history
  • Loading branch information
katjam committed Sep 25, 2024
1 parent 8446fcd commit 6500290
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions app/Route/Partners/Partner_.elm
Original file line number Diff line number Diff line change
Expand Up @@ -111,28 +111,32 @@ update :
-> Model
-> ( Model, Effect.Effect Msg )
update app shared msg model =
let
aPartner =
Data.PlaceCal.Partners.partnerFromSlug app.sharedData.partners app.routeParams.partner
in
case msg of
ClickedDay posix ->
( { model
| filterBy = Theme.Paginator.Day posix
, visibleEvents =
Data.PlaceCal.Events.eventsFromDate app.sharedData.events posix
eventsFromPartnerId aPartner.id (Data.PlaceCal.Events.eventsFromDate app.sharedData.events posix)
}
, Effect.none
)

ClickedAllPastEvents ->
( { model
| filterBy = Theme.Paginator.Past
, visibleEvents = List.reverse (Data.PlaceCal.Events.onOrBeforeDate app.sharedData.events model.nowTime)
, visibleEvents = eventsFromPartnerId aPartner.id (List.reverse (Data.PlaceCal.Events.onOrBeforeDate app.sharedData.events model.nowTime))
}
, Effect.none
)

ClickedAllFutureEvents ->
( { model
| filterBy = Theme.Paginator.Future
, visibleEvents = Data.PlaceCal.Events.afterDate app.sharedData.events model.nowTime
, visibleEvents = eventsFromPartnerId aPartner.id (Data.PlaceCal.Events.afterDate app.sharedData.events model.nowTime)
}
, Effect.none
)
Expand All @@ -142,7 +146,7 @@ update app shared msg model =
| filterBy = Theme.Paginator.Day newTime
, nowTime = newTime
, visibleEvents =
Data.PlaceCal.Events.eventsFromDate app.sharedData.events newTime
eventsFromPartnerId aPartner.id (Data.PlaceCal.Events.eventsFromDate app.sharedData.events newTime)
}
, Effect.none
)
Expand Down Expand Up @@ -219,7 +223,9 @@ view app shared model =
, innerContent =
Just
(Theme.PartnerPage.viewInfo model
{ partner = aPartner, events = app.sharedData.events }
{ partner = aPartner
, events = eventsFromPartnerId aPartner.id app.sharedData.events
}
)
, outerContent = Just (Theme.Global.viewBackButton (Helpers.TransRoutes.toAbsoluteUrl Partners) (t BackToPartnersLinkText))
}
Expand All @@ -241,3 +247,8 @@ pages =
Data.PlaceCal.Partners.partnersDecoder
)
|> BackendTask.allowFatal


eventsFromPartnerId : String -> List Data.PlaceCal.Events.Event -> List Data.PlaceCal.Events.Event
eventsFromPartnerId partnerId eventList =
List.filter (\event -> partnerId == event.partner.id) eventList

0 comments on commit 6500290

Please sign in to comment.