local SousChef = SousChef
local u = SousChef.Utility

function SousChef.AddTradingSlot(row, result)
	local rankIcon = SousChef.getIcon(row)

	rankIcon:SetHidden(true)
    if SousChef.settings.processRecipes then
        if u.MatchesRecipe(result.name) then
            local match = u.MatchInCookbook(result.name)
            local gmatch = u.MatchInGlobalCookbook(result.name)
            if (match and SousChef.settings.checkKnown == "known") or
               (not match and SousChef.settings.checkKnown == "unknown")then
                rankIcon:SetDimensions(30, 30)
                rankIcon:SetAnchor(CENTER, row, CENTER, 230)
                rankIcon:SetTexture(CANLEARN)
                rankIcon:SetHidden(false)
                if not match and gmatch and SousChef.settings.checkKnown == "unknown" and SousChef.settings.markAlt then
                    rankIcon:SetColor(1,1,1,0.2)
                else
                    rankIcon:SetColor(1,1,1,1)
                end
            end
        end
    end
end



function SousChef.HookTrading(...)
    if SousChef.hookedDataFunction then return end
    SousChef.hookedDataFunction = ZO_TradingHouseItemPaneSearchResults.dataTypes[1].setupCallback
    ZO_TradingHouseItemPaneSearchResults.dataTypes[1].setupCallback = function(...)
        local row, data = ...
        SousChef.hookedDataFunction(...)
        AddTradingSlot(row, data)
    end
end