adds replaceShop from items
This commit is contained in:
64
src/Main.elm
64
src/Main.elm
@@ -59,6 +59,21 @@ type Page
|
||||
| Loading
|
||||
|
||||
|
||||
|
||||
{-
|
||||
|
||||
type Page
|
||||
= Dashboard Session
|
||||
| GroupChest Session
|
||||
| Shop Shop.Model
|
||||
| NewLoot Session
|
||||
| About
|
||||
| Loading
|
||||
|
||||
|
||||
-}
|
||||
|
||||
|
||||
type alias HasPage r =
|
||||
{ r | page : Page }
|
||||
|
||||
@@ -153,6 +168,9 @@ viewPage page =
|
||||
linkWithGem "Coffre de groupe" "/coffre"
|
||||
]
|
||||
|
||||
Admin _ ->
|
||||
[ navLink "fas fa-store-alt" "Marchand" "/marchand" ]
|
||||
|
||||
_ ->
|
||||
[]
|
||||
in
|
||||
@@ -202,9 +220,9 @@ type Msg
|
||||
= UrlChanged Url.Url
|
||||
| LinkClicked Browser.UrlRequest
|
||||
| SessionLoaded (Maybe Session)
|
||||
| SwitchMenuOpen
|
||||
| GotChestMsg Chest.Msg
|
||||
| GotAdminMsg Admin.Msg
|
||||
| SwitchMenuOpen
|
||||
|
||||
|
||||
|
||||
@@ -226,45 +244,35 @@ update msg model =
|
||||
in
|
||||
case user of
|
||||
Session.Player playerId ->
|
||||
let
|
||||
( chest, cmd ) =
|
||||
Chest.init navKey playerId
|
||||
in
|
||||
( model |> setPage (Chest chest), Cmd.map GotChestMsg cmd )
|
||||
updatePage Chest GotChestMsg model <|
|
||||
Chest.init navKey playerId
|
||||
|
||||
Session.Admin ->
|
||||
let
|
||||
( admin, cmd ) =
|
||||
Admin.init navKey
|
||||
in
|
||||
( model |> setPage (Admin admin), Cmd.map GotAdminMsg cmd )
|
||||
updatePage Admin GotAdminMsg model <|
|
||||
Admin.init logged
|
||||
|
||||
Nothing ->
|
||||
( model |> setPage About, Cmd.none )
|
||||
|
||||
( LinkClicked urlRequest, _ ) ->
|
||||
case model.page of
|
||||
Chest chestModel ->
|
||||
case urlRequest of
|
||||
Browser.Internal url ->
|
||||
( model, Nav.pushUrl model.navbar.navKey (Url.toString url) )
|
||||
case urlRequest of
|
||||
Browser.Internal url ->
|
||||
( model, Nav.pushUrl model.navbar.navKey (Url.toString url) )
|
||||
|
||||
Browser.External href ->
|
||||
( model, Cmd.none )
|
||||
|
||||
_ ->
|
||||
Browser.External href ->
|
||||
( model, Cmd.none )
|
||||
|
||||
( UrlChanged url, page ) ->
|
||||
-- Handle routing according to current page
|
||||
case ( Route.fromUrl url, page ) of
|
||||
( Just (Route.Home content), Chest _ ) ->
|
||||
update
|
||||
(GotChestMsg <| Chest.SetContent content)
|
||||
model
|
||||
( Just (Route.Home content), Chest chest ) ->
|
||||
( model |> setPage (Chest (Chest.setContent content chest))
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
( Just (Route.Home MerchantLoot), Admin _ ) ->
|
||||
( model, Cmd.none )
|
||||
( Just route, Admin admin ) ->
|
||||
Admin.routeChanged route admin
|
||||
|> updatePage Admin GotAdminMsg model
|
||||
|
||||
_ ->
|
||||
( model |> setPage About, Cmd.none )
|
||||
@@ -285,8 +293,8 @@ update msg model =
|
||||
|
||||
|
||||
updatePage : (pageModel -> Page) -> (pageMsg -> Msg) -> Model -> ( pageModel, Cmd pageMsg ) -> ( Model, Cmd Msg )
|
||||
updatePage toModel toMsg model ( pageModel, pageCmd ) =
|
||||
( { model | page = toModel pageModel }
|
||||
updatePage toPage toMsg model ( pageModel, pageCmd ) =
|
||||
( { model | page = toPage pageModel }
|
||||
, Cmd.map toMsg pageCmd
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user