@timardex/cluemart-shared 1.2.88 → 1.2.89

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.
@@ -192,11 +192,11 @@ var EnumPartnerType = /* @__PURE__ */ ((EnumPartnerType2) => {
192
192
  EnumPartnerType2["SUPPORTING_PARTNER"] = "Supporting_Partner";
193
193
  return EnumPartnerType2;
194
194
  })(EnumPartnerType || {});
195
- var EnumOSPlatform = /* @__PURE__ */ ((EnumOSPlatform2) => {
196
- EnumOSPlatform2["ANDROID"] = "android";
197
- EnumOSPlatform2["IOS"] = "ios";
198
- EnumOSPlatform2["WEB"] = "web";
199
- return EnumOSPlatform2;
195
+ var EnumOSPlatform = /* @__PURE__ */ ((EnumOSPlatform3) => {
196
+ EnumOSPlatform3["ANDROID"] = "android";
197
+ EnumOSPlatform3["IOS"] = "ios";
198
+ EnumOSPlatform3["WEB"] = "web";
199
+ return EnumOSPlatform3;
200
200
  })(EnumOSPlatform || {});
201
201
  var EnumRegions = /* @__PURE__ */ ((EnumRegions2) => {
202
202
  EnumRegions2["Auckland"] = "Auckland";
@@ -1581,10 +1581,13 @@ function useTesterForm(data) {
1581
1581
  handleSubmit,
1582
1582
  reset,
1583
1583
  setValue,
1584
+ trigger,
1584
1585
  watch
1585
1586
  } = (0, import_react_hook_form11.useForm)({
1586
1587
  defaultValues: defaultValues7,
1587
- resolver: (0, import_yup11.yupResolver)(testerSchema)
1588
+ mode: "onChange",
1589
+ resolver: (0, import_yup11.yupResolver)(testerSchema),
1590
+ reValidateMode: "onChange"
1588
1591
  });
1589
1592
  import_react.default.useEffect(() => {
1590
1593
  if (data) {
@@ -1604,34 +1607,80 @@ function useTesterForm(data) {
1604
1607
  } else {
1605
1608
  reset(defaultValues7);
1606
1609
  }
1607
- }, [data]);
1610
+ }, [data, reset]);
1611
+ const resourceType = watch("resourceType");
1612
+ const vendor = watch("vendor");
1613
+ const event = watch("event");
1614
+ import_react.default.useEffect(() => {
1615
+ if (resourceType === "vendor" /* VENDOR */ && vendor === null) {
1616
+ const emptyVendor = {
1617
+ categories: [],
1618
+ marketsAttended: [],
1619
+ productsOrServices: "",
1620
+ questionary: {
1621
+ applyToAtLeastOneMarket: false,
1622
+ completeFeedbackQuestionnaire: false,
1623
+ tryVisitorFeatures: false,
1624
+ uploadStallProfileFirstWeek: false
1625
+ }
1626
+ };
1627
+ setValue("vendor", emptyVendor, { shouldValidate: true });
1628
+ } else if (resourceType === "event" /* EVENT */ && vendor !== null) {
1629
+ setValue("vendor", null, { shouldValidate: true });
1630
+ }
1631
+ }, [resourceType, vendor, setValue]);
1632
+ import_react.default.useEffect(() => {
1633
+ if (resourceType === "event" /* EVENT */ && event === null) {
1634
+ const emptyEvent = {
1635
+ allowMarketingAppearance: false,
1636
+ completeFinalQuestionnaire: false,
1637
+ dailyCoordinationNeeds: "",
1638
+ interestedInCharityInitiative: false,
1639
+ inviteAtLeastFiveStallholders: false,
1640
+ manageApplicationsAndCommunication: false,
1641
+ markets: [],
1642
+ organizerExpectations: "",
1643
+ registerMarketsFirstWeek: false
1644
+ };
1645
+ setValue("event", emptyEvent, { shouldValidate: true });
1646
+ } else if (resourceType === "vendor" /* VENDOR */ && event !== null) {
1647
+ setValue("event", null, { shouldValidate: true });
1648
+ }
1649
+ }, [resourceType, event, setValue]);
1650
+ import_react.default.useEffect(() => {
1651
+ if (resourceType === "vendor" /* VENDOR */ && vendor !== null) {
1652
+ trigger("vendor");
1653
+ }
1654
+ }, [resourceType, vendor, trigger]);
1655
+ import_react.default.useEffect(() => {
1656
+ if (resourceType === "event" /* EVENT */ && event !== null) {
1657
+ trigger("event");
1658
+ }
1659
+ }, [resourceType, event, trigger]);
1608
1660
  const {
1609
1661
  businessName,
1610
1662
  email,
1611
- event,
1612
1663
  firstName,
1613
1664
  lastName,
1614
1665
  mobilePhone,
1615
1666
  osType,
1616
1667
  privacyConsent,
1617
- region,
1618
- resourceType,
1619
- vendor
1668
+ region
1620
1669
  } = getValues();
1621
1670
  return {
1622
1671
  control,
1623
1672
  fields: {
1624
1673
  businessName,
1625
1674
  email,
1626
- event,
1675
+ event: event || null,
1627
1676
  firstName,
1628
1677
  lastName,
1629
1678
  mobilePhone,
1630
1679
  osType,
1631
1680
  privacyConsent,
1632
1681
  region,
1633
- resourceType,
1634
- vendor
1682
+ resourceType: resourceType || "",
1683
+ vendor: vendor || null
1635
1684
  },
1636
1685
  formState: { errors },
1637
1686
  handleSubmit,