summaryrefslogtreecommitdiff
blob: faa4a2f6b4faa7c55996bee8e4c7afc5fa2595f9 (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
41
42
43
44
45
46
module Struct.Event exposing (Type(..), attempted)

-- Elm -------------------------------------------------------------------------
import Http

-- Shared ----------------------------------------------------------------------
import Util.Http

-- Login -----------------------------------------------------------------------
import Struct.Error
import Struct.ServerReply
import Struct.HelpRequest
import Struct.UI

--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
--------------------------------------------------------------------------------
type Type =
   None
   | Failed Struct.Error.Type
   | RequestedHelp Struct.HelpRequest.Type
   | SignInRequested
   | SignUpRequested
   | RecoveryRequested
   | SetUsername String
   | SetPassword1 String
   | SetPassword2 String
   | SetEmail1 String
   | SetEmail2 String
   | ServerReplied (Result Http.Error (List Struct.ServerReply.Type))
   | TabSelected Struct.UI.Tab
   | Connected
   | DebugSignInAs String

attempted : (Result.Result err val) -> Type
attempted act =
   case act of
      (Result.Ok _) -> None
      (Result.Err msg) ->
         (Failed
            (Struct.Error.new
               Struct.Error.Failure
               -- TODO: find a way to get some relevant text here.
               "(text representation not implemented)"
            )
         )