const { BlankType } = require('../../../public/common_constants');

function getCardHtml(info, btn) {
    return `<div class="row">
    <div class="col-lg-8 mx-auto mt-5">
        <div class="card newuser-input">
            <div class="card-body">
                <h4 class="mt-2 mb-5 text-center">${info}</h4>
                ${btn ? `<div class="form-group text-center"><a class="btn btn-primary" href="${btn.href}">${btn.title}</a></div>` : ''}
            </div>
        </div>
    </div>
</div>`;
}

module.exports = function (app) {
    app.get('/blank', function (req, res) {
        const { type } = req.query;
        let html = '';
        switch (+type) {
            case BlankType.SHARE_CANCEL:
                html = getCardHtml('分享设置已被修改，当前项目无权查看。', { href: '/pm', title: '返回项目管理' });
                break;
            case BlankType.NOT_FOUND:
            default:
                html = getCardHtml('很抱歉，您要访问的页面不存在。');
                break;

        }
        res.render('common/components/blank/index.html', { html });
    });
}