2021-09-08 16:30:37 +02:00
|
|
|
defmodule PokemonCoutureWeb.ClothesTrackerLive do
|
|
|
|
use PokemonCoutureWeb, :live_view
|
|
|
|
|
2021-09-13 14:36:14 +02:00
|
|
|
alias PokemonCouture.Shops
|
2021-09-14 17:24:08 +02:00
|
|
|
alias PokemonCouture.Accounts
|
2021-09-24 17:42:14 +02:00
|
|
|
|
2021-09-15 15:22:51 +02:00
|
|
|
def mount(_params, %{"user_token" => user_token} = _session, socket) do
|
|
|
|
user = Accounts.get_user_by_session_token(user_token)
|
2021-10-07 17:26:45 +02:00
|
|
|
clothes_map = Shops.create_shop_map()
|
2021-09-24 17:42:14 +02:00
|
|
|
clothes_map = for {shop, map} <- clothes_map
|
2021-10-07 17:26:45 +02:00
|
|
|
do {shop, Enum.reduce(map, %{}, &Shops.inner_map_creator/2)}
|
2021-09-24 17:42:14 +02:00
|
|
|
end
|
2021-09-08 16:49:52 +02:00
|
|
|
socket =
|
|
|
|
socket
|
2021-09-14 17:24:08 +02:00
|
|
|
|> assign(:clothes_map, clothes_map)
|
|
|
|
|> assign(:user, user)
|
2021-09-08 16:30:37 +02:00
|
|
|
{:ok, socket}
|
|
|
|
end
|
|
|
|
end
|