Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const enableRedirectHandler = () => {
if (!isBeta()) {
return;
}
/** Effectivity dates */
const { effectivityDates: { accessExpired } = {} } = getThemeSettings('product') || {};
if (accessExpired) {
return;
}
const getProductEffectivityDates = makeGetProductEffectivityDates();
redirects.set(ITEM_PATTERN, ({ action, getState }) => {
const { params: { pathname }, route: { state: { productId } } } = action;
const effectivityDates = getProductEffectivityDates(getState(), { productId });
if (effectivityDates) {
// Forbid redirect if endDate is expired
if (effectivityDates.endDate
&& isAfter(new Date(), new Date(effectivityDates.endDate))) {
return null;
}
export const buildShowScheduledParams = () => {
if (!isBeta()) {
return {};
}
let cachedTime = null;
let { effectivityDates: { showScheduled } = {} } = getThemeSettings('product') || {};
if (showScheduled === ALWAYS) {
showScheduled = 'P1Y';
} else if (showScheduled === NEVER) {
showScheduled = 'PT0S';
cachedTime = 60000; // 1 minute min effective precision
}
return {
cachedTime,
params: {
showScheduled,
},
};
};
subscribe(productNotAvailableEffDatesPDP$, ({
action, getState, dispatch, events,
}) => {
const { effectivityDates: { accessExpired } = {} } = getThemeSettings('product') || {};
if (accessExpired === false) {
const { productId } = action;
dispatch(historyPop());
const name = getProductName(getState(), { productId });
events.emit(ToastProvider.ADD, {
id: 'product.available.not_search_similar',
message: 'product.available.not_search_similar',
messageParams: {
name,
},
action: () => dispatch(historyPush({
pathname: getSearchRoute(name),
})),
});
}
});
const LocationStockInfo = ({ location, className, showStoreName }) => {
const { locationStockInfo } = getThemeSettings('product');
const settings = defaultsDeep(locationStockInfo, defaultSettings);
const { availabilityText = '', availabilityTextColor = 'inherit' } =
getAvailabilitySettings(settings, location.visibleInventory, location.inventoryBlind);
const defaultClassName = css({
color: availabilityTextColor,
fontSize: '0.875rem',
margin: 0,
});
return (