@@ -6,6 +6,8 @@ module App.Types
6
6
Action (.. ),
7
7
St (.. ),
8
8
newSt ,
9
+ Asset (.. ),
10
+ newAsset ,
9
11
Screen (.. ),
10
12
isQrCode ,
11
13
unQrCode ,
@@ -34,7 +36,7 @@ import Data.Functor.Barbie
34
36
import qualified Data.Version as Version
35
37
import Functora.Cfg
36
38
import Functora.Miso.Prelude
37
- import Functora.Miso.Types as X hiding (Asset (.. ))
39
+ import Functora.Miso.Types as X hiding (Asset (.. ), newAsset )
38
40
import Functora.Money hiding (Currency , Money , Text )
39
41
import qualified Functora.Prelude as Prelude
40
42
import qualified Functora.Rates as Rates
@@ -121,10 +123,11 @@ newSt = do
121
123
}
122
124
123
125
data Asset f = Asset
124
- { assetLink :: Field URI f ,
125
- assetPhoto :: Field URI f ,
126
+ { assetLink :: Field Unicode f ,
127
+ assetPhoto :: Field Unicode f ,
126
128
assetPrice :: Field Rational f ,
127
- assetQty :: Field Rational f
129
+ assetQty :: Field Rational f ,
130
+ assetOoc :: OpenedOrClosed
128
131
}
129
132
deriving stock (Generic )
130
133
@@ -142,6 +145,21 @@ instance TraversableB Asset
142
145
143
146
deriving via GenericType (Asset Identity ) instance Binary (Asset Identity )
144
147
148
+ newAsset :: (MonadIO m ) => m (Asset Unique )
149
+ newAsset = do
150
+ link <- newTextField mempty
151
+ photo <- newTextField mempty
152
+ price <- newRatioField 0
153
+ qty <- newRatioField 1
154
+ pure
155
+ Asset
156
+ { assetLink = link,
157
+ assetPhoto = photo,
158
+ assetPrice = price,
159
+ assetQty = qty,
160
+ assetOoc = Opened
161
+ }
162
+
145
163
data Screen
146
164
= Main
147
165
| Donate
0 commit comments