diff options
author | Akshay <[email protected]> | 2020-12-26 14:43:50 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2020-12-26 14:43:50 +0000 |
commit | b8a744f6e7e02f67551124063d3dd97faba5fb0b (patch) | |
tree | c219b2177d4608a1862de0d66e978086c06e63f8 /frontend/src/Product.elm | |
parent | a7881f40ccaa623d757e762d1215d5e9bc9d1a7a (diff) |
begin work on frontend
Diffstat (limited to 'frontend/src/Product.elm')
-rw-r--r-- | frontend/src/Product.elm | 35 |
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 | ||
3 | import Browser | 3 | import Browser |
4 | import Browser.Navigation as Nav | 4 | import Browser.Navigation as Nav |
5 | import Html exposing (..) | 5 | import Html |
6 | import Html.Attributes exposing (..) | 6 | import Html.Styled exposing (..) |
7 | import Html.Events exposing (..) | 7 | import Html.Styled.Attributes exposing (..) |
8 | import Html.Styled.Events exposing (..) | ||
8 | import Http | 9 | import Http |
9 | import Json.Decode as D | 10 | import Json.Decode as D |
10 | import Json.Encode as Encode | 11 | import Json.Encode as Encode |
11 | import Url | 12 | import Url |
12 | import Url.Parser as P exposing ((</>), Parser, int, oneOf, s, string) | 13 | import Url.Parser as P exposing ((</>), Parser, int, oneOf, s, string) |
14 | import Utils exposing (..) | ||
13 | 15 | ||
14 | 16 | ||
15 | type SubmitStatus | 17 | type 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 | ||
31 | emptyProduct = | 35 | emptyProduct = |
32 | Product -1 "" Nothing 0 Nothing | 36 | Product -1 "" Nothing 0 Nothing "" "" |
33 | 37 | ||
34 | 38 | ||
35 | type alias Rating = | 39 | type alias Rating = |
@@ -140,12 +144,14 @@ update msg model = | |||
140 | 144 | ||
141 | decodeProduct : D.Decoder Product | 145 | decodeProduct : D.Decoder Product |
142 | decodeProduct = | 146 | decodeProduct = |
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 | ||
151 | decodeRating : D.Decoder Rating | 157 | decodeRating : D.Decoder Rating |
@@ -246,10 +252,21 @@ viewStatus s = | |||
246 | viewProduct : Product -> Html Msg | 252 | viewProduct : Product -> Html Msg |
247 | viewProduct p = | 253 | viewProduct 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 | ||