tutor/www/src/Deck.elm
Correl Roush fcbd583b95 Add card details to the deck editor page
Straightened out a lot of the data modeling.
2023-01-10 21:21:33 -05:00

33 lines
660 B
Elm

module Deck exposing (..)
import Card
import Json.Decode
import Json.Decode.Pipeline as JDP
type alias Deck =
{ id : Int
, name : String
, cards : List Card
}
type alias Card =
{ card : Card.Card
, quantity : Int
}
decode : Json.Decode.Decoder Deck
decode =
Json.Decode.succeed Deck
|> JDP.required "deck_id" Json.Decode.int
|> JDP.required "name" Json.Decode.string
|> JDP.required "cards" (Json.Decode.list decodeCard)
decodeCard : Json.Decode.Decoder Card
decodeCard =
Json.Decode.succeed Card
|> JDP.required "card" Card.decode
|> JDP.required "quantity" Json.Decode.int