/*
    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 crate::RenderInfo;
use jellycommon::{
    jellyobject::Object,
    routes::{u_account_login, u_account_logout, u_account_settings},
    *,
};
use jellyui_locale::tr;

markup::define! {
    UserSettings<'a>(ri: &'a RenderInfo<'a>, user: Object<'a>) {
        h1 { @tr(ri.lang, "settings") }

        h2 { @tr(ri.lang, "settings.account") }
        a.switch_account[href=u_account_login()] { button { "Switch Account" } }
        a.switch_account[href=u_account_logout()] { button { "Log out" } }
        p { @tr(ri.lang, "tag.Ulgn") ": " @user.get(USER_LOGIN) }
        form[method="POST", action=u_account_settings()] {
            label[for="name"] { @tr(ri.lang, "tag.Unam") }
            input[type="text", id="name", name="name", value=user.get(USER_NAME)];
            input[type="submit", value=tr(ri.lang, "settings.update")];
        }
        form[method="POST", action=u_account_settings()] {
            label[for="password"] { @tr(ri.lang, "tag.Upwd") }
            input[type="password", id="password", name="password"];
            input[type="submit", value=tr(ri.lang, "settings.update")];
        }

        // h2 { @tr(ri.lang, "settings.appearance") }
        // form[method="POST", action=u_account_settings()] {
        //     fieldset {
        //         legend { @tr(ri.lang, "tag.Uthm") }
        //         @for theme in [] {
        //             label { input[type="radio", name="theme", value=A(*theme), checked=session.user.theme==*theme]; @tr(ri.lang, &format!("theme.{theme}")) } br;
        //         }
        //     }
        //     input[type="submit", value=tr(ri.lang, "settings.apply")];
        // }
        // form[method="POST", action=u_account_settings()] {
        //     fieldset {
        //         legend { @tr(ri.lang, "settings.player_preference") }
        //         @for kind in PlayerKind::ALL {
        //             label { input[type="radio", name="player_preference", value=A(*kind), checked=session.user.player_preference==*kind]; @tr(ri.lang, &format!("player_kind.{kind}")) } br;
        //         }
        //     }
        //     input[type="submit", value=tr(ri.lang, "settings.apply")];
        // }
    }
}
