--[[
	This function is used to get all of the AccessoryTypes that are used by the
	items in state so that we have a list of possible filters that always return
	at least one item.
]]


local MerchBooth = script:FindFirstAncestor("MerchBooth")

local matchAssetTypeToAccessoryType = require(MerchBooth.Modules.matchAssetTypeToAccessoryType)
local serverReducer = require(MerchBooth.Reducers.serverReducer)
local types = require(MerchBooth.types)

local function getAvailableAccessoryTypes(itemInfo: serverReducer.ItemInfoState): { types.ProductType }
	local accessoryTypeDict: { [types.ProductType]: boolean } = {}
	local accessoryTypes: { types.ProductType } = {}

	for _, item in pairs(itemInfo) do
		if item.productType == Enum.InfoType.Asset then
			accessoryTypeDict[matchAssetTypeToAccessoryType(item.assetType)] = true
		else
			accessoryTypeDict[item.productType] = true
		end
	end

	for accessoryType in pairs(accessoryTypeDict) do
		table.insert(accessoryTypes, accessoryType)
	end

	return accessoryTypes
end

return getAvailableAccessoryTypes
