Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import React from 'react';
import { Conditioner } from '@shopgate/pwa-core';
export const defaultContext = {
productId: null,
variantId: null,
options: {},
characteristics: {},
setCharacteristic: jest.fn(),
conditioner: new Conditioner(),
};
let context;
export const ProductContext = ({
Provider(props) {
/* eslint-disable react/prop-types */
context = props.value || defaultContext;
return React.createElement('div', null, props.children);
/* eslint-enable react/prop-types */
},
Consumer(props) {
return props.children(context || defaultContext);
},
});
constructor(props) {
super(props);
this.baseContextValue = {
conditioner: new Conditioner(),
};
this.state = {
currency: props.currency,
options: {},
optionsPrices: {},
productId: props.variantId ? props.baseProductId : props.productId,
variantId: props.variantId ? props.variantId : null,
characteristics: null,
quantity: 1,
};
}
constructor(props) {
super(props);
this.baseContextValue = {
conditioner: new Conditioner(),
};
this.state = {
currency: props.currency,
options: {},
optionsPrices: {},
productId: props.variantId ? props.baseProductId : props.productId,
variantId: props.variantId ? props.variantId : null,
characteristics: null,
quantity: 1,
};
}