@octaviaflow/core 3.1.0-beta.89 → 3.1.0-beta.90

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.js CHANGED
@@ -37065,7 +37065,7 @@ var CHANNEL_TYPE_META = {
37065
37065
  whatsapp: {
37066
37066
  label: "WhatsApp",
37067
37067
  hint: "Template messages to a phone number.",
37068
- connected: true,
37068
+ connected: false,
37069
37069
  icon: /* @__PURE__ */ jsx152(ChatLaunchIcon, { size: "sm", "aria-hidden": "true" })
37070
37070
  },
37071
37071
  webhook: {
@@ -37826,9 +37826,12 @@ import { useEffect as useEffect57, useMemo as useMemo41, useState as useState80
37826
37826
  var CONNECTED_CHANNEL_TYPES = [
37827
37827
  "slack",
37828
37828
  "teams",
37829
- "google_chat",
37830
- "whatsapp"
37829
+ "google_chat"
37831
37830
  ];
37831
+ function isValidPhoneNumber(value) {
37832
+ const digits = value.replace(/[^\d]/g, "");
37833
+ return /^\+?[\d\s()-]+$/.test(value.trim()) && digits.length >= 8 && digits.length <= 15;
37834
+ }
37832
37835
  var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
37833
37836
  function isValidEmail(value) {
37834
37837
  return EMAIL_RE.test(value.trim());
@@ -37855,6 +37858,10 @@ function validateChannelDraft(draft) {
37855
37858
  if (!draft.url?.trim()) errors.url = "Enter the endpoint URL.";
37856
37859
  else if (!isValidWebhookUrl(draft.url))
37857
37860
  errors.url = "Enter a full URL, starting with https://.";
37861
+ } else if (draft.type === "whatsapp") {
37862
+ if (!draft.target?.trim()) errors.target = "Enter the recipient\u2019s WhatsApp number.";
37863
+ else if (!isValidPhoneNumber(draft.target))
37864
+ errors.target = "Enter a valid number in international format, e.g. +91 98765 43210.";
37858
37865
  }
37859
37866
  return errors;
37860
37867
  }
@@ -38196,6 +38203,23 @@ function NotificationChannelForm({
38196
38203
  disabled: readOnly,
38197
38204
  size
38198
38205
  }
38206
+ ),
38207
+ value.type === "whatsapp" && /* @__PURE__ */ jsx158(
38208
+ Input,
38209
+ {
38210
+ id: `${baseId}-target`,
38211
+ type: "tel",
38212
+ label: TARGET_LABEL.whatsapp ?? "Phone number",
38213
+ placeholder: TARGET_PLACEHOLDER.whatsapp,
38214
+ value: value.target ?? "",
38215
+ onChange: (e) => patch({ target: e.target.value }),
38216
+ onBlur: () => touch("target"),
38217
+ error: Boolean(errorFor("target")),
38218
+ errorMessage: errorText("target"),
38219
+ helperText: "Sent from Octaviaflow\u2019s WhatsApp using the approved template. Include the country code.",
38220
+ disabled: readOnly,
38221
+ size
38222
+ }
38199
38223
  )
38200
38224
  ] }),
38201
38225
  /* @__PURE__ */ jsxs150("fieldset", { className: "ods-notif-channel-form__section", children: [