/*
    This file is part of jellything (https://codeberg.org/metamuffin/jellything)
    which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
    Copyright (C) 2026 metamuffin <metamuffin.org>
*/

use jellyui_locale::tr;

use crate::RenderInfo;

markup::define! {
    AccountSetPassword<'a>(ri: &'a RenderInfo<'a>, session: &'a str) {
        form.account[method="POST", action=""] {
            h1 { @tr(ri.lang, "account.set_password") }
            input[type="text", name="session", hidden, value=session]; br;

            label[for="inp-password"] { @tr(ri.lang, "account.password") }
            input[type="password", id="inp-password", name="password"]; br;

            input[type="submit", value=tr(ri.lang, "account.register.submit")];


        }
    }
    AccountLogin<'a>(ri: &'a RenderInfo<'a>) {
        form.account[method="POST", action=""] {
            h1 { @tr(ri.lang, "account.login") }

            label[for="inp-username"] { @tr(ri.lang, "account.username") }
            input[type="text", id="inp-username", name="username"]; br;
            label[for="inp-password"] { @tr(ri.lang, "account.password") }
            input[type="password", id="inp-password", name="password"]; br;

            input[type="submit", value=tr(ri.lang, if ri.user.is_some() { "account.login.submit.switch" } else { "account.login.submit" })];
        }
    }
    AccountLogout<'a>(ri: &'a RenderInfo<'a>) {
        form.account[method="POST", action=""] {
            h1 { @tr(ri.lang, "account.logout") }
            input[type="submit", value=tr(ri.lang, "account.logout.submit")];
        }
    }
}
