var PushMessageDetail = {};

PushMessageDetail.baseApiUrl = CONSTANT.URL.CMS.BASE + ClientData.userInfo_accountPath() + CONSTANT.URL.CMS.API.BASE + 'pushMessageDetail/';

PushMessageDetail.dummyMessageDetailJson = {
    pushMessage: "内容が入ります。内容が入ります。内容が入ります。内容が入ります。",
    pushSendDate: "2022/07/06 14:14",
    operationName: "絞り検索",
    pushSendLoginId: "agentec"
}

PushMessageDetail.init = function() {
    $("#includedHeader").load("../common/header.html" , function() {
        I18N.initi18n();
    });
    let urlParam = COMMON.getUrlParameter();
    if (typeof urlParam !== 'object' || typeof urlParam.pushMessageId === 'undefined') {
		return;
	}
    PushMessageDetail.getMessageDetail(urlParam.pushMessageId, function(message) {
        PushMessageDetail.showMessage(message);
    });
}

PushMessageDetail.getMessageDetail = function(pushMessageId, callback) {
    let param = {
        sid: COMMON.getSid(),
        pushMessageId: pushMessageId
    };
    const url = PushMessageDetail.baseApiUrl;
    COMMON.cmsAjax(url, param, false, function (json) {
        if (callback) {
            callback(json);
        }
    }, function() {
        console.log('PushMessageDetail.getMessageDetail error');
        if (callback) {
            callback(PushMessageDetail.dummyMessageDetailJson);
        }
    });
}

PushMessageDetail.showMessage = function(message) {
    $('#content').text(message.pushMessage);
    $('#sendDate').text(message.pushSendDate);
    $('#operationName').text(message.operationName);
    $('#sender').text(message.pushSendLoginId);
}
