@embedreach/components 0.2.63 → 0.2.65

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.
@@ -76047,60 +76047,6 @@ const PreviewAndSchedule = () => {
76047
76047
  }
76048
76048
  return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-4 w-full", children: /* @__PURE__ */ jsx(PreviewPanel, {}) }) });
76049
76049
  };
76050
- const ComboboxDemo = ({
76051
- data,
76052
- placeholder,
76053
- searchPlaceholder,
76054
- noResultsMessage,
76055
- value,
76056
- setValue
76057
- }) => {
76058
- const [open, setOpen] = React.useState(false);
76059
- return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, modal: true, children: [
76060
- /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
76061
- Button$1,
76062
- {
76063
- variant: "outline",
76064
- role: "combobox",
76065
- "aria-expanded": open,
76066
- className: "w-full max-w-[200px] justify-between bg-background",
76067
- children: [
76068
- value ? data.find((item) => item.value === value)?.label : placeholder,
76069
- /* @__PURE__ */ jsx(ChevronsUpDown, { className: "opacity-50" })
76070
- ]
76071
- }
76072
- ) }),
76073
- /* @__PURE__ */ jsx(PopoverContent, { className: "w-[200px] p-0", children: /* @__PURE__ */ jsxs(Command, { children: [
76074
- /* @__PURE__ */ jsx(CommandInput, { placeholder: searchPlaceholder, className: "h-9" }),
76075
- /* @__PURE__ */ jsxs(CommandList, { children: [
76076
- /* @__PURE__ */ jsx(CommandEmpty, { children: noResultsMessage }),
76077
- /* @__PURE__ */ jsx(CommandGroup, { children: data.map((item) => /* @__PURE__ */ jsxs(
76078
- CommandItem,
76079
- {
76080
- value: item.value,
76081
- onSelect: (currentValue) => {
76082
- setValue(currentValue === value ? "" : currentValue);
76083
- setOpen(false);
76084
- },
76085
- children: [
76086
- item.label,
76087
- /* @__PURE__ */ jsx(
76088
- Check,
76089
- {
76090
- className: cn$1(
76091
- "ml-auto",
76092
- value === item.value ? "opacity-100" : "opacity-0"
76093
- )
76094
- }
76095
- )
76096
- ]
76097
- },
76098
- item.value
76099
- )) })
76100
- ] })
76101
- ] }) })
76102
- ] });
76103
- };
76104
76050
  function _typeof(o2) {
76105
76051
  "@babel/helpers - typeof";
76106
76052
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o3) {
@@ -79591,17 +79537,20 @@ const SetScheduleTime = ({ setScheduleTime, setTimezone, timezone, scheduleTime,
79591
79537
  )
79592
79538
  }
79593
79539
  ),
79594
- /* @__PURE__ */ jsx(
79595
- ComboboxDemo,
79540
+ /* @__PURE__ */ jsx("div", { className: "w-full sm:w-[200px]", children: /* @__PURE__ */ jsx(
79541
+ MultiSelectDialog,
79596
79542
  {
79597
- data: timezoneOptions,
79543
+ options: timezoneOptions,
79544
+ selectedValues: [timezone],
79545
+ setSelectedValues: (values) => handleTimezoneChange(values[0]),
79546
+ onValueChange: (values) => handleTimezoneChange(values[0]),
79598
79547
  placeholder: "Select timezone...",
79599
79548
  searchPlaceholder: "Search timezone...",
79600
- noResultsMessage: "No timezone found",
79601
- value: timezone,
79602
- setValue: handleTimezoneChange
79549
+ emptyMessage: "No timezone found",
79550
+ title: "Select Timezone",
79551
+ singleSelect: true
79603
79552
  }
79604
- )
79553
+ ) })
79605
79554
  ] }),
79606
79555
  error2 && /* @__PURE__ */ jsxs("p", { className: "text-destructive text-sm mt-2 flex items-center", children: [
79607
79556
  /* @__PURE__ */ jsx("span", { className: "mr-2", children: "⚠️" }),
@@ -79611,6 +79560,7 @@ const SetScheduleTime = ({ setScheduleTime, setTimezone, timezone, scheduleTime,
79611
79560
  };
79612
79561
  const AutomationSelectTimeMain = ({ title: title2 = "Edit Schedule Time" }) => {
79613
79562
  const automation2 = useAutomation();
79563
+ const queryClient = useQueryClient();
79614
79564
  const { updateAutomation: businessUpdateAutomation } = useUpdateBusinessAutomation(automation2?.id || "");
79615
79565
  const { toast: toast2 } = useToast();
79616
79566
  const [deliveryOption, setDeliveryOption] = useState(null);
@@ -79626,41 +79576,75 @@ const AutomationSelectTimeMain = ({ title: title2 = "Edit Schedule Time" }) => {
79626
79576
  const updateTriggerTime = useCallback(() => {
79627
79577
  if (!automation2) return;
79628
79578
  if (deliveryOption === "sendNow" || scheduledAt === "now") {
79629
- businessUpdateAutomation({
79630
- trigger: {
79631
- triggerType: AutomationTriggerType.ONE_TIME,
79632
- scheduledAt: "now"
79579
+ businessUpdateAutomation(
79580
+ {
79581
+ trigger: {
79582
+ triggerType: AutomationTriggerType.ONE_TIME,
79583
+ scheduledAt: "now"
79584
+ }
79585
+ },
79586
+ {
79587
+ onSuccess: () => {
79588
+ setPendingToast({
79589
+ title: "Schedule time updated successfully 🚀",
79590
+ description: `${t$1("engage:broadcast")} scheduled to begin sending in 5 minutes after you activate it`
79591
+ });
79592
+ },
79593
+ onError: () => {
79594
+ toast2({
79595
+ title: "Failed to update schedule time",
79596
+ description: "Please try again",
79597
+ variant: "destructive"
79598
+ });
79599
+ queryClient.invalidateQueries({
79600
+ queryKey: automationKeys.all
79601
+ });
79602
+ }
79633
79603
  }
79634
- });
79635
- setPendingToast({
79636
- title: "Schedule time updated successfully 🚀",
79637
- description: `${t$1("engage:broadcast")} scheduled to begin sending in 5 minutes after you activate it`
79638
- });
79604
+ );
79639
79605
  } else if (scheduledAt && timezone) {
79640
- businessUpdateAutomation({
79641
- trigger: {
79642
- triggerType: AutomationTriggerType.ONE_TIME,
79643
- scheduledAt,
79644
- timezone
79606
+ businessUpdateAutomation(
79607
+ {
79608
+ trigger: {
79609
+ triggerType: AutomationTriggerType.ONE_TIME,
79610
+ scheduledAt,
79611
+ timezone
79612
+ }
79613
+ },
79614
+ {
79615
+ onSuccess: () => {
79616
+ setPendingToast({
79617
+ title: "Schedule time updated successfully 🚀",
79618
+ description: `${t$1("engage:broadcast")} scheduled to start at ${new Date(
79619
+ scheduledAt
79620
+ ).toLocaleString("en-US", {
79621
+ weekday: "long",
79622
+ month: "long",
79623
+ day: "numeric"
79624
+ })}`
79625
+ });
79626
+ },
79627
+ onError: () => {
79628
+ toast2({
79629
+ title: "Failed to update schedule time",
79630
+ description: "Please try again",
79631
+ variant: "destructive"
79632
+ });
79633
+ queryClient.invalidateQueries({
79634
+ queryKey: automationKeys.all
79635
+ });
79636
+ }
79645
79637
  }
79646
- });
79647
- setPendingToast({
79648
- title: "Schedule time updated successfully 🚀",
79649
- description: `${t$1("engage:broadcast")} scheduled to start at ${new Date(
79650
- scheduledAt
79651
- ).toLocaleString("en-US", {
79652
- weekday: "long",
79653
- month: "long",
79654
- day: "numeric"
79655
- })}`
79656
- });
79638
+ );
79657
79639
  }
79658
79640
  }, [
79641
+ automation2,
79659
79642
  deliveryOption,
79660
79643
  scheduledAt,
79661
79644
  timezone,
79662
79645
  businessUpdateAutomation,
79663
- automation2
79646
+ toast2,
79647
+ queryClient
79664
79648
  ]);
79665
79649
  useEffect(() => {
79666
79650
  if (pendingToast) {
@@ -81811,9 +81795,13 @@ const AutomationAudienceSelectorMain = ({ title: title2 = "Preview Audience" })
81811
81795
  ) !== void 0;
81812
81796
  useEffect(() => {
81813
81797
  if (automation2 && !initialStateSet) {
81814
- setSelectedAudience(
81815
- allUsersSelected || includedSegments.length > 0 && excludedSegments.length === 0 ? "all" : "segments"
81816
- );
81798
+ if (includedSegments.length === 1 && segments?.find(
81799
+ (segment2) => segment2.type === BusinessSegmentTypeEnum.ALL_USERS && segment2.id === includedSegments[0]
81800
+ ) !== void 0) {
81801
+ setSelectedAudience("all");
81802
+ } else {
81803
+ setSelectedAudience("segments");
81804
+ }
81817
81805
  getCountOfBusinessAutomationRecipients({
81818
81806
  includeSegments: includedSegments,
81819
81807
  excludeSegments: excludedSegments
@@ -81827,7 +81815,8 @@ const AutomationAudienceSelectorMain = ({ title: title2 = "Preview Audience" })
81827
81815
  allUsersSelected,
81828
81816
  initialStateSet,
81829
81817
  includedSegments,
81830
- excludedSegments
81818
+ excludedSegments,
81819
+ segments
81831
81820
  ]);
81832
81821
  const handleAudienceSelectionChange = (value) => {
81833
81822
  setSelectedAudience(value);
@@ -82186,14 +82175,14 @@ const getAutomationSteps = ({
82186
82175
  ),
82187
82176
  footerConfig: {
82188
82177
  backText: "Back",
82189
- nextText: "Schedule",
82178
+ nextText: automation2.triggerMetadata && "scheduledAt" in automation2.triggerMetadata && automation2.triggerMetadata.scheduledAt === "now" ? "Send Now" : "Schedule",
82190
82179
  hideBack: false,
82191
82180
  backDisabled: false,
82192
82181
  getInfoTooltipTitle: () => {
82193
82182
  const smsChannelSender = smsChannelSenders.find(
82194
82183
  (sender) => sender.channelSender.id === communicationGroup.smsChannelSenderId
82195
82184
  );
82196
- if (!smsChannelSender || smsChannelSender.smsApplication !== null && smsChannelSender.smsApplication?.status !== SmsRegistrationApplicationStatus.APPROVED) {
82185
+ if (smsChannelSender && smsChannelSender.smsApplication !== null && smsChannelSender.smsApplication?.status !== SmsRegistrationApplicationStatus.APPROVED) {
82197
82186
  return "You cannot send this yet if you have selected a text channel and don't have an approved SMS application. Please save as draft and try again later.";
82198
82187
  }
82199
82188
  return void 0;
@@ -85849,6 +85838,7 @@ function AutomationCancelRunningDialog({
85849
85838
  const automation2 = useAutomation();
85850
85839
  const { toast: toast2 } = useToast();
85851
85840
  const { updateAutomation: businessUpdateAutomation } = useUpdateBusinessAutomation(automation2?.id || "");
85841
+ const queryClient = useQueryClient();
85852
85842
  const handleCancel = () => {
85853
85843
  if (!automation2) {
85854
85844
  return;
@@ -85867,6 +85857,9 @@ function AutomationCancelRunningDialog({
85867
85857
  description: `Please contact your administrator.`,
85868
85858
  variant: "destructive"
85869
85859
  });
85860
+ queryClient.invalidateQueries({
85861
+ queryKey: automationKeys.all
85862
+ });
85870
85863
  },
85871
85864
  onSuccess: () => {
85872
85865
  onOpenChange(false);
@@ -85947,20 +85940,37 @@ function AutomationConvertToDraftDialog({
85947
85940
  const automation2 = useAutomation();
85948
85941
  const { updateAutomation: businessUpdateAutomation } = useUpdateBusinessAutomation(automation2?.id || "");
85949
85942
  const { toast: toast2 } = useToast();
85950
- const automationName = automation2?.triggerType === AutomationTriggerType.ONE_TIME ? t$1("engage:automation") : t$1("engage:broadcast");
85943
+ const queryClient = useQueryClient();
85944
+ const automationName = automation2?.triggerType === AutomationTriggerType.ONE_TIME ? t$1("engage:broadcast") : t$1("engage:automation");
85951
85945
  const handleDeactivate = () => {
85952
- businessUpdateAutomation({
85953
- status: AutomationStatus.DRAFT
85954
- });
85955
- onOpenChange(false);
85956
- setIsActive(false);
85957
- toast2({
85958
- title: `Updated ${automationName}`,
85959
- description: `${automationName} status updated to draft`
85960
- });
85946
+ businessUpdateAutomation(
85947
+ {
85948
+ status: AutomationStatus.DRAFT
85949
+ },
85950
+ {
85951
+ onSuccess: () => {
85952
+ toast2({
85953
+ title: `Updated ${automationName}`,
85954
+ description: `${automationName} status updated to draft`
85955
+ });
85956
+ onOpenChange(false);
85957
+ setIsActive(false);
85958
+ },
85959
+ onError: () => {
85960
+ toast2({
85961
+ title: `Failed to update ${automationName}`,
85962
+ description: "Please try again"
85963
+ });
85964
+ queryClient.invalidateQueries({
85965
+ queryKey: automationKeys.all
85966
+ });
85967
+ }
85968
+ }
85969
+ );
85961
85970
  };
85971
+ const dialogTitle = automation2?.triggerType === AutomationTriggerType.ONE_TIME ? "Unschedule" : "Convert to draft";
85962
85972
  return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-[425px]", children: [
85963
- /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: "Convert to draft" }) }),
85973
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: dialogTitle }) }),
85964
85974
  /* @__PURE__ */ jsxs("div", { children: [
85965
85975
  "Are you sure you want to convert",
85966
85976
  /* @__PURE__ */ jsx("span", { className: "font-bold px-1 text-primary", children: automation2?.name }),
@@ -85970,7 +85980,7 @@ function AutomationConvertToDraftDialog({
85970
85980
  ] }),
85971
85981
  /* @__PURE__ */ jsxs(DialogFooter, { className: "gap-2 sm:gap-0", children: [
85972
85982
  /* @__PURE__ */ jsx(Button$1, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
85973
- /* @__PURE__ */ jsx(Button$1, { variant: "destructive", onClick: handleDeactivate, children: "Convert to draft" })
85983
+ /* @__PURE__ */ jsx(Button$1, { variant: "destructive", onClick: handleDeactivate, children: dialogTitle })
85974
85984
  ] })
85975
85985
  ] }) });
85976
85986
  }
@@ -86070,6 +86080,7 @@ const AutomationsEditorHeader = ({ showBackButton, onDuplicationCreated, onBefor
86070
86080
  const { data: smsApplication } = useGetLatestSmsRegistrationApplication();
86071
86081
  const { channelSenders } = useChannelSender();
86072
86082
  const { channelAccounts } = useChannelAccount();
86083
+ const queryClient = useQueryClient();
86073
86084
  const [isActive, setIsActive] = useState(void 0);
86074
86085
  const [isDuplicateDialogOpen, setIsDuplicateDialogOpen] = useState(false);
86075
86086
  const [isStatusDialogOpen, setIsStatusDialogOpen] = useState(false);
@@ -86236,6 +86247,9 @@ const AutomationsEditorHeader = ({ showBackButton, onDuplicationCreated, onBefor
86236
86247
  variant: "destructive"
86237
86248
  });
86238
86249
  setEditingStatus(false);
86250
+ queryClient.invalidateQueries({
86251
+ queryKey: automationKeys.all
86252
+ });
86239
86253
  }
86240
86254
  }
86241
86255
  );
@@ -86471,14 +86485,15 @@ const AutomationsEditorHeader = ({ showBackButton, onDuplicationCreated, onBefor
86471
86485
  }
86472
86486
  }, [
86473
86487
  automation2,
86488
+ communicationGroup,
86489
+ smsChannelSenders,
86474
86490
  toast2,
86475
86491
  isActive,
86476
86492
  onBeforeSchedule,
86477
- communicationGroup,
86478
86493
  businessUpdateAutomation,
86479
86494
  estimatedMatchesStats,
86480
86495
  numberOfTimesSentClicked,
86481
- smsChannelSenders
86496
+ queryClient
86482
86497
  ]);
86483
86498
  const renderPill = useMemo(() => {
86484
86499
  if (!automation2) {
@@ -86502,9 +86517,23 @@ const AutomationsEditorHeader = ({ showBackButton, onDuplicationCreated, onBefor
86502
86517
  value: automation2.name,
86503
86518
  schema: nameSchema,
86504
86519
  onSubmit: (values) => {
86505
- return businessUpdateAutomation({
86506
- name: values.name
86507
- });
86520
+ businessUpdateAutomation(
86521
+ {
86522
+ name: values.name
86523
+ },
86524
+ {
86525
+ onError: () => {
86526
+ toast2({
86527
+ title: "Failed to update automation name",
86528
+ description: "Please try again",
86529
+ variant: "destructive"
86530
+ });
86531
+ queryClient.invalidateQueries({
86532
+ queryKey: automationKeys.all
86533
+ });
86534
+ }
86535
+ }
86536
+ );
86508
86537
  },
86509
86538
  fieldName: "name",
86510
86539
  className: "text-lg",
@@ -86518,9 +86547,23 @@ const AutomationsEditorHeader = ({ showBackButton, onDuplicationCreated, onBefor
86518
86547
  value: automation2.description || "",
86519
86548
  schema: descriptionSchema,
86520
86549
  onSubmit: (values) => {
86521
- return businessUpdateAutomation({
86522
- description: values.description
86523
- });
86550
+ businessUpdateAutomation(
86551
+ {
86552
+ description: values.description
86553
+ },
86554
+ {
86555
+ onError: () => {
86556
+ toast2({
86557
+ title: "Failed to update automation description",
86558
+ description: "Please try again",
86559
+ variant: "destructive"
86560
+ });
86561
+ queryClient.invalidateQueries({
86562
+ queryKey: automationKeys.all
86563
+ });
86564
+ }
86565
+ }
86566
+ );
86524
86567
  },
86525
86568
  fieldName: "description",
86526
86569
  className: `text-sm ${automation2.description ? "text-current" : "text-muted-foreground"}`,