/*
    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>
*/

pub mod admin;
pub mod admin_log;
pub mod login;
pub mod message;
pub mod node_card;
pub mod node_list;
pub mod node_page;
pub mod props;
pub mod stats;
pub mod user;

use crate::{
    RenderInfo,
    components::{
        admin::{AdminDashboard, AdminImport, AdminInfo},
        login::{AccountLogin, AccountLogout, AccountSetPassword},
        message::Message,
        node_list::NodeList,
        node_page::{NodePage, Player},
        user::UserSettings,
    },
};
use jellycommon::{jellyobject::Object, *};
use markup::define;

define! {
    View<'a>(ri: &'a RenderInfo<'a>, view: Object<'a>) {
        @if let Some(message) = view.get(VIEW_MESSAGE) {
            @Message { ri, message }
        }
        @if let Some(nku) = view.get(VIEW_NODE_PAGE) {
            @NodePage { ri, nku }
        }
        @if let Some(nku) = view.get(VIEW_PLAYER) {
            @Player { ri, nku }
        }
        @for nl in view.iter(VIEW_NODE_LIST) {
            @NodeList { ri, nl }
        }
        @if let Some(()) = view.get(VIEW_ACCOUNT_LOGIN) {
            @AccountLogin { ri }
        }
        @if let Some(()) = view.get(VIEW_ACCOUNT_LOGOUT) {
            @AccountLogout{ ri }
        }
        @if let Some(session) = view.get(VIEW_ACCOUNT_SET_PASSWORD) {
            @AccountSetPassword { ri, session }
        }
        @if let Some(()) = view.get(VIEW_ADMIN_DASHBOARD) {
            @AdminDashboard { ri }
        }
        @if let Some(data) = view.get(VIEW_ADMIN_IMPORT) {
            @AdminImport { ri, data }
        }
        @if let Some(data) = view.get(VIEW_ADMIN_INFO) {
            @AdminInfo { ri, data }
        }
        @if let Some(user) = view.get(VIEW_USER_SETTINGS) {
            @UserSettings { ri, user }
        }
    }
}
