@redacto.io/consent-sdk-react 10.2.2-beta.0 → 10.2.2-beta.2

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.
@@ -308,7 +308,7 @@ declare enum RequestTypeEnum {
308
308
  NOMINATION = "nomination"
309
309
  }
310
310
  type NominationData = {
311
- nominee_email: string;
311
+ nominee_email?: string;
312
312
  nominee_mobile?: string;
313
313
  };
314
314
  type UpdatePurpose = {
@@ -308,7 +308,7 @@ declare enum RequestTypeEnum {
308
308
  NOMINATION = "nomination"
309
309
  }
310
310
  type NominationData = {
311
- nominee_email: string;
311
+ nominee_email?: string;
312
312
  nominee_mobile?: string;
313
313
  };
314
314
  type UpdatePurpose = {
@@ -19604,10 +19604,7 @@ function NominationDataSection({
19604
19604
  /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
19605
19605
  PCInput,
19606
19606
  {
19607
- label: /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("span", { children: [
19608
- t("nomineeEmail"),
19609
- /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { style: { color: getVar17("--pc-error") }, children: "*" })
19610
- ] }),
19607
+ label: t("nomineeEmail"),
19611
19608
  placeholder: t("nomineeEmailPlaceholder"),
19612
19609
  value: (_a = nominationData.nominee_email) != null ? _a : "",
19613
19610
  onChange: (e) => setNominationData((prev) => ({
@@ -20417,6 +20414,9 @@ var PRODUCT_SCOPED_REQUEST_TYPES = /* @__PURE__ */ new Set([
20417
20414
  "CORRECTION" /* CORRECTION */
20418
20415
  ]);
20419
20416
  var isProductScopedRequestType = (rt) => rt !== null && PRODUCT_SCOPED_REQUEST_TYPES.has(rt);
20417
+ var NOMINEE_EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
20418
+ var NOMINEE_MOBILE_PATTERN = /^\+?\d{9,15}$/;
20419
+ var cleanNomineeMobile = (mobile) => (mobile != null ? mobile : "").replace(/[\s\-().]/g, "");
20420
20420
  var extractCaseId = (response) => {
20421
20421
  var _a, _b, _c, _d;
20422
20422
  if (!response) {
@@ -20847,9 +20847,11 @@ function Form({
20847
20847
  }));
20848
20848
  }
20849
20849
  if (requestType === "nomination" /* NOMINATION */) {
20850
+ const nomineeEmail = (_a2 = nominationData.nominee_email) == null ? void 0 : _a2.trim();
20851
+ const nomineeMobile = cleanNomineeMobile(nominationData.nominee_mobile);
20850
20852
  requestDetails.nomination_data = {
20851
- nominee_email: nominationData.nominee_email.trim(),
20852
- ...((_a2 = nominationData.nominee_mobile) == null ? void 0 : _a2.trim()) ? { nominee_mobile: nominationData.nominee_mobile.trim() } : {}
20853
+ ...nomineeEmail ? { nominee_email: nomineeEmail } : {},
20854
+ ...nomineeMobile ? { nominee_mobile: nomineeMobile } : {}
20853
20855
  };
20854
20856
  }
20855
20857
  const payload = {
@@ -20905,6 +20907,7 @@ function Form({
20905
20907
  }
20906
20908
  };
20907
20909
  const isRequestDetailsValid = (0, import_react44.useCallback)(() => {
20910
+ var _a2, _b2;
20908
20911
  if (!requestType) {
20909
20912
  return false;
20910
20913
  }
@@ -20918,8 +20921,8 @@ function Form({
20918
20921
  if (requestType === "CORRECTION" /* CORRECTION */) {
20919
20922
  return selectedCorrectionElements.length > 0 && selectedCorrectionElements.every(
20920
20923
  (name) => {
20921
- var _a2, _b2, _c2, _d2;
20922
- return ((_b2 = (_a2 = correctionValues[name]) == null ? void 0 : _a2.current) == null ? void 0 : _b2.trim()) && ((_d2 = (_c2 = correctionValues[name]) == null ? void 0 : _c2.updated) == null ? void 0 : _d2.trim());
20924
+ var _a3, _b3, _c2, _d2;
20925
+ return ((_b3 = (_a3 = correctionValues[name]) == null ? void 0 : _a3.current) == null ? void 0 : _b3.trim()) && ((_d2 = (_c2 = correctionValues[name]) == null ? void 0 : _c2.updated) == null ? void 0 : _d2.trim());
20923
20926
  }
20924
20927
  );
20925
20928
  }
@@ -20930,10 +20933,12 @@ function Form({
20930
20933
  switch (requestType) {
20931
20934
  case "grievance" /* GRIEVANCE */:
20932
20935
  return Object.values(selectedGrievances).some(Boolean);
20933
- case "nomination" /* NOMINATION */:
20934
- return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(
20935
- nominationData.nominee_email.trim()
20936
- );
20936
+ case "nomination" /* NOMINATION */: {
20937
+ const nomineeEmail = (_b2 = (_a2 = nominationData.nominee_email) == null ? void 0 : _a2.trim()) != null ? _b2 : "";
20938
+ const nomineeMobile = cleanNomineeMobile(nominationData.nominee_mobile);
20939
+ if (!nomineeEmail && !nomineeMobile) return false;
20940
+ return (!nomineeEmail || NOMINEE_EMAIL_PATTERN.test(nomineeEmail)) && (!nomineeMobile || NOMINEE_MOBILE_PATTERN.test(nomineeMobile));
20941
+ }
20937
20942
  default:
20938
20943
  return false;
20939
20944
  }
@@ -19499,10 +19499,7 @@ function NominationDataSection({
19499
19499
  /* @__PURE__ */ jsx61(
19500
19500
  PCInput,
19501
19501
  {
19502
- label: /* @__PURE__ */ jsxs38("span", { children: [
19503
- t("nomineeEmail"),
19504
- /* @__PURE__ */ jsx61("span", { style: { color: getVar17("--pc-error") }, children: "*" })
19505
- ] }),
19502
+ label: t("nomineeEmail"),
19506
19503
  placeholder: t("nomineeEmailPlaceholder"),
19507
19504
  value: (_a = nominationData.nominee_email) != null ? _a : "",
19508
19505
  onChange: (e) => setNominationData((prev) => ({
@@ -20312,6 +20309,9 @@ var PRODUCT_SCOPED_REQUEST_TYPES = /* @__PURE__ */ new Set([
20312
20309
  "CORRECTION" /* CORRECTION */
20313
20310
  ]);
20314
20311
  var isProductScopedRequestType = (rt) => rt !== null && PRODUCT_SCOPED_REQUEST_TYPES.has(rt);
20312
+ var NOMINEE_EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
20313
+ var NOMINEE_MOBILE_PATTERN = /^\+?\d{9,15}$/;
20314
+ var cleanNomineeMobile = (mobile) => (mobile != null ? mobile : "").replace(/[\s\-().]/g, "");
20315
20315
  var extractCaseId = (response) => {
20316
20316
  var _a, _b, _c, _d;
20317
20317
  if (!response) {
@@ -20742,9 +20742,11 @@ function Form({
20742
20742
  }));
20743
20743
  }
20744
20744
  if (requestType === "nomination" /* NOMINATION */) {
20745
+ const nomineeEmail = (_a2 = nominationData.nominee_email) == null ? void 0 : _a2.trim();
20746
+ const nomineeMobile = cleanNomineeMobile(nominationData.nominee_mobile);
20745
20747
  requestDetails.nomination_data = {
20746
- nominee_email: nominationData.nominee_email.trim(),
20747
- ...((_a2 = nominationData.nominee_mobile) == null ? void 0 : _a2.trim()) ? { nominee_mobile: nominationData.nominee_mobile.trim() } : {}
20748
+ ...nomineeEmail ? { nominee_email: nomineeEmail } : {},
20749
+ ...nomineeMobile ? { nominee_mobile: nomineeMobile } : {}
20748
20750
  };
20749
20751
  }
20750
20752
  const payload = {
@@ -20800,6 +20802,7 @@ function Form({
20800
20802
  }
20801
20803
  };
20802
20804
  const isRequestDetailsValid = useCallback15(() => {
20805
+ var _a2, _b2;
20803
20806
  if (!requestType) {
20804
20807
  return false;
20805
20808
  }
@@ -20813,8 +20816,8 @@ function Form({
20813
20816
  if (requestType === "CORRECTION" /* CORRECTION */) {
20814
20817
  return selectedCorrectionElements.length > 0 && selectedCorrectionElements.every(
20815
20818
  (name) => {
20816
- var _a2, _b2, _c2, _d2;
20817
- return ((_b2 = (_a2 = correctionValues[name]) == null ? void 0 : _a2.current) == null ? void 0 : _b2.trim()) && ((_d2 = (_c2 = correctionValues[name]) == null ? void 0 : _c2.updated) == null ? void 0 : _d2.trim());
20819
+ var _a3, _b3, _c2, _d2;
20820
+ return ((_b3 = (_a3 = correctionValues[name]) == null ? void 0 : _a3.current) == null ? void 0 : _b3.trim()) && ((_d2 = (_c2 = correctionValues[name]) == null ? void 0 : _c2.updated) == null ? void 0 : _d2.trim());
20818
20821
  }
20819
20822
  );
20820
20823
  }
@@ -20825,10 +20828,12 @@ function Form({
20825
20828
  switch (requestType) {
20826
20829
  case "grievance" /* GRIEVANCE */:
20827
20830
  return Object.values(selectedGrievances).some(Boolean);
20828
- case "nomination" /* NOMINATION */:
20829
- return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(
20830
- nominationData.nominee_email.trim()
20831
- );
20831
+ case "nomination" /* NOMINATION */: {
20832
+ const nomineeEmail = (_b2 = (_a2 = nominationData.nominee_email) == null ? void 0 : _a2.trim()) != null ? _b2 : "";
20833
+ const nomineeMobile = cleanNomineeMobile(nominationData.nominee_mobile);
20834
+ if (!nomineeEmail && !nomineeMobile) return false;
20835
+ return (!nomineeEmail || NOMINEE_EMAIL_PATTERN.test(nomineeEmail)) && (!nomineeMobile || NOMINEE_MOBILE_PATTERN.test(nomineeMobile));
20836
+ }
20832
20837
  default:
20833
20838
  return false;
20834
20839
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redacto.io/consent-sdk-react",
3
- "version": "10.2.2-beta.0",
3
+ "version": "10.2.2-beta.2",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",