@orderingstack/front-components-product-configurator 1.4.2-beta.20 → 1.4.2-beta.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -6895,12 +6895,14 @@ const getProductToChangeInForm = (product, isFilterValidated) => {
6895
6895
  return { productsToSelect, productsToUnselect };
6896
6896
  };
6897
6897
  const unselectProductsInForm = (productsToUnselect, setValueInForm) => {
6898
+ console.log("LOG1 productsToUnselect", productsToUnselect);
6898
6899
  productsToUnselect.map(({ selCtx, id }) => {
6899
6900
  setValueInForm(`selected.${selCtx}.${id}`, false);
6900
6901
  });
6901
6902
  };
6902
- const selectProductsInForm = (productToUnselect, setValueInForm, initialSelectedState) => {
6903
- productToUnselect.map(({ selCtx, id }) => {
6903
+ const selectProductsInForm = (productToSelect, setValueInForm, initialSelectedState) => {
6904
+ console.log("LOG1 productToSelect", productToSelect);
6905
+ productToSelect.map(({ selCtx, id }) => {
6904
6906
  var _a;
6905
6907
  const productInInitialState = (_a = initialSelectedState[selCtx]) == null ? void 0 : _a[id];
6906
6908
  if (productInInitialState) {
@@ -6916,8 +6918,9 @@ function useMenuOptions(product, nestedLvl, parentKind, parentSelCtx) {
6916
6918
  useStore((state) => state.filter);
6917
6919
  const initialSelected = useStore((state) => state.initialSelected);
6918
6920
  const currency = useStore((state) => state.currency);
6919
- const { setValue, getValues } = useFormContext();
6920
- const { selected = {}, filter = {} } = getValues();
6921
+ const { setValue, getValues, watch } = useFormContext();
6922
+ const selected = watch("selected");
6923
+ const filter = watch("filter");
6921
6924
  const isFilterValidated = validateProductFilter(product, filter);
6922
6925
  const isOnSubmitted = useStore((state) => state.isOnSubmitted);
6923
6926
  const setValidationMap = useStore((state) => state.setValidationMap);
@@ -6937,16 +6940,15 @@ function useMenuOptions(product, nestedLvl, parentKind, parentSelCtx) {
6937
6940
  parentKind
6938
6941
  });
6939
6942
  useEffect(() => {
6940
- console.log("isFilterValidated useEffect");
6941
6943
  const { productsToSelect, productsToUnselect } = getProductToChangeInForm(
6942
6944
  product,
6943
6945
  isFilterValidated
6944
6946
  );
6945
- console.log({ productsToSelect });
6946
- console.log({ productsToUnselect });
6947
- unselectProductsInForm(productsToUnselect, setValue);
6947
+ console.log("LOG1 useMenuOptions useEffect productsToUnselect", productsToUnselect);
6948
+ console.log("LOG1 useMenuOptions useEffect productsToSelect", productsToSelect);
6948
6949
  selectProductsInForm(productsToSelect, setValue, initialSelected);
6949
- }, [isFilterValidated, initialSelected]);
6950
+ unselectProductsInForm(productsToUnselect, setValue);
6951
+ }, [isFilterValidated, selected]);
6950
6952
  return {
6951
6953
  isFilterValidated,
6952
6954
  selected,
@@ -11027,7 +11029,6 @@ function ProductConfigurator(props) {
11027
11029
  const {
11028
11030
  encodedProduct,
11029
11031
  initSelected,
11030
- filter,
11031
11032
  productQuantity,
11032
11033
  setIsOnSubmittedOnTrue,
11033
11034
  getInvalidSelCtxArray,
@@ -11049,7 +11050,6 @@ function ProductConfigurator(props) {
11049
11050
  setValidationMap(validationMapNew);
11050
11051
  }
11051
11052
  });
11052
- console.log("ProductConfigurator initSelected", initSelected);
11053
11053
  const methods = useForm({
11054
11054
  defaultValues: {
11055
11055
  selected: initSelected
@@ -11071,6 +11071,8 @@ function ProductConfigurator(props) {
11071
11071
  } else {
11072
11072
  console.log("selected", getValues("selected"));
11073
11073
  const decodedCleanedSelected = decodeSelected(cleanSelected(getValues("selected")));
11074
+ const filter = getValues("filter");
11075
+ console.log("filter", filter);
11074
11076
  console.log("decodedCleanedSelected: ", decodedCleanedSelected);
11075
11077
  handleAddToCart({
11076
11078
  price: countedProductPrice,