document.title = "内容审核";

window.disable_new_user_picker=true;

// var link = document.createElement('link');
// link.rel = 'shortcut icon';
// link.type = 'image/x-icon';
// link.href = '/favicon.ico';

// var existingLink = document.querySelector('link[rel="shortcut icon"]');
// if (existingLink) {
//   existingLink.parentNode.removeChild(existingLink);
// }

// document.head.appendChild(link);

var today = new Date();
var v = today.getFullYear().toString() + (today.getMonth() + 1).toString().padStart(2, '0') + today.getDate().toString().padStart(2, '0');

loadCss(Steedos.absoluteUrl('/content-review/topic.css?v='+v));
loadCss(Steedos.absoluteUrl('/content-review/amis.css?v='+v));
loadCss(Steedos.absoluteUrl('/content-review/liveblocks.css?v='+v));

window.drawerWidth = '80%';

if(false){
    let parentClassName = 'steedos-global-header-toolbar'
    Promise.all([
        waitForThing(window, parentClassName, function(){
            return document.querySelector(`.${parentClassName}`);
        }),
    ]).then(()=>{
        // 获取steedos-global-header-toolbar的div元素
        var toolbarDiv = document.querySelector(`.${parentClassName}`);
        // 创建一个新的div节点
        var newDiv = document.createElement('div');
        newDiv.className = 'header-toolbar-rooms-inbox';
        newDiv.id = 'header-toolbar-rooms-inbox';
    
        // 使用insertBefore方法将新节点插入到第一个位置
        toolbarDiv.insertBefore(newDiv, toolbarDiv.firstChild);
    
        const schema = {
        type: "service",
        body: {
            type: "rooms-provider",
            baseUrl: "",
            body: {
            type: "wrapper",
            className: "p-0",
            body: { type: "rooms-inbox-popover" },
            },
        },
        };
        Steedos.Page.render(document.getElementById('header-toolbar-rooms-inbox'), {
            schema: schema,
            render_engine: 'amis'
        }, {});
    })
}




window.completeMaterialDataSimple = function (payload, materialList) {
    const existingIds = new Set(payload.data.rows.map(row => row.pepsico_material));
    
    materialList.forEach(material => {
        if (!existingIds.has(material._id)) {
            const now = new Date();
            payload.data.rows.push({
                "_id": `simulated_${material._id}`,
                "space": material.space,
                "pepsico_material": material._id,
                "approval_field": "approval_status",
                "_display": {
                    "pepsico_material": {
                        "objectName": "pepsico_material",
                        "value": material._id,
                        "label": material.name
                    },
                    "approval_field": "审核专员"
                },
                "_index": payload.data.rows.length + 1,
                "_simulated": true
            });
        }
    });
    
    payload.data.count = payload.data.rows.length;
    return payload;
}