62 lines
2.1 KiB
TypeScript
62 lines
2.1 KiB
TypeScript
// Metro module 13723 (f13724).
|
|
import { useMemo } from "react";
|
|
import CollectiblesCategoryStore from "../CollectiblesCategoryStore";
|
|
import CollectiblesPurchaseStore from "../CollectiblesPurchaseStore";
|
|
import { useStateFromStores, useStateFromStoresArray } from "../../../_bundle/defaultAreStatesEqual";
|
|
import { getProfileEffects, isPremiumCollectiblesPurchase, isPremiumCollectiblesProduct } from "../CollectiblesUtils";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
let c9538_6 = {
|
|
PURCHASE: "purchase",
|
|
PREMIUM_PURCHASE: "premium_purchase",
|
|
PREVIEW: "preview"
|
|
};
|
|
let c9538_7 = {
|
|
skuId: "None"
|
|
};
|
|
let c9538_8 = {
|
|
skuId: "Shop"
|
|
};
|
|
export default function useProfileEffectSections() {
|
|
let c20669_1, c20669_2;
|
|
const stateFromStores = useStateFromStores([CollectiblesPurchaseStore], () => CollectiblesPurchaseStore.purchases);
|
|
const [r22, r23] = useStateFromStoresArray([CollectiblesCategoryStore], () => [CollectiblesCategoryStore.categories, CollectiblesCategoryStore.products]);
|
|
c20669_1 = r22;
|
|
c20669_2 = r23;
|
|
return useMemo(() => {
|
|
const r22 = getProfileEffects(stateFromStores, c20669_1).reduce((acc, item) => {
|
|
const r9 = stateFromStores.get(item.skuId);
|
|
if (r9 != null ? isPremiumCollectiblesPurchase(r9) : isPremiumCollectiblesProduct(c20669_2.get(item.skuId))) {
|
|
acc.premium_purchase.push(item);
|
|
} else if (r9 != null) {
|
|
acc.purchase.push(item);
|
|
} else {
|
|
acc.preview.push(item);
|
|
}
|
|
return acc;
|
|
}, {
|
|
purchase: [],
|
|
premium_purchase: [],
|
|
preview: []
|
|
});
|
|
return [{
|
|
section: c9538_6.PURCHASE,
|
|
items: [c9538_7, c9538_8, ...r22.purchase],
|
|
height: 12,
|
|
header: intl.string(t["9x1v/p"])
|
|
}, {
|
|
section: c9538_6.PREMIUM_PURCHASE,
|
|
items: r22.premium_purchase,
|
|
height: 12,
|
|
header: intl.string(t.TiLCgw)
|
|
}, {
|
|
section: c9538_6.PREVIEW,
|
|
items: r22.preview,
|
|
height: 12,
|
|
header: intl.string(t["1vbbee"])
|
|
}].filter((item) => item.items.length > 0);
|
|
}, [r22, r23, stateFromStores]);
|
|
};
|
|
export { c9538_6 as Section };
|
|
export { c9538_7 as NONE_ITEM };
|
|
export { c9538_8 as SHOP_ITEM };
|