@embedreach/components 0.3.43 → 0.3.44

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.
@@ -22729,6 +22729,8 @@ const generateReputationResponsesData = ({
22729
22729
  startDate,
22730
22730
  endDate,
22731
22731
  locationIds,
22732
+ reviewSource,
22733
+ sentiment,
22732
22734
  cursor,
22733
22735
  limit,
22734
22736
  searchTerm
@@ -22759,6 +22761,21 @@ const generateReputationResponsesData = ({
22759
22761
  (response) => response.locationId && locationIds.includes(response.locationId)
22760
22762
  );
22761
22763
  }
22764
+ if (reviewSource) {
22765
+ const sources = reviewSource.split(",").filter(Boolean);
22766
+ filteredResponses = filteredResponses.filter(
22767
+ (response) => sources.includes(response.reviewSource)
22768
+ );
22769
+ }
22770
+ if (sentiment) {
22771
+ filteredResponses = filteredResponses.filter((response) => {
22772
+ const calculatedSentiment = calculateSentiment(
22773
+ response.reviewSource,
22774
+ response.rating
22775
+ );
22776
+ return calculatedSentiment === sentiment;
22777
+ });
22778
+ }
22762
22779
  if (searchTerm && searchTerm.length >= 3) {
22763
22780
  const searchLower = searchTerm.toLowerCase();
22764
22781
  filteredResponses = filteredResponses.filter((response) => {
@@ -22792,6 +22809,18 @@ const generateReputationResponsesData = ({
22792
22809
  total: filteredResponses.length
22793
22810
  };
22794
22811
  };
22812
+ function calculateSentiment(reviewSource, rating) {
22813
+ if (reviewSource === "google_business_profile") {
22814
+ if (rating >= 4) return "positive";
22815
+ if (rating === 3) return "neutral";
22816
+ return "negative";
22817
+ } else if (reviewSource === "internal_feedback") {
22818
+ if (rating >= 9) return "positive";
22819
+ if (rating >= 7) return "neutral";
22820
+ return "negative";
22821
+ }
22822
+ return "neutral";
22823
+ }
22795
22824
  function generateResponsePool(platformConfig, platformData, startDate, endDate, totalCount) {
22796
22825
  const responses = [];
22797
22826
  const partnerLocations = platformData.reputationData?.partnerLocations || [];
@@ -24200,6 +24229,8 @@ const reputationHandlers = [
24200
24229
  const startDate = url.searchParams.get("start_date");
24201
24230
  const endDate = url.searchParams.get("end_date");
24202
24231
  const locationIds = url.searchParams.getAll("location_ids");
24232
+ const reviewSource = url.searchParams.get("review_source");
24233
+ const sentiment = url.searchParams.get("sentiment");
24203
24234
  const cursor = url.searchParams.get("cursor");
24204
24235
  const limit = parseInt(url.searchParams.get("limit") || "25", 10);
24205
24236
  const searchTerm = url.searchParams.get("search_term");
@@ -24219,11 +24250,14 @@ const reputationHandlers = [
24219
24250
  error2
24220
24251
  );
24221
24252
  }
24253
+ const reviewSourceParam = reviewSource || null;
24222
24254
  const responsesData = generateReputationResponsesData({
24223
24255
  platformData,
24224
24256
  startDate,
24225
24257
  endDate,
24226
24258
  locationIds,
24259
+ reviewSource: reviewSourceParam,
24260
+ sentiment: sentiment || null,
24227
24261
  cursor,
24228
24262
  limit,
24229
24263
  searchTerm
package/dist/index.d.ts CHANGED
@@ -51,12 +51,14 @@ declare interface CreateAutomationModalProps {
51
51
  *
52
52
  * @param args.estimatedEmailRecipients - The estimated number of email recipients
53
53
  * @param args.estimatedSmsRecipients - The estimated number of sms recipients
54
+ * @param args.scheduleSendAt - The scheduled send time as an ISO date string, or null if not set
54
55
  *
55
56
  * @returns true if the automation should be scheduled, string otherwise that will be displayed to the user in a toast notification
56
57
  */
57
58
  onBeforeSchedule?: (args: {
58
59
  estimatedEmailRecipients: number;
59
60
  estimatedSmsRecipients: number;
61
+ scheduleSendAt: string | null;
60
62
  }) => Promise<true | string>;
61
63
  /**
62
64
  * Optional text and hyperlink to display for
@@ -477,12 +479,14 @@ export declare type ViewAutomationProps = {
477
479
  *
478
480
  * @param args.estimatedEmailRecipients - The estimated number of email recipients
479
481
  * @param args.estimatedSmsRecipients - The estimated number of sms recipients
482
+ * @param args.scheduleSendAt - The scheduled send time as an ISO date string, or null if not set
480
483
  *
481
484
  * @returns true if the automation should be scheduled, string otherwise that will be displayed to the user in a toast notification
482
485
  */
483
486
  onBeforeSchedule?: (args: {
484
487
  estimatedEmailRecipients: number;
485
488
  estimatedSmsRecipients: number;
489
+ scheduleSendAt: string | null;
486
490
  }) => Promise<true | string>;
487
491
  /**
488
492
  * Optional boolean to hide features