tangled
alpha
login
or
join now
kacaii.dev
/
sigo
0
fork
atom
๐ฉโ๐ Firefighters API written in Gleam!
lustre
gleam
0
fork
atom
overview
issues
pulls
pipelines
:bug: use correct URL for signup requests
kacaii.dev
2 weeks ago
75bc171e
ed2fe551
verified
This commit was signed with the committer's
known signature
.
kacaii.dev
SSH Key Fingerprint:
SHA256:n9v7QGNWHCUv1x/483hCtPUvTsVabU5PzC5CSJMUNtI=
+10
-8
1 changed file
expand all
collapse all
unified
split
client
src
client
page
signup.gleam
+10
-8
client/src/client/page/signup.gleam
···
12
12
import shared/contract/signup as contract
13
13
import shared/role
14
14
import shared/session
15
15
+
import shared/user
15
16
16
17
pub const empty = Model(
17
18
user_name: "",
···
58
59
UserUpdatedConfirmPasswordField(String)
59
60
60
61
UserSentRequest
61
61
-
ServerSentResponse(Result(response.Response(String), rsvp.Error))
62
62
+
ServerSentResponse(Result(user.User, rsvp.Error))
62
63
UserUpdatedPhoneField(String)
63
64
}
64
65
···
113
114
|> contract.request_to_json()
114
115
115
116
let effect =
116
116
-
rsvp.expect_ok_response(ServerSentResponse)
117
117
-
|> rsvp.post("api/signup", body, _)
117
117
+
rsvp.expect_json(user.decoder(), ServerSentResponse)
118
118
+
|> rsvp.post("/api/signup", body, _)
118
119
119
120
#(Model(..model, loading: True), effect)
120
121
}
121
122
122
122
-
ServerSentResponse(Ok(resp)) -> #(
123
123
-
Model(..model, loading: False, text_message: resp.body),
124
124
-
effect.none(),
125
125
-
)
123
123
+
ServerSentResponse(Ok(user)) -> {
124
124
+
let text_message = user.full_name <> " registrado(a)"
125
125
+
#(Model(..empty, loading: False, text_message:), effect.none())
126
126
+
}
126
127
127
128
ServerSentResponse(Error(reason)) -> {
129
129
+
echo reason
128
130
let text_message = case reason {
129
131
rsvp.HttpError(resp) -> resp.body
130
132
rsvp.NetworkError -> "Connection not available"
···
149
151
fn text_message(model: Model) -> element.Element(Msg) {
150
152
case model.text_message {
151
153
"" -> element.none()
152
152
-
text -> html.p([class("text-white")], [html.text(text)])
154
154
+
text -> html.p([class("text-center text-white")], [html.text(text)])
153
155
}
154
156
}
155
157