Files
discord-decomp/modules/collectibles/native/ShopBlockItem.tsx
T
2026-11-01 12:12:55 +02:00

75 lines
3.3 KiB
TypeScript

// Metro module 14612 (f14613).
import { useMemo } from "react";
import { View } from "react-native";
import CollectiblesCategoryStore from "../CollectiblesCategoryStore";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { useStateFromStores } from "../../../_bundle/Module589";
import { ShopBlockType } from "../../../_bundle/Module5829";
import { CollectiblesAnalyticsProvider } from "../CollectiblesAnalyticsContext";
import FramesHeroBlock from "./FramesHeroBlock";
import HeroBlock from "./HeroBlock";
import FeaturedBlock from "./FeaturedBlock";
import FeedBlock from "./FeedBlock";
import FramesProductShelfBlock from "./FramesProductShelfBlock";
import ShelfBlock from "./ShelfBlock";
const useStyles = createStyles({
shopBlockSpacing: {
marginTop: Module712.space.PX_16
}
});
export default ({ block, screen, preferVCPrice, framesBannerBlock }) => {
let stateFromStores2;
stateFromStores2 = void 0;
const styles = useStyles();
const stateFromStores = useStateFromStores([CollectiblesCategoryStore], () => CollectiblesCategoryStore.categories);
stateFromStores2 = useStateFromStores([CollectiblesCategoryStore], () => CollectiblesCategoryStore.products);
const memo = useMemo(() => block.type === ShopBlockType.HERO ? `hero-${block.categoryStoreListingId}` : block.type === ShopBlockType.REWARD_HERO ? `reward-hero-${block.categoryStoreListingId}` : `${stateFromStores.size}-${stateFromStores2.size}`, [block, stateFromStores.size, stateFromStores2.size]);
const type = block.type;
if (ShopBlockType.HERO === type) {
return <CollectiblesAnalyticsProvider newValue={{
pageSection: "top 4"
}}>
{framesBannerBlock != null ? <FramesHeroBlock key={memo} heroBlock={block} bannerBlock={framesBannerBlock} preferVCPrice={preferVCPrice} screen={screen} /> : <HeroBlock key={memo} heroBlock={block} preferVCPrice={preferVCPrice} screen={screen} />}
</CollectiblesAnalyticsProvider>;
}
if (ShopBlockType.FEATURED === type) {
return <CollectiblesAnalyticsProvider newValue={{
pageSection: "featured_block"
}}>
<View key={memo} style={styles.shopBlockSpacing}>
<FeaturedBlock featuredBlock={block} />
</View>
</CollectiblesAnalyticsProvider>;
}
if (ShopBlockType.FEED === type) {
return <CollectiblesAnalyticsProvider newValue={{
pageSection: "popular picks"
}}>
<View style={styles.shopBlockSpacing}>
<FeedBlock key={memo} feedBlock={block} screen={screen} preferVCPrice={preferVCPrice} disableBundleStaticBackground />
</View>
</CollectiblesAnalyticsProvider>;
}
if (ShopBlockType.FRAMES_PRODUCT_SHELF === type) {
return <CollectiblesAnalyticsProvider newValue={{
pageSection: "frames_product_shelf"
}}>
<FramesProductShelfBlock key={memo} block={block} preferVCPrice={preferVCPrice} />
</CollectiblesAnalyticsProvider>;
}
if (ShopBlockType.SHELF === type) {
return <CollectiblesAnalyticsProvider newValue={{
pageSection: block.name
}}>
<View style={styles.shopBlockSpacing}>
<ShelfBlock key={memo} block={block} preferVCPrice={preferVCPrice} />
</View>
</CollectiblesAnalyticsProvider>;
}
if (ShopBlockType.WIDE_BANNER !== type) {
ShopBlockType.FRAMES_BANNER;
}
return null;
};