diff --git a/src/client/page/sidebar.gleam b/src/client/page/sidebar.gleam index 56e2aa6..27abdc9 100644 --- a/src/client/page/sidebar.gleam +++ b/src/client/page/sidebar.gleam @@ -11,22 +11,27 @@ pub fn view(session: session.Session) -> element.Element(Msg) { let data_sidebar = attr.data("sidebar", "") html.aside([data_sidebar, class("p-4 bg-primary text-primary-foreground")], [ - session.guard(session, { - let attr = [class("hover:cursor-pointer hstack")] + case session { + session.Authenticated(..) -> { + let attr = [class("hover:cursor-pointer hstack")] - html.section([], [ - // Dashboard - html.a([attr.href(route.path(route.Dashboard)), ..attr], [ - icon.layout_dashboard([]), - html.p([], [html.text("Dashboard")]), - ]), + html.section([], [ + // Dashboard + html.a([attr.href(route.path(route.Dashboard)), ..attr], [ + icon.layout_dashboard([]), + html.p([], [html.text("Dashboard")]), + ]), - // Calculator - html.a(attr, [ - icon.calculator([]), - html.p([], [html.text("Simulador")]), - ]), - ]) - }), + // Calculator + html.a(attr, [ + icon.calculator([]), + html.p([], [html.text("Simulador")]), + ]), + ]) + } + + // Not authenticated + _ -> element.none() + }, ]) } diff --git a/src/client/session.gleam b/src/client/session.gleam index c730ad4..3f36fb1 100644 --- a/src/client/session.gleam +++ b/src/client/session.gleam @@ -1,7 +1,6 @@ import client/route import client/session/token import gleam/dynamic/decode -import lustre/element pub type Session { ///  User is sucessfully authenticated and is allowed to @@ -34,15 +33,3 @@ pub fn decoder() -> decode.Decoder(Session) { _ -> decode.failure(Guest, "Session") } } - -///  Require User authentication in order to render an HTML element. -/// -/// ```gleam -/// guard(session, html.p([], [])) -/// ``` -pub fn guard(self: Session, element: element.Element(_)) -> element.Element(_) { - case self { - Authenticated(..) -> element - _ -> element.none() - } -}