nitro-react/src/components/catalog/views/page/widgets/CatalogLimitedItemWidgetView.tsx

20 lines
884 B
TypeScript
Raw Normal View History

2022-02-01 07:58:19 +01:00
import { FC } from 'react';
2022-03-12 06:52:59 +01:00
import { Base, BaseProps, LayoutLimitedEditionCompletePlateView } from '../../../../../common';
2022-02-02 21:54:40 +01:00
import { useCatalogContext } from '../../../CatalogContext';
2022-02-01 07:58:19 +01:00
import { Offer } from '../../../common/Offer';
export const CatalogLimitedItemWidgetView: FC<BaseProps<HTMLDivElement>> = props =>
{
const { children = null, ...rest } = props;
const { currentOffer = null } = useCatalogContext();
if(!currentOffer || (currentOffer.pricingModel !== Offer.PRICING_MODEL_SINGLE) || !currentOffer.product.isUniqueLimitedItem) return null;
return (
<Base { ...rest }>
2022-03-12 06:52:59 +01:00
<LayoutLimitedEditionCompletePlateView className="mx-auto" uniqueLimitedItemsLeft={ currentOffer.product.uniqueLimitedItemsLeft } uniqueLimitedSeriesSize={ currentOffer.product.uniqueLimitedItemSeriesSize } />
2022-02-01 07:58:19 +01:00
{ children }
</Base>
);
}