Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Elevator Closures at home station #2338

Merged
merged 18 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions assets/src/components/v2/elevator/elevator_closures_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,23 @@ const OutsideClosureList = ({

interface Props extends WrappedComponentProps {
id: string;
in_station_closures: Closure[];
other_stations_with_closures: StationWithClosures[];
stations_with_closures: StationWithClosures[];
station_id: string;
}

const ElevatorClosuresList = ({
other_stations_with_closures: stations,
in_station_closures: inStationClosures,
stations_with_closures: stations,
station_id: stationId,
lastUpdate,
onFinish,
}: Props) => {
return (
<div className="elevator-closures-list">
<InStationSummary closures={inStationClosures} />
<InStationSummary
closures={stations
.filter((s) => s.id === stationId)
.flatMap((s) => s.closures)}
/>
<OutsideClosureList
stations={stations}
stationId={stationId}
Expand Down
7 changes: 3 additions & 4 deletions lib/screens/v2/candidate_generator/elevator/closures.ex
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ defmodule Screens.V2.CandidateGenerator.Elevator.Closures do
{elevator_widget_instance, header_footer_variant} =
if is_nil(current_elevator_closure) do
{%ElevatorClosuresList{
in_station_closures: in_station_closures,
digitalcora marked this conversation as resolved.
Show resolved Hide resolved
other_stations_with_closures:
format_outside_closures(
stations_with_closures:
build_stations_with_closures(
elevator_alerts,
parent_station_map,
routes_map
Expand Down Expand Up @@ -160,7 +159,7 @@ defmodule Screens.V2.CandidateGenerator.Elevator.Closures do
}
end

defp format_outside_closures(alerts, station_id_to_name, station_id_to_routes) do
defp build_stations_with_closures(alerts, station_id_to_name, station_id_to_routes) do
alerts
|> Enum.group_by(&get_parent_station_id_from_informed_entities(&1.informed_entities))
|> Enum.map(fn {parent_station_id, alerts} ->
Expand Down
11 changes: 4 additions & 7 deletions lib/screens/v2/widget_instance/elevator_closures_list.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ defmodule Screens.V2.WidgetInstance.ElevatorClosuresList do
alias Screens.V2.WidgetInstance.Elevator.Closure
alias ScreensConfig.V2.Elevator

defstruct ~w[app_params in_station_closures other_stations_with_closures station_id]a
defstruct ~w[app_params stations_with_closures station_id]a

@type t :: %__MODULE__{
app_params: Elevator.t(),
in_station_closures: list(Closure.t()),
other_stations_with_closures: list(__MODULE__.Station.t()),
stations_with_closures: list(__MODULE__.Station.t()),
station_id: String.t()
}

Expand All @@ -34,14 +33,12 @@ defmodule Screens.V2.WidgetInstance.ElevatorClosuresList do

def serialize(%__MODULE__{
app_params: %Elevator{elevator_id: id},
in_station_closures: in_station_closures,
other_stations_with_closures: other_stations_with_closures,
stations_with_closures: stations_with_closures,
station_id: station_id
}),
do: %{
id: id,
in_station_closures: in_station_closures,
other_stations_with_closures: other_stations_with_closures,
stations_with_closures: stations_with_closures,
station_id: station_id
}

Expand Down