@@ -11,6 +11,7 @@ module App.Types
11
11
unQrCode ,
12
12
unShareUri ,
13
13
stUri ,
14
+ stTeleUri ,
14
15
setScreenPure ,
15
16
setScreenAction ,
16
17
vsn ,
@@ -62,10 +63,10 @@ data Action
62
63
63
64
data St f = St
64
65
{ stAssets :: [Asset f ],
65
- stPayments :: [Money f ],
66
- stFeePercent :: Field Rational f ,
66
+ stPayment :: Money f ,
67
+ stMerchantTele :: Field Unicode f ,
68
+ stMerchantFeePercent :: Field Rational f ,
67
69
stDefAssetCurrency :: Currency f ,
68
- stDefPaymentCurrency :: Currency f ,
69
70
stFavName :: Field Unicode f ,
70
71
stPreview :: Field Unicode f ,
71
72
stScreen :: Screen
@@ -89,19 +90,20 @@ deriving via GenericType (St Identity) instance Binary (St Identity)
89
90
newSt :: (MonadIO m ) => m (St Unique )
90
91
newSt = do
91
92
fee <- newRatioField 2
92
- assetCur <- newCurrency cny
93
- paymentCur <- newCurrency rub
93
+ payment <- newMoney 0 rub
94
+ defAssetCur <- newCurrency cny
94
95
fav <- newTextField mempty
95
- pre <- newTextField mempty
96
+ pre <- newTextField " Delivery Calculator"
97
+ tele <- newTextField " Functora"
96
98
pure
97
99
St
98
100
{ stAssets = mempty ,
99
- stPayments = mempty ,
100
- stFeePercent = fee ,
101
- stDefAssetCurrency = assetCur ,
102
- stDefPaymentCurrency = paymentCur ,
101
+ stPayment = payment ,
102
+ stMerchantTele = tele ,
103
+ stMerchantFeePercent = fee ,
104
+ stDefAssetCurrency = defAssetCur ,
103
105
stFavName = fav,
104
- stPreview = pre,
106
+ stPreview = pre & # fieldType .~ FieldTypeTitle ,
105
107
stScreen = Main
106
108
}
107
109
@@ -166,6 +168,22 @@ stQuery st = do
166
168
. B64URL. encode
167
169
. from @ BL. ByteString @ ByteString
168
170
171
+ stTeleUri :: (MonadThrow m ) => Model -> m URI
172
+ stTeleUri st = do
173
+ base <- URI. mkURI " https://t.me"
174
+ user <- URI. mkPathPiece $ st ^. # modelState . # stMerchantTele . # fieldOutput
175
+ link <- stUri st
176
+ key <- URI. mkQueryKey " text"
177
+ val <-
178
+ URI. mkQueryValue
179
+ $ " Hello, I have a question about the delivery of the following items: "
180
+ <> URI. render link
181
+ pure
182
+ $ base
183
+ { URI. uriPath = Just (False , [user]),
184
+ URI. uriQuery = [URI. QueryParam key val]
185
+ }
186
+
169
187
unShareUri ::
170
188
( MonadIO m ,
171
189
MonadThrow m
0 commit comments