if (serviceConfig && currentConfigurator && options) {
const ServiceConfigEffLive = ServiceConfigEff.of({
services: Effect.succeed(serviceConfig),
});
const allGoodsPending = state.goods.pending;
if (!allGoodsPending) {
dispatch(Goods.setPending(true));
pipe(
Configuration.Good.fromProductOptions(currentConfigurator, options),
Effect.match({
onFailure: errs => {
dispatch(
Core.error({
message: `all config products failed to fetch. Errors: ${JSON.stringify(
errs,
)}`,
context: {
type: 'global',
},
}),
);
dispatch(Goods.setPending(false));
return null;
},
onSuccess: products => {
dispatch(Goods.setPending(false));
dispatch(Goods.setAllGoods(products));
return products;
},
}),
Effect.provideService(ServiceConfigEff, ServiceConfigEffLive),
Effect.runPromise,
);
}
}
if (serviceConfig && currentConfigurator && options) {
const ServiceConfigEffLive = ServiceConfigEff.of({
services: Effect.succeed(serviceConfig),
});
const allGoodsPending = state.goods.pending;
if (!allGoodsPending) {
dispatch(Goods.setPending(true));
pipe(
Configuration.Good.fromProductOptions(currentConfigurator, options),
Effect.match({
onFailure: errs => {
dispatch(
Core.error({
message: `all config products failed to fetch. Errors: ${JSON.stringify(
errs,
)}`,
context: {
type: 'global',
},
}),
);
dispatch(Goods.setPending(false));
return null;
},
onSuccess: products => {
dispatch(Goods.setPending(false));
dispatch(Goods.setAllGoods(products));
return products;
},
}),
Effect.provideService(ServiceConfigEff, ServiceConfigEffLive),
Effect.runPromise,
);
}
}