···3232 )
3333}
34343535-/// โโโโโโโโ
3636-/// โโโโโโโโ View โโโโโโโโ
3737-/// โ โโโโโโโโ โ
3838-/// โโโโโโโโโ โโโโโโโโโโ
3939-/// โ Model โโโโโโโโโโโโโโ UPDATE โ
4040-/// โโโโโโโโโ โโโโโโโโโโ
4141-///
4235pub fn main() -> Nil {
4336 let app = lustre.application(init:, update:, view:)
4437 let assert Ok(_runtime) = lustre.start(app, "#app", Nil)
···6356 // UI Elements
6457 SidebarMsg(msg: sidebar.Msg)
6558 NavbarMsg(msg: navbar.Msg)
6666- NotFoundMsg(not_found.Msg)
5959+ NotFoundMsg(msg: not_found.Msg)
6760}
68616962// INIT ------------------------------------------------------------------------
···161154162155 // SESSION MANAGEMENT -----------------------------------------------------
163156 //
164164- // Success
157157+ // If the Server successfully authenticated the User,
158158+ // initialize its Session, and redirect them to the correct route.
165159 Model(session: session.Pending(on_success:, on_error: _), ..),
166160 UserRestoredSession(Ok(session))
167161 -> #(
···169163 modem.push(route.to_path(on_success), option.None, option.None),
170164 )
171165172172- // Failure
166166+ // If it fails, start the Session as a Guest and redirect
167167+ // the User accordingly, usually to the Login Page.
173168 Model(session: session.Pending(on_success: _, on_error:), ..),
174169 UserRestoredSession(Error(_))
175170 -> #(
···183178 )
184179185180 // User ended their Session and token has been removed.
186186- // Redirect user to the Home page
181181+ // Redirect user to the Home page.
187182 model, ServerRemovedToken(Ok(_)) -> {
188183 let session = session.Guest
189184 let route = route.to_path(route.Home)
···252247 _ -> ""
253248 }
254249255255- let page =
256256- login.Model(..page, loading: False, message:)
257257- |> page.Login
258258-259259- #(Model(..model, page:), effect.none())
250250+ let page = login.Model(..page, loading: False, message:)
251251+ #(Model(..model, page: page.Login(page)), effect.none())
260252 }
261253 }
262254}
+8-6
src/client/page/login.gleam
···3030 /// User updated password field
3131 UserTypedPassword(password: String)
32323333- /// User sent credentials to the Server
3333+ /// User sent login credentials to the Server
3434 UserClickedSubmit
35353636 /// API validated User's credentials
···9393 ]
94949595 html.div(wrapper_attr, [
9696- // ๏ฌ Logo with Title ---
9696+ // ๏ฌ LOGO AND TITLE -------------------------------------------------------
9797 html.section(
9898 [
9999 class("p-4 w-full"),
···114114 ],
115115 ),
116116117117- // Form ---
117117+ // ๓ฑ FORM -----------------------------------------------------------------
118118 html.article([class("w-full card @container")], [
119119- // Form Header
119119+ // Header
120120 html.header([class("hidden mb-4 @md:inline")], [
121121 html.h3([class("my-2 font-bold")], [
122122 html.text(case lang {
···125125 _ -> "Join the Platform"
126126 }),
127127 ]),
128128+128129 html.p([class("text-subtext")], [
129130 html.text(case lang {
130131 language.BrazillianPortuguese | language.PortugalPortuguese ->
131131- "Acesse sua conta para gerenciar contratos de energia"
132132+ "Acesse sua conta para gerenciar seus contratos de energia"
132133 _ -> "Access your account to manage your energy contracts"
133134 }),
134135 ]),
···160161 "Senha"
161162 _ -> "Password"
162163 }),
164164+163165 html.input([
164166 attr.type_("password"),
165167 attr.value(model.password),
···177179 html.text("Login"),
178180 ]),
179181180180- // ---
181182 html.hr([class("my-4")]),
183183+182184 html.div(
183185 [
184186 class("text-sm text-center"),