๐Ÿ‘ฉโ€๐Ÿš’ Firefighters API written in Gleam!
lustre gleam

:bug: use correct URL for signup requests

kacaii.dev 75bc171e ed2fe551

verified
+10 -8
+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 + 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 - ServerSentResponse(Result(response.Response(String), rsvp.Error)) 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 - rsvp.expect_ok_response(ServerSentResponse) 117 - |> rsvp.post("api/signup", body, _) 117 + rsvp.expect_json(user.decoder(), ServerSentResponse) 118 + |> rsvp.post("/api/signup", body, _) 118 119 119 120 #(Model(..model, loading: True), effect) 120 121 } 121 122 122 - ServerSentResponse(Ok(resp)) -> #( 123 - Model(..model, loading: False, text_message: resp.body), 124 - effect.none(), 125 - ) 123 + ServerSentResponse(Ok(user)) -> { 124 + let text_message = user.full_name <> " registrado(a)" 125 + #(Model(..empty, loading: False, text_message:), effect.none()) 126 + } 126 127 127 128 ServerSentResponse(Error(reason)) -> { 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 - text -> html.p([class("text-white")], [html.text(text)]) 154 + text -> html.p([class("text-center text-white")], [html.text(text)]) 153 155 } 154 156 } 155 157