add gs
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
local CorePackages = game:GetService("CorePackages")
|
||||
|
||||
local Rodux = require(CorePackages.Rodux)
|
||||
|
||||
local AccountInfoReceived = require(script.Parent.Parent.Actions.AccountInfoReceived)
|
||||
|
||||
local ProductInfoReducer = Rodux.createReducer({}, {
|
||||
[AccountInfoReceived.name] = function(state, action)
|
||||
local accountInfo = action.accountInfo
|
||||
|
||||
return {
|
||||
balance = accountInfo.RobuxBalance,
|
||||
bcLevel = accountInfo.MembershipType,
|
||||
}
|
||||
end,
|
||||
})
|
||||
|
||||
return ProductInfoReducer
|
||||
@@ -0,0 +1,13 @@
|
||||
local CorePackages = game:GetService("CorePackages")
|
||||
|
||||
local Rodux = require(CorePackages.Rodux)
|
||||
|
||||
local SetGamepadEnabled = require(script.Parent.Parent.Actions.SetGamepadEnabled)
|
||||
|
||||
local GamepadEnabledReducer = Rodux.createReducer(false, {
|
||||
[SetGamepadEnabled.name] = function(state, action)
|
||||
return action.enabled
|
||||
end,
|
||||
})
|
||||
|
||||
return GamepadEnabledReducer
|
||||
@@ -0,0 +1,17 @@
|
||||
local CorePackages = game:GetService("CorePackages")
|
||||
|
||||
local Rodux = require(CorePackages.Rodux)
|
||||
|
||||
local PromptNativeUpsell = require(script.Parent.Parent.Actions.PromptNativeUpsell)
|
||||
|
||||
local NativeUpsellReducer = Rodux.createReducer({}, {
|
||||
[PromptNativeUpsell.name] = function(state, action)
|
||||
|
||||
return {
|
||||
robuxProductId = action.robuxProductId,
|
||||
robuxPurchaseAmount = action.robuxPurchaseAmount,
|
||||
}
|
||||
end,
|
||||
})
|
||||
|
||||
return NativeUpsellReducer
|
||||
@@ -0,0 +1,24 @@
|
||||
local CorePackages = game:GetService("CorePackages")
|
||||
|
||||
local Rodux = require(CorePackages.Rodux)
|
||||
|
||||
local ProductInfoReceived = require(script.Parent.Parent.Actions.ProductInfoReceived)
|
||||
|
||||
local getPreviewImageUrl = require(script.Parent.Parent.getPreviewImageUrl)
|
||||
|
||||
local ProductInfoReducer = Rodux.createReducer({}, {
|
||||
[ProductInfoReceived.name] = function(state, action)
|
||||
local productInfo = action.productInfo
|
||||
|
||||
return {
|
||||
name = productInfo.Name,
|
||||
price = productInfo.PriceInRobux or 0,
|
||||
imageUrl = getPreviewImageUrl(productInfo),
|
||||
assetTypeId = productInfo.AssetTypeId,
|
||||
productId = productInfo.ProductId,
|
||||
bcLevelRequired = productInfo.MinimumMembershipLevel,
|
||||
}
|
||||
end,
|
||||
})
|
||||
|
||||
return ProductInfoReducer
|
||||
@@ -0,0 +1,22 @@
|
||||
local CorePackages = game:GetService("CorePackages")
|
||||
|
||||
local Rodux = require(CorePackages.Rodux)
|
||||
|
||||
local SetProduct = require(script.Parent.Parent.Actions.SetProduct)
|
||||
local HidePrompt = require(script.Parent.Parent.Actions.HidePrompt)
|
||||
|
||||
local ProductReducer = Rodux.createReducer({}, {
|
||||
[SetProduct.name] = function(state, action)
|
||||
return {
|
||||
id = action.id,
|
||||
infoType = action.infoType,
|
||||
equipIfPurchased = action.equipIfPurchased,
|
||||
}
|
||||
end,
|
||||
[HidePrompt.name] = function(state, action)
|
||||
-- Clear product info when we hide the prompt
|
||||
return {}
|
||||
end,
|
||||
})
|
||||
|
||||
return ProductReducer
|
||||
@@ -0,0 +1,35 @@
|
||||
local CorePackages = game:GetService("CorePackages")
|
||||
|
||||
local Rodux = require(CorePackages.Rodux)
|
||||
|
||||
local PromptState = require(script.Parent.Parent.PromptState)
|
||||
|
||||
local SetPromptState = require(script.Parent.Parent.Actions.SetPromptState)
|
||||
local HidePrompt = require(script.Parent.Parent.Actions.HidePrompt)
|
||||
local ErrorOccurred = require(script.Parent.Parent.Actions.ErrorOccurred)
|
||||
local ItemCannotBePurchased = require(script.Parent.Parent.Actions.ItemCannotBePurchased)
|
||||
local StartPurchase = require(script.Parent.Parent.Actions.StartPurchase)
|
||||
local PromptNativeUpsell = require(script.Parent.Parent.Actions.PromptNativeUpsell)
|
||||
|
||||
local PromptStateReducer = Rodux.createReducer(PromptState.Hidden, {
|
||||
[SetPromptState.name] = function(state, action)
|
||||
return action.promptState
|
||||
end,
|
||||
[HidePrompt.name] = function(state, action)
|
||||
return PromptState.Hidden
|
||||
end,
|
||||
[ErrorOccurred.name] = function(state, action)
|
||||
return PromptState.Error
|
||||
end,
|
||||
[ItemCannotBePurchased.name] = function(state, action)
|
||||
return PromptState.CannotPurchase
|
||||
end,
|
||||
[StartPurchase.name] = function(state, action)
|
||||
return PromptState.PurchaseInProgress
|
||||
end,
|
||||
[PromptNativeUpsell.name] = function(state, action)
|
||||
return PromptState.RobuxUpsell
|
||||
end,
|
||||
})
|
||||
|
||||
return PromptStateReducer
|
||||
@@ -0,0 +1,16 @@
|
||||
local ErrorOccurred = require(script.Parent.Parent.Actions.ErrorOccurred)
|
||||
local ItemCannotBePurchased = require(script.Parent.Parent.Actions.ItemCannotBePurchased)
|
||||
|
||||
-- TODO: Switch to Rodux.createReducer once CorePackages.Rodux is upgraded
|
||||
local PurchaseErrorReducer = function(state, action)
|
||||
|
||||
if action.type == ErrorOccurred.name then
|
||||
return action.purchaseError
|
||||
elseif action.type == ItemCannotBePurchased.name then
|
||||
return action.purchaseError
|
||||
end
|
||||
|
||||
return state
|
||||
end
|
||||
|
||||
return PurchaseErrorReducer
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
local StartPurchase = require(script.Parent.Parent.Actions.StartPurchase)
|
||||
|
||||
local function PurchasingStartTimeReducer(state, action)
|
||||
state = state or -1
|
||||
|
||||
if action.type == StartPurchase.name then
|
||||
return action.purchasingStartTime
|
||||
end
|
||||
|
||||
return state
|
||||
end
|
||||
|
||||
return PurchasingStartTimeReducer
|
||||
@@ -0,0 +1,27 @@
|
||||
--[[
|
||||
The main reducer for the app's store
|
||||
]]
|
||||
local CorePackages = game:GetService("CorePackages")
|
||||
local Rodux = require(CorePackages.Rodux)
|
||||
|
||||
local ProductReducer = require(script.Parent.ProductReducer)
|
||||
local ProductInfoReducer = require(script.Parent.ProductInfoReducer)
|
||||
local NativeUpsellReducer = require(script.Parent.NativeUpsellReducer)
|
||||
local PromptStateReducer = require(script.Parent.PromptStateReducer)
|
||||
local PurchaseErrorReducer = require(script.Parent.PurchaseErrorReducer)
|
||||
local AccountInfoReducer = require(script.Parent.AccountInfoReducer)
|
||||
local PurchasingStartTimeReducer = require(script.Parent.PurchasingStartTimeReducer)
|
||||
local GamepadEnabledReducer = require(script.Parent.GamepadEnabledReducer)
|
||||
|
||||
local Reducer = Rodux.combineReducers({
|
||||
product = ProductReducer,
|
||||
productInfo = ProductInfoReducer,
|
||||
nativeUpsell = NativeUpsellReducer,
|
||||
promptState = PromptStateReducer,
|
||||
purchaseError = PurchaseErrorReducer,
|
||||
accountInfo = AccountInfoReducer,
|
||||
purchasingStartTime = PurchasingStartTimeReducer,
|
||||
gamepadEnabled = GamepadEnabledReducer,
|
||||
})
|
||||
|
||||
return Reducer
|
||||
Reference in New Issue
Block a user