local SevenDayManager = class("SevenDayManager", BaseModule)

function SevenDayManager:showUI()
    UIManager:showUI("app/ui/activity/seven_day/seven_day_ui")
end

function SevenDayManager:claimTaskReward(id)
    local args = {
        ids = {id}
	}
	self:sendMessage(ProtoMsgType.FromMsgEnum.SevenDayTaskRewardReq, args, {}, self.onClaimTaskRewardFinish, BIReport.ITEM_GET_TYPE.SEVEN_DAY_TASK)
end

function SevenDayManager:onClaimTaskRewardFinish(result)
    if result.status == 0 then
        GFunc.showRewardBox(result.rewards)
        DataManager.SevenDayData:refreshTasks(result.tasks)
        DataManager.SevenDayData:setDirty()
    end
end

function SevenDayManager:claimStepReward(id)
    if DataManager.SevenDayData:getStepCollected(id) then
        return
    end
    if not DataManager.SevenDayData:canClaimStepTask(id) then
        return
    end
    local params = {
        id = id
    }
    self:sendMessage(ProtoMsgType.FromMsgEnum.SevenDayRewardReq, params, {}, self.onClaimStepRewardFinish, BIReport.ITEM_GET_TYPE.SEVEN_DAY_STEP_REWARD)
end

function SevenDayManager:onClaimStepRewardFinish(result)
    if result.status == 0 then
        GFunc.showRewardBox(result.rewards)
        DataManager.SevenDayData:refreshClaimed(result.Claimed)
        DataManager.SevenDayData:setDirty()
    end
end

return SevenDayManager