const std = @import("std");
const jetzig = @import("jetzig");

pub const layout = "panel";

pub fn index(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
    const cookies = try request.cookies();
    const allowed = blk: {
        const session = cookies.get("session") orelse break :blk false;

        const session_query = jetzig.database.Query(.Session)
            .findBy(.{ .session_id = session.value });
        _ = request.repo.execute(session_query) catch break :blk false;
        break :blk true;
    };

    const root = try data.object();
    try root.put("allowed", allowed);
    return request.render(.ok);
}
