@embedreach/components 0.2.12 → 0.2.14

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.
@@ -6,6 +6,7 @@ import ReactDOM__default from "react-dom";
6
6
  const BUSINESS_PATH = "/businesses/me";
7
7
  const BUSINESS_SEGMENT_PATH = "/segments";
8
8
  const BUSINESS_AUTOMATION_PATH = "/automations";
9
+ const BUSINESS_AUTOMATION_INTERNAL_PATH = "/automations/internal";
9
10
  const WEB_PRESENCE_PATH = "/web-presence";
10
11
  const WEBSITE_BRAND_SETTINGS_PATH = `${WEB_PRESENCE_PATH}/brand-settings`;
11
12
  const CHANNEL_SENDER_PATH = "/channel/senders";
@@ -2621,7 +2622,14 @@ const createQueryClient = () => new QueryClient({
2621
2622
  const automationKeys = {
2622
2623
  all: ["automations"],
2623
2624
  single: (id2) => [...automationKeys.all, id2],
2624
- recipients: (id2) => [...automationKeys.all, id2, "recipients"],
2625
+ sentCommunications: (args) => [
2626
+ ...automationKeys.all,
2627
+ args.automationId,
2628
+ "sentCommunications",
2629
+ ...args.cursor ? [args.cursor] : [],
2630
+ ...args.limit ? [args.limit] : [],
2631
+ ...args.search ? [args.search] : []
2632
+ ],
2625
2633
  statistics: (id2) => [...automationKeys.all, id2, "statistics"],
2626
2634
  list: (args) => [
2627
2635
  ...automationKeys.all,
@@ -2649,10 +2657,21 @@ const getAutomation = async (automationId) => {
2649
2657
  );
2650
2658
  return response.data;
2651
2659
  };
2652
- const getAutomationRecipients = async (automationId) => {
2653
- const response = await baseRequest(
2654
- `${BUSINESS_AUTOMATION_PATH}/${automationId}/recipients`
2655
- );
2660
+ const getSentCommunications = async (args) => {
2661
+ const params = new URLSearchParams();
2662
+ if (args.cursor) {
2663
+ params.append("cursor", args.cursor);
2664
+ }
2665
+ if (args.limit) {
2666
+ params.append("limit", args.limit.toString());
2667
+ }
2668
+ if (args.search) {
2669
+ params.append("search", args.search);
2670
+ }
2671
+ const url = `${BUSINESS_AUTOMATION_INTERNAL_PATH}/${args.automationId}/sent${params.toString() ? `?${params.toString()}` : ""}`;
2672
+ const response = await baseRequest(url, {
2673
+ method: "GET"
2674
+ });
2656
2675
  return response.data;
2657
2676
  };
2658
2677
  const updateAutomation = async (id2, params) => {
@@ -2736,18 +2755,30 @@ const useGetBusinessAutomation = (automationId) => {
2736
2755
  })
2737
2756
  };
2738
2757
  };
2739
- const useGetBusinessAutomationRecipients = (automationId) => {
2740
- const getAutomationRecipientsQuery = useQuery({
2741
- queryKey: automationKeys.recipients(automationId),
2742
- queryFn: () => getAutomationRecipients(automationId)
2758
+ const useGetBusinessAutomationSentCommunications = (args) => {
2759
+ const getSentCommunicationsQuery = useQuery({
2760
+ queryKey: automationKeys.sentCommunications(args),
2761
+ queryFn: () => getSentCommunications(args),
2762
+ // placeholderData: keepPreviousData is a powerful feature from TanStack Query.
2763
+ // What it does:
2764
+ // 1. When new data is being fetched for a query (e.g., due to a queryKey change like a new cursor),
2765
+ // TanStack Query will continue to show the data from the previous successful fetch (the "placeholder" data)
2766
+ // until the new data arrives.
2767
+ // 2. While this placeholder data is being shown, `isPlaceholderData` will be true.
2768
+ // 3. `isLoading` will only be true if there's no data at all (initial fetch or hard refresh with no cache).
2769
+ // It will be false if placeholder data is being shown, even though a new fetch is in progress (`isFetching` will be true).
2770
+ // This provides a much smoother UX, as the UI doesn't jump to a loading state on pagination or filter changes
2771
+ // if previous data is available to show in the meantime.
2772
+ placeholderData: keepPreviousData
2743
2773
  });
2744
2774
  return {
2745
- // Get automation recipients query
2746
- recipients: getAutomationRecipientsQuery.data,
2747
- isFetching: getAutomationRecipientsQuery.isFetching,
2748
- isLoading: getAutomationRecipientsQuery.isLoading,
2749
- fetchError: getAutomationRecipientsQuery.error,
2750
- refetchAutomationRecipients: getAutomationRecipientsQuery.refetch
2775
+ // Get automation sent communications query
2776
+ sentCommunications: getSentCommunicationsQuery.data,
2777
+ isFetching: getSentCommunicationsQuery.isFetching,
2778
+ isLoading: getSentCommunicationsQuery.isLoading,
2779
+ isPlaceholderData: getSentCommunicationsQuery.isPlaceholderData,
2780
+ fetchError: getSentCommunicationsQuery.error,
2781
+ refetchSentCommunications: getSentCommunicationsQuery.refetch
2751
2782
  };
2752
2783
  };
2753
2784
  const useCreateBusinessAutomation = () => {
@@ -2852,6 +2883,11 @@ var AutomationStatus = /* @__PURE__ */ ((AutomationStatus2) => {
2852
2883
  AutomationStatus2["DEACTIVATED"] = "deactivated";
2853
2884
  return AutomationStatus2;
2854
2885
  })(AutomationStatus || {});
2886
+ var ChannelIntegrationTypeEnum = /* @__PURE__ */ ((ChannelIntegrationTypeEnum2) => {
2887
+ ChannelIntegrationTypeEnum2["EMAIL"] = "email";
2888
+ ChannelIntegrationTypeEnum2["SMS"] = "sms";
2889
+ return ChannelIntegrationTypeEnum2;
2890
+ })(ChannelIntegrationTypeEnum || {});
2855
2891
  var sharedConfig = {
2856
2892
  context: void 0,
2857
2893
  registry: void 0,
@@ -46033,6 +46069,20 @@ const sendTestCommunication = async (id2, params) => {
46033
46069
  );
46034
46070
  return response.data;
46035
46071
  };
46072
+ const resetCommunicationGroupToDefault = async (args) => {
46073
+ const { communicationGroupId, automationId, type } = args;
46074
+ const response = await baseRequest(
46075
+ `${COMMUNICATION_GROUP_PATH}/${communicationGroupId}/${automationId}/reset`,
46076
+ {
46077
+ method: "POST",
46078
+ body: JSON.stringify({ type })
46079
+ }
46080
+ );
46081
+ return response.data;
46082
+ };
46083
+ const communicationGroupQueryKeys = {
46084
+ all: ["communication-group"]
46085
+ };
46036
46086
  const useGetCommunicationGroup = (communicationGroupId) => {
46037
46087
  const query = useQuery({
46038
46088
  queryKey: ["communication-group", communicationGroupId],
@@ -46054,7 +46104,9 @@ const useUpdateCommunicationGroup = () => {
46054
46104
  params
46055
46105
  }) => updateCommunicationGroup(groupId, params),
46056
46106
  onSuccess: () => {
46057
- queryClient.invalidateQueries({ queryKey: ["communication-group"] });
46107
+ queryClient.invalidateQueries({
46108
+ queryKey: communicationGroupQueryKeys.all
46109
+ });
46058
46110
  }
46059
46111
  });
46060
46112
  return {
@@ -63065,8 +63117,13 @@ const stripoScriptId = "UiEditorScript";
63065
63117
  const initStripo = (options) => {
63066
63118
  return new Promise((resolve, reject) => {
63067
63119
  const initStripoEditor = () => {
63120
+ let forceRecreate = true;
63121
+ if (options.updatedFromDefault) {
63122
+ forceRecreate = false;
63123
+ }
63068
63124
  if (window.UIEditor) {
63069
63125
  window.UIEditor.initEditor(options.container, {
63126
+ forceRecreate,
63070
63127
  metadata: {
63071
63128
  emailId: options.emailId
63072
63129
  },
@@ -63226,7 +63283,8 @@ const StripoWrapper = ({
63226
63283
  css: template2.css || "",
63227
63284
  container: containerRef.current,
63228
63285
  businessId: editorData.businessId,
63229
- mergeFields: mergeFieldsResponse.mergeFields || []
63286
+ mergeFields: mergeFieldsResponse.mergeFields || [],
63287
+ updatedFromDefault: template2.updatedFromDefault
63230
63288
  }).catch((error2) => {
63231
63289
  console.error("Failed to initialize Stripo:", error2);
63232
63290
  });
@@ -64316,6 +64374,103 @@ const SMSPreview = ({ mergeFieldsResponse, smsChannelSenders }) => {
64316
64374
  ] })
64317
64375
  ] });
64318
64376
  };
64377
+ var CommunicationGroupTypeEnum = /* @__PURE__ */ ((CommunicationGroupTypeEnum2) => {
64378
+ CommunicationGroupTypeEnum2["CUSTOM"] = "custom";
64379
+ CommunicationGroupTypeEnum2["MANAGED"] = "managed";
64380
+ return CommunicationGroupTypeEnum2;
64381
+ })(CommunicationGroupTypeEnum || {});
64382
+ var BuiltInActionIds = /* @__PURE__ */ ((BuiltInActionIds2) => {
64383
+ BuiltInActionIds2["EditAudience"] = "edit-audience";
64384
+ BuiltInActionIds2["EditTime"] = "edit-time";
64385
+ return BuiltInActionIds2;
64386
+ })(BuiltInActionIds || {});
64387
+ const TitleAndResetButton = ({ title: title2, type }) => {
64388
+ const communicationGroup = useCommunicationGroup();
64389
+ const automation2 = useAutomation();
64390
+ const { toast: toast2 } = useToast();
64391
+ const queryClient = useQueryClient();
64392
+ const [loading2, setLoading2] = useState(false);
64393
+ const [showConfirm, setShowConfirmDialog] = useState(false);
64394
+ const showResetButton = (
64395
+ /**
64396
+ * If we haven't loaded in the communication group yet, don't show the reset button
64397
+ */
64398
+ !communicationGroup ? false : (
64399
+ /**
64400
+ * First see if this is a managed communication group
64401
+ */
64402
+ communicationGroup.type === CommunicationGroupTypeEnum.MANAGED && /**
64403
+ * If its SMS, check if the text_message_body was updated from the default template
64404
+ */
64405
+ (type === "sms" ? communicationGroup.updatedFromDefault?.text_message_body : (
64406
+ /**
64407
+ * If its email, check if the email_text_body or email_html_body was updated from the default template
64408
+ */
64409
+ communicationGroup.updatedFromDefault?.email_text_body || communicationGroup.updatedFromDefault?.email_html_body
64410
+ ))
64411
+ )
64412
+ );
64413
+ const resetCommunicationGroup = async () => {
64414
+ if (!communicationGroup || !automation2) {
64415
+ toast2({
64416
+ title: "Error resetting communication",
64417
+ description: "Please contact your administrator",
64418
+ variant: "destructive"
64419
+ });
64420
+ return;
64421
+ }
64422
+ setLoading2(true);
64423
+ await resetCommunicationGroupToDefault({
64424
+ communicationGroupId: communicationGroup.id,
64425
+ automationId: automation2.id,
64426
+ type
64427
+ });
64428
+ queryClient.invalidateQueries({
64429
+ queryKey: communicationGroupQueryKeys.all
64430
+ });
64431
+ toast2({
64432
+ title: "Communication reset to default!"
64433
+ });
64434
+ setLoading2(false);
64435
+ setShowConfirmDialog(false);
64436
+ };
64437
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
64438
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
64439
+ /* @__PURE__ */ jsx("h4", { className: "text-xl text-primary", children: title2 }),
64440
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: showResetButton && /* @__PURE__ */ jsx(Fragment, { children: loading2 ? /* @__PURE__ */ jsx(BasicLoader, {}) : /* @__PURE__ */ jsx(
64441
+ Button$1,
64442
+ {
64443
+ variant: "outline",
64444
+ size: "sm",
64445
+ onClick: () => setShowConfirmDialog(true),
64446
+ children: "Reset To Default"
64447
+ }
64448
+ ) }) })
64449
+ ] }),
64450
+ /* @__PURE__ */ jsx(Dialog, { open: showConfirm, onOpenChange: setShowConfirmDialog, children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-[425px]", children: [
64451
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
64452
+ /* @__PURE__ */ jsx(DialogTitle, { className: "text-xl font-semibold", children: "Reset to Default" }),
64453
+ /* @__PURE__ */ jsxs(DialogDescription, { className: "text-base text-muted-foreground", children: [
64454
+ "Are you sure you want to reset this",
64455
+ " ",
64456
+ type === "email" ? "email" : "SMS",
64457
+ " template to its default state? This action cannot be undone."
64458
+ ] })
64459
+ ] }),
64460
+ /* @__PURE__ */ jsxs(DialogFooter, { className: "flex flex-row justify-end gap-3 mt-6", children: [
64461
+ /* @__PURE__ */ jsx(
64462
+ Button$1,
64463
+ {
64464
+ variant: "outline",
64465
+ onClick: () => setShowConfirmDialog(false),
64466
+ children: "Cancel"
64467
+ }
64468
+ ),
64469
+ /* @__PURE__ */ jsx(Button$1, { variant: "destructive", onClick: resetCommunicationGroup, children: "Reset to Default" })
64470
+ ] })
64471
+ ] }) })
64472
+ ] });
64473
+ };
64319
64474
  const EditCampaignContent = ({
64320
64475
  getExtraMergeFields
64321
64476
  }) => {
@@ -64427,12 +64582,6 @@ const EditCampaignContent = ({
64427
64582
  }
64428
64583
  });
64429
64584
  } else {
64430
- if (communicationGroup?.id && communicationGroup.extraMergeFields !== null) {
64431
- updateCommunicationGroup2({
64432
- groupId: communicationGroup?.id,
64433
- params: { extraMergeFields: null }
64434
- });
64435
- }
64436
64585
  setMergeFieldsResponse(getMergeFields$1);
64437
64586
  }
64438
64587
  }, [
@@ -64491,7 +64640,7 @@ const EditCampaignContent = ({
64491
64640
  className: "bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative",
64492
64641
  ref: emailContainerRef,
64493
64642
  children: [
64494
- /* @__PURE__ */ jsx("h4", { className: "text-xl text-primary", children: "Email Campaign" }),
64643
+ /* @__PURE__ */ jsx(TitleAndResetButton, { title: "Email Campaign", type: "email" }),
64495
64644
  /* @__PURE__ */ jsx(
64496
64645
  EmailPreview,
64497
64646
  {
@@ -64503,7 +64652,7 @@ const EditCampaignContent = ({
64503
64652
  }
64504
64653
  ),
64505
64654
  selectedChannels.includes("sms") && /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-2xl w-full border border-gray-200 p-6 space-y-4 relative", children: [
64506
- /* @__PURE__ */ jsx("h4", { className: "text-xl text-primary", children: "SMS Campaign" }),
64655
+ /* @__PURE__ */ jsx(TitleAndResetButton, { title: "SMS Campaign", type: "sms" }),
64507
64656
  /* @__PURE__ */ jsx(
64508
64657
  SMSPreview,
64509
64658
  {
@@ -81840,13 +81989,13 @@ const useAutomationStatusToggle = (id2) => {
81840
81989
  }, [isUpdateSuccess, updateError, toast2]);
81841
81990
  return { toggleStatus };
81842
81991
  };
81843
- const DEFAULT_PAGE_SIZE$2 = 10;
81992
+ const DEFAULT_PAGE_SIZE$3 = 10;
81844
81993
  function AutomationList() {
81845
81994
  const { toast: toast2 } = useToast();
81846
81995
  const [updatingId, setUpdatingId] = useState(null);
81847
81996
  const { toggleStatus } = useAutomationStatusToggle(updatingId || "");
81848
81997
  const navigate = useNavigate();
81849
- const [pageSizeForQuery, setPageSizeForQuery] = useState(DEFAULT_PAGE_SIZE$2);
81998
+ const [pageSizeForQuery, setPageSizeForQuery] = useState(DEFAULT_PAGE_SIZE$3);
81850
81999
  const [cursorForQuery, setCursorForQuery] = useState(
81851
82000
  void 0
81852
82001
  );
@@ -81936,14 +82085,14 @@ function AutomationList() {
81936
82085
  }
81937
82086
  ) }) });
81938
82087
  }
81939
- const DEFAULT_PAGE_SIZE$1 = 10;
82088
+ const DEFAULT_PAGE_SIZE$2 = 10;
81940
82089
  function BroadcastList() {
81941
82090
  const { toast: toast2 } = useToast();
81942
82091
  const [createDialogOpen, setCreateDialogOpen] = useState(false);
81943
82092
  const [updatingId, setUpdatingId] = useState(null);
81944
82093
  const { toggleStatus } = useAutomationStatusToggle(updatingId || "");
81945
82094
  const navigate = useNavigate();
81946
- const [pageSizeForQuery, setPageSizeForQuery] = useState(DEFAULT_PAGE_SIZE$1);
82095
+ const [pageSizeForQuery, setPageSizeForQuery] = useState(DEFAULT_PAGE_SIZE$2);
81947
82096
  const [cursorForQuery, setCursorForQuery] = useState(
81948
82097
  void 0
81949
82098
  );
@@ -81997,7 +82146,7 @@ function BroadcastList() {
81997
82146
  );
81998
82147
  const resetListPagination = () => {
81999
82148
  setCursorForQuery(void 0);
82000
- setPageSizeForQuery(DEFAULT_PAGE_SIZE$1);
82149
+ setPageSizeForQuery(DEFAULT_PAGE_SIZE$2);
82001
82150
  setSearchQuery("");
82002
82151
  };
82003
82152
  const onDialogClose = (result) => {
@@ -82065,12 +82214,12 @@ function BroadcastList() {
82065
82214
  )
82066
82215
  ] });
82067
82216
  }
82068
- const DEFAULT_PAGE_SIZE = 10;
82217
+ const DEFAULT_PAGE_SIZE$1 = 10;
82069
82218
  function SegmentList() {
82070
82219
  const { toast: toast2 } = useToast();
82071
82220
  const [createDialogOpen, setCreateDialogOpen] = useState(false);
82072
82221
  const [selectedSegment, setSelectedSegment] = useState(null);
82073
- const [pageSizeForQuery, setPageSizeForQuery] = useState(DEFAULT_PAGE_SIZE);
82222
+ const [pageSizeForQuery, setPageSizeForQuery] = useState(DEFAULT_PAGE_SIZE$1);
82074
82223
  const [cursorForQuery, setCursorForQuery] = useState(
82075
82224
  void 0
82076
82225
  );
@@ -82124,7 +82273,7 @@ function SegmentList() {
82124
82273
  );
82125
82274
  const resetListPagination = () => {
82126
82275
  setCursorForQuery(void 0);
82127
- setPageSizeForQuery(DEFAULT_PAGE_SIZE);
82276
+ setPageSizeForQuery(DEFAULT_PAGE_SIZE$1);
82128
82277
  setSearchQuery("");
82129
82278
  };
82130
82279
  const onDialogClose = (result) => {
@@ -82754,14 +82903,59 @@ const AutomationsEditorStatsTab = ({ hideSms, hideSales }) => {
82754
82903
  }
82755
82904
  ) });
82756
82905
  };
82757
- const AutomationsEditorRecipientsTab = () => {
82906
+ const DEFAULT_PAGE_SIZE = 10;
82907
+ const AutomationRecipientsTable = () => {
82758
82908
  const automation2 = useAutomation();
82909
+ const [pageSizeForQuery, setPageSizeForQuery] = useState(DEFAULT_PAGE_SIZE);
82910
+ const [cursorForQuery, setCursorForQuery] = useState(
82911
+ void 0
82912
+ );
82913
+ const [searchQuery, setSearchQuery] = useState("");
82759
82914
  const {
82760
- recipients,
82915
+ sentCommunications,
82761
82916
  isLoading: isLoadingRecipients,
82917
+ isFetching,
82918
+ isPlaceholderData,
82762
82919
  fetchError
82763
- } = useGetBusinessAutomationRecipients(automation2?.id ?? "");
82920
+ } = useGetBusinessAutomationSentCommunications({
82921
+ automationId: automation2?.id ?? "",
82922
+ cursor: cursorForQuery,
82923
+ limit: pageSizeForQuery,
82924
+ search: searchQuery || void 0
82925
+ });
82926
+ const handleQueryParametersChange = useCallback(
82927
+ (params) => {
82928
+ setCursorForQuery(params.cursor);
82929
+ setPageSizeForQuery(params.pageSize);
82930
+ },
82931
+ []
82932
+ );
82764
82933
  const columns = [
82934
+ {
82935
+ accessorKey: "communicationsSent",
82936
+ id: "lastCommunication",
82937
+ header: "Updated At",
82938
+ cell: ({ row }) => {
82939
+ const communications = row.original.communicationsSent || [];
82940
+ if (communications.length === 0) {
82941
+ return /* @__PURE__ */ jsx("span", { className: "text-gray-400", children: "None" });
82942
+ }
82943
+ const latestCommunication = communications.reduce(
82944
+ (latest, current) => {
82945
+ if (!latest || !latest.updatedAt) return current;
82946
+ if (!current.updatedAt) return latest;
82947
+ return new Date(current.updatedAt) > new Date(latest.updatedAt) ? current : latest;
82948
+ }
82949
+ );
82950
+ if (!latestCommunication?.updatedAt) {
82951
+ return /* @__PURE__ */ jsx("span", { className: "text-gray-400", children: "Not available" });
82952
+ }
82953
+ return /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx("span", { className: "text-sm text-gray-600", children: format$1(
82954
+ new Date(latestCommunication.updatedAt),
82955
+ "MMM d, yyyy h:mm a"
82956
+ ) }) });
82957
+ }
82958
+ },
82765
82959
  {
82766
82960
  accessorFn: (row) => `${row.firstName || ""} ${row.lastName || ""}`.trim(),
82767
82961
  id: "name",
@@ -82782,9 +82976,73 @@ const AutomationsEditorRecipientsTab = () => {
82782
82976
  accessorKey: "phone",
82783
82977
  header: "Phone",
82784
82978
  cell: ({ row }) => row.original.phone || /* @__PURE__ */ jsx("span", { className: "text-gray-400", children: "Not provided" })
82979
+ },
82980
+ {
82981
+ accessorKey: "communicationsSent",
82982
+ id: "communicationsSent",
82983
+ header: "Communications Sent",
82984
+ cell: ({ row }) => {
82985
+ const communications = row.original.communicationsSent || [];
82986
+ const emailCommunications = communications.filter(
82987
+ (c2) => c2.type === ChannelIntegrationTypeEnum.EMAIL
82988
+ );
82989
+ const smsCommunications = communications.filter(
82990
+ (c2) => c2.type === ChannelIntegrationTypeEnum.SMS
82991
+ );
82992
+ const hasEmail = emailCommunications.length > 0;
82993
+ const hasSms = smsCommunications.length > 0;
82994
+ const emailDelivered = emailCommunications.some((c2) => c2.delivered);
82995
+ const smsDelivered = smsCommunications.some((c2) => c2.delivered);
82996
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
82997
+ hasEmail && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
82998
+ /* @__PURE__ */ jsxs("div", { className: "relative", children: [
82999
+ /* @__PURE__ */ jsx(
83000
+ IconDefinitions.EmailIcon,
83001
+ {
83002
+ className: `h-4 w-4 ${emailDelivered ? "text-green-500" : "text-gray-400"}`
83003
+ }
83004
+ ),
83005
+ emailDelivered && /* @__PURE__ */ jsx("div", { className: "absolute -right-1 -top-1 h-2 w-2 rounded-full bg-green-500 ring-1 ring-white" })
83006
+ ] }),
83007
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
83008
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Email" }),
83009
+ /* @__PURE__ */ jsx(
83010
+ "span",
83011
+ {
83012
+ className: `text-xs ${emailDelivered ? "text-green-600" : "text-gray-500"}`,
83013
+ children: emailDelivered ? "Delivered" : "Pending"
83014
+ }
83015
+ )
83016
+ ] })
83017
+ ] }),
83018
+ hasEmail && hasSms && /* @__PURE__ */ jsx("div", { className: "h-8 w-px bg-gray-200" }),
83019
+ hasSms && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
83020
+ /* @__PURE__ */ jsxs("div", { className: "relative", children: [
83021
+ /* @__PURE__ */ jsx(
83022
+ IconDefinitions.SmsIcon,
83023
+ {
83024
+ className: `h-4 w-4 ${smsDelivered ? "text-green-500" : "text-gray-400"}`
83025
+ }
83026
+ ),
83027
+ smsDelivered && /* @__PURE__ */ jsx("div", { className: "absolute -right-1 -top-1 h-2 w-2 rounded-full bg-green-500 ring-1 ring-white" })
83028
+ ] }),
83029
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
83030
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "SMS" }),
83031
+ /* @__PURE__ */ jsx(
83032
+ "span",
83033
+ {
83034
+ className: `text-xs ${smsDelivered ? "text-green-600" : "text-gray-500"}`,
83035
+ children: smsDelivered ? "Delivered" : "Pending"
83036
+ }
83037
+ )
83038
+ ] })
83039
+ ] }),
83040
+ !hasEmail && !hasSms && /* @__PURE__ */ jsx("span", { className: "text-sm text-gray-400", children: "None" })
83041
+ ] });
83042
+ }
82785
83043
  }
82786
83044
  ];
82787
- if (!automation2 || isLoadingRecipients || !recipients) {
83045
+ if (!automation2 || isLoadingRecipients || !sentCommunications) {
82788
83046
  return /* @__PURE__ */ jsx(BasicLoader, { text: ["Fetching Recipients", "Finishing up"] });
82789
83047
  }
82790
83048
  if (fetchError) {
@@ -82793,31 +83051,56 @@ const AutomationsEditorRecipientsTab = () => {
82793
83051
  fetchError.message
82794
83052
  ] });
82795
83053
  }
82796
- if (!recipients || recipients.recipients.length === 0) {
83054
+ if (!sentCommunications || !searchQuery && sentCommunications.results.length === 0) {
82797
83055
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center p-8 text-center", children: [
82798
83056
  /* @__PURE__ */ jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsx(IconDefinitions.UserIcon, { className: "h-12 w-12 text-gray-400" }) }),
82799
- /* @__PURE__ */ jsx("h3", { className: "mb-2 text-lg font-semibold text-gray-700", children: "No Recipients Found" }),
83057
+ /* @__PURE__ */ jsx("h3", { className: "mb-2 text-lg font-semibold text-gray-700", children: "No Communications Sent Yet" }),
82800
83058
  /* @__PURE__ */ jsxs("p", { className: "text-gray-500", children: [
82801
- "This ",
82802
- t$1("engage:automation"),
82803
- " currently has no assigned recipients. Please update the include or exclude",
83059
+ "This",
82804
83060
  " ",
82805
- t$1("engage:segment", { count: 2 }),
82806
- " to add recipients."
83061
+ automation2.triggerType === AutomationTriggerType.ONE_TIME ? t$1("engage:one_time") : t$1("engage:automation"),
83062
+ " ",
83063
+ "hasn't sent any communications yet. Please check back later to see recipient details once communications have been sent."
82807
83064
  ] })
82808
83065
  ] });
82809
83066
  }
82810
83067
  return /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(
82811
83068
  TanstackTable,
82812
83069
  {
82813
- data: recipients.recipients,
83070
+ data: sentCommunications.results,
82814
83071
  columns,
82815
- paginationMode: "standard",
82816
- initialPageSize: 10,
82817
- isLoading: isLoadingRecipients
83072
+ paginationMode: "cursor",
83073
+ initialPageSize: pageSizeForQuery,
83074
+ isLoading: isLoadingRecipients && !isPlaceholderData,
83075
+ cursorPaginationQueryResult: {
83076
+ nextCursor: sentCommunications.pagination.cursor,
83077
+ isLoading: isLoadingRecipients,
83078
+ isFetching,
83079
+ isPlaceholderData
83080
+ },
83081
+ onQueryParametersChange: handleQueryParametersChange,
83082
+ searchValue: searchQuery,
83083
+ onSearchChange: setSearchQuery
82818
83084
  }
82819
83085
  ) });
82820
83086
  };
83087
+ const AutomationsEditorRecipientsTab = () => {
83088
+ const automation2 = useAutomation();
83089
+ if (automation2?.triggerType === AutomationTriggerType.ONE_TIME && automation2?.status === AutomationStatus.DRAFT) {
83090
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center p-8 text-center", children: [
83091
+ /* @__PURE__ */ jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsx(IconDefinitions.UserIcon, { className: "h-12 w-12 text-gray-400" }) }),
83092
+ /* @__PURE__ */ jsx("h3", { className: "mb-2 text-lg font-semibold text-gray-700", children: "No Recipients Available Yet" }),
83093
+ /* @__PURE__ */ jsxs("p", { className: "text-gray-500", children: [
83094
+ "Recipients will be available once this",
83095
+ " ",
83096
+ automation2.triggerType === AutomationTriggerType.ONE_TIME ? t$1("engage:one_time") : t$1("engage:automation"),
83097
+ " ",
83098
+ "has completed running. Please check back after the automation has finished."
83099
+ ] })
83100
+ ] });
83101
+ }
83102
+ return /* @__PURE__ */ jsx(AutomationRecipientsTable, {});
83103
+ };
82821
83104
  const PanelGroupContext = createContext$1(null);
82822
83105
  PanelGroupContext.displayName = "PanelGroupContext";
82823
83106
  const DATA_ATTRIBUTES = {
@@ -84965,11 +85248,6 @@ const sortAutomationSteps = (args) => {
84965
85248
  }
84966
85249
  return sortedSteps;
84967
85250
  };
84968
- var BuiltInActionIds = /* @__PURE__ */ ((BuiltInActionIds2) => {
84969
- BuiltInActionIds2["EditAudience"] = "edit-audience";
84970
- BuiltInActionIds2["EditTime"] = "edit-time";
84971
- return BuiltInActionIds2;
84972
- })(BuiltInActionIds || {});
84973
85251
  const AutomationFlowLabel = ({ copyText }) => {
84974
85252
  return /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: copyText });
84975
85253
  };
@@ -85512,7 +85790,8 @@ const AutomationFlowMain = () => {
85512
85790
  },
85513
85791
  actionData.actionData.actionMetadata?.currentActionId ?? index2
85514
85792
  )),
85515
- automation2.triggerType === AutomationTriggerType.ONE_TIME && /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3", children: /* @__PURE__ */ jsx(AutomationEditorTrigger, {}) }, "one-time-trigger")
85793
+ automation2.triggerType === AutomationTriggerType.ONE_TIME && // We need this otherwise we can get a 'Encountered two children with the same key, ``.'
85794
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3", children: /* @__PURE__ */ jsx(AutomationEditorTrigger, {}) }, "one-time-trigger")
85516
85795
  ] }) })
85517
85796
  ] });
85518
85797
  };