var PushMessageDetail = {};

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

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

PushMessageDetail.init = function() {
    TEMPLATE.loadHearder("#includedHeader");
    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, true, function (json) {
        if (callback && json && json.pushMessage) {
            callback(json.pushMessage);
        }
    }, function() {
        console.log('PushMessageDetail.getMessageDetail error');
    });
}

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