use maud::{html, Markup, DOCTYPE};
use crate::{channel::repo::channels::Channel, login::repo::logins::Login};
pub fn authenticated<'c>(login: Login, channels: impl IntoIterator- ) -> Markup {
html! {
(DOCTYPE)
head {
title { "hi" }
}
body {
section {
(channel_list(channels))
(create_channel())
}
section {
(logout_form(&login.name))
}
}
}
}
fn channel_list<'c>(channels: impl IntoIterator
- ) -> Markup {
html! {
ul {
@for channel in channels {
(channel_list_entry(&channel))
}
}
}
}
fn channel_list_entry(channel: &Channel) -> Markup {
html! {
li {
(channel.name) " (" (channel.id) ")"
}
}
}
fn create_channel() -> Markup {
html! {
form action="/create" method="post" {
label {
"name"
input name="name" type="text" {}
}
button {
"start channel"
}
}
}
}
fn logout_form(name: &str) -> Markup {
html! {
form action="/logout" method="post" {
button { "bye, " (name) }
}
}
}
pub fn unauthenticated() -> Markup {
html! {
(DOCTYPE)
head {
title { "hi" }
}
body {
(login_form())
}
}
}
fn login_form() -> Markup {
html! {
form action="/login" method="post" {
label {
"login"
input name="name" type="text" {}
}
label {
"password"
input name="password" type="password" {}
}
button { "hi" }
}
}
}