aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/Product.elm
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-12-26 14:43:50 +0000
committerAkshay <[email protected]>2020-12-26 14:43:50 +0000
commitb8a744f6e7e02f67551124063d3dd97faba5fb0b (patch)
treec219b2177d4608a1862de0d66e978086c06e63f8 /frontend/src/Product.elm
parenta7881f40ccaa623d757e762d1215d5e9bc9d1a7a (diff)
begin work on frontend
Diffstat (limited to 'frontend/src/Product.elm')
-rw-r--r--frontend/src/Product.elm35
1 files changed, 26 insertions, 9 deletions
diff --git a/frontend/src/Product.elm b/frontend/src/Product.elm
index 0ea0ce1..b97a847 100644
--- a/frontend/src/Product.elm
+++ b/frontend/src/Product.elm
@@ -2,14 +2,16 @@ module Product exposing (..)
2 2
3import Browser 3import Browser
4import Browser.Navigation as Nav 4import Browser.Navigation as Nav
5import Html exposing (..) 5import Html
6import Html.Attributes exposing (..) 6import Html.Styled exposing (..)
7import Html.Events exposing (..) 7import Html.Styled.Attributes exposing (..)
8import Html.Styled.Events exposing (..)
8import Http 9import Http
9import Json.Decode as D 10import Json.Decode as D
10import Json.Encode as Encode 11import Json.Encode as Encode
11import Url 12import Url
12import Url.Parser as P exposing ((</>), Parser, int, oneOf, s, string) 13import Url.Parser as P exposing ((</>), Parser, int, oneOf, s, string)
14import Utils exposing (..)
13 15
14 16
15type SubmitStatus 17type SubmitStatus
@@ -25,11 +27,13 @@ type alias Product =
25 , kind : Maybe String 27 , kind : Maybe String
26 , price : Float 28 , price : Float
27 , description : Maybe String 29 , description : Maybe String
30 , src : String
31 , iosSrc : String
28 } 32 }
29 33
30 34
31emptyProduct = 35emptyProduct =
32 Product -1 "" Nothing 0 Nothing 36 Product -1 "" Nothing 0 Nothing "" ""
33 37
34 38
35type alias Rating = 39type alias Rating =
@@ -140,12 +144,14 @@ update msg model =
140 144
141decodeProduct : D.Decoder Product 145decodeProduct : D.Decoder Product
142decodeProduct = 146decodeProduct =
143 D.map5 Product 147 D.map7 Product
144 (D.field "id" D.int) 148 (D.field "id" D.int)
145 (D.field "name" D.string) 149 (D.field "name" D.string)
146 (D.field "kind" (D.nullable D.string)) 150 (D.field "kind" (D.nullable D.string))
147 (D.field "price" D.float) 151 (D.field "price" D.float)
148 (D.field "description" (D.nullable D.string)) 152 (D.field "description" (D.nullable D.string))
153 (D.field "src" D.string)
154 (D.field "ios_src" D.string)
149 155
150 156
151decodeRating : D.Decoder Rating 157decodeRating : D.Decoder Rating
@@ -246,10 +252,21 @@ viewStatus s =
246viewProduct : Product -> Html Msg 252viewProduct : Product -> Html Msg
247viewProduct p = 253viewProduct p =
248 div [] 254 div []
249 [ text p.name 255 [ div [] [ text p.name ]
250 , text <| Maybe.withDefault "" p.kind 256 , div [] [ text <| Maybe.withDefault "" p.kind ]
251 , text <| Maybe.withDefault "" p.description 257 , div [] [ text <| Maybe.withDefault "" p.description ]
252 , text <| String.fromFloat p.price 258 , div [] [ text <| String.fromFloat p.price ]
259 , div []
260 [ modelViewer
261 [ cameraControls
262 , autoRotate
263 , arSrc p.src
264 , arIosSrc p.iosSrc
265 , loading "eager"
266 , arModes "webxr"
267 ]
268 []
269 ]
253 ] 270 ]
254 271
255 272