1 | import { useContext } from 'react';
|
2 | import ProductConfigurationContext from '../components/ProductConfigurationProvider/ProductConfigurationContext';
|
3 |
|
4 | export function useDynamicPrice(product, variant) {
|
5 | const configurationContext = useContext(ProductConfigurationContext);
|
6 |
|
7 |
|
8 | if (configurationContext === null || configurationContext === void 0 ? void 0 : configurationContext.configurationPrice) {
|
9 | return configurationContext.configurationPrice;
|
10 | }
|
11 |
|
12 | if (variant) {
|
13 | const { price, previousPrice } = variant;
|
14 | return {
|
15 | price,
|
16 | previousPrice
|
17 | };
|
18 | }
|
19 |
|
20 | return {
|
21 | price: product === null || product === void 0 ? void 0 : product.price,
|
22 | previousPrice: product === null || product === void 0 ? void 0 : product.previousPrice
|
23 | };
|
24 | }
|
25 |
|
\ | No newline at end of file |