aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/LoggedIn/Home/Model.elm
blob: 6b29d8c4e2ddd9ad69230cc8b112feb2c0d51fe2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module LoggedIn.Home.Model exposing
  ( Model
  , Search
  , init
  )

import Form exposing (Form)
import Form.Validate as Validate exposing (Validation)

import Model.User exposing (Users, UserId)
import Model.Payment exposing (PaymentId, Payments, Frequency(..))
import Model.Payer exposing (Payers)

import LoggedIn.Home.AddPayment.Model as AddPaymentModel

type alias Model =
  { add : AddPaymentModel.Model
  , paymentEdition : Maybe PaymentId
  , currentPage : Int
  , monthlyDetail : Bool
  , search : Form String Search
  }

type alias Search =
  { searchText : Maybe String
  }

init : Model
init =
  { add = AddPaymentModel.init Punctual
  , paymentEdition = Nothing
  , currentPage = 1
  , monthlyDetail = False
  , search = Form.initial [] validate
  }

validate : Validation String Search
validate =
  Validate.form1 Search
    (Validate.get "searchText" (Validate.maybe Validate.string))