68 lines
2.3 KiB
TypeScript
68 lines
2.3 KiB
TypeScript
// Metro module 13732 (f13733).
|
|
import { useMemo } from "react";
|
|
import CollectiblesCategoryStore from "../CollectiblesCategoryStore";
|
|
import CollectiblesPurchaseStore from "../CollectiblesPurchaseStore";
|
|
import { useStateFromStores, useStateFromStoresArray } from "../../../_bundle/defaultAreStatesEqual";
|
|
import { getNameplates, isPremiumCollectiblesPurchase, isPremiumCollectiblesProduct } from "../CollectiblesUtils";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
let c9547_6 = {
|
|
PURCHASE: "purchase",
|
|
PREMIUM_PURCHASE: "premium_purchase",
|
|
PREVIEW: "preview"
|
|
};
|
|
let c9547_7 = {
|
|
skuId: "None"
|
|
};
|
|
let c9547_8 = {
|
|
skuId: "Shop"
|
|
};
|
|
export default function useNameplateSections() {
|
|
let c20683_1, c20683_2;
|
|
const stateFromStores = useStateFromStores([CollectiblesPurchaseStore], () => CollectiblesPurchaseStore.purchases);
|
|
const [r22, r23] = useStateFromStoresArray([CollectiblesCategoryStore], () => [CollectiblesCategoryStore.categories, CollectiblesCategoryStore.products]);
|
|
c20683_1 = r22;
|
|
c20683_2 = r23;
|
|
return useMemo(() => {
|
|
const r22 = getNameplates(stateFromStores, c20683_1).reduce((acc, item) => {
|
|
const r8 = stateFromStores.get(item.skuId);
|
|
const r12 = c20683_2.get(item.skuId);
|
|
const r19 = r8 != null ? isPremiumCollectiblesPurchase(r8) : isPremiumCollectiblesProduct(r12);
|
|
let r27 = r12?.isCategoryReward;
|
|
if (r27 == null) {
|
|
r27 = false;
|
|
}
|
|
if (r19) {
|
|
acc.premium_purchase.push(item);
|
|
} else if (r8 != null) {
|
|
acc.purchase.push(item);
|
|
} else if (!r27) {
|
|
acc.preview.push(item);
|
|
}
|
|
return acc;
|
|
}, {
|
|
purchase: [],
|
|
premium_purchase: [],
|
|
preview: []
|
|
});
|
|
return [{
|
|
section: c9547_6.PURCHASE,
|
|
items: [c9547_7, c9547_8, ...r22.purchase],
|
|
height: 12,
|
|
header: intl.string(t.WfGV52)
|
|
}, {
|
|
section: c9547_6.PREMIUM_PURCHASE,
|
|
items: r22.premium_purchase,
|
|
height: 12,
|
|
header: intl.string(t.TiLCgw)
|
|
}, {
|
|
section: c9547_6.PREVIEW,
|
|
items: r22.preview,
|
|
height: 12,
|
|
header: intl.string(t["1vbbee"])
|
|
}].filter((item) => item.items.length > 0);
|
|
}, [r22, stateFromStores, r23]);
|
|
};
|
|
export { c9547_6 as Section };
|
|
export { c9547_7 as NONE_ITEM };
|
|
export { c9547_8 as SHOP_ITEM };
|