@embedreach/components 0.1.97 → 0.1.99

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.
@@ -12870,7 +12870,8 @@ const toastVariants = cva(
12870
12870
  {
12871
12871
  variants: {
12872
12872
  variant: {
12873
- default: "border bg-background text-foreground",
12873
+ default: "border bg-muted text-muted-foreground",
12874
+ success: "border bg-green-100 text-foreground",
12874
12875
  destructive: "destructive group border-destructive bg-destructive text-destructive-foreground"
12875
12876
  }
12876
12877
  },
@@ -13049,7 +13050,7 @@ const authListeners = [
13049
13050
  }
13050
13051
  }
13051
13052
  ];
13052
- const { Provider: Provider$3 } = createDataContext(
13053
+ const { Context: Context$2, Provider: Provider$3 } = createDataContext(
13053
13054
  authReducer,
13054
13055
  {
13055
13056
  handleReauth
@@ -13619,6 +13620,42 @@ const ThemeInitializer = ({ initialTheme, children: children2 }) => {
13619
13620
  const Provider$2 = ({ initialTheme, children: children2 }) => {
13620
13621
  return /* @__PURE__ */ jsx(BaseProvider, { children: /* @__PURE__ */ jsx(ThemeInitializer, { initialTheme, children: children2 }) });
13621
13622
  };
13623
+ const useAuthContext = (reauthCallback) => {
13624
+ const context2 = useContext$1(Context$2);
13625
+ const hasTriedReauth = useRef(false);
13626
+ const callbackRef = useRef(reauthCallback);
13627
+ useEffect(() => {
13628
+ callbackRef.current = reauthCallback;
13629
+ }, [reauthCallback]);
13630
+ if (context2 === void 0) {
13631
+ throw new Error("useAuthContext must be used within an AuthProvider");
13632
+ }
13633
+ const { state, handleReauth: handleReauth2 } = context2;
13634
+ useEffect(() => {
13635
+ if (!state.isAuthenticated && state.reauthing && !hasTriedReauth.current) {
13636
+ hasTriedReauth.current = true;
13637
+ if (callbackRef.current) {
13638
+ handleReauth2(callbackRef.current);
13639
+ } else {
13640
+ console.error("No reauth callback available");
13641
+ }
13642
+ const timeout = setTimeout(() => {
13643
+ hasTriedReauth.current = false;
13644
+ }, 1e4);
13645
+ return () => clearTimeout(timeout);
13646
+ }
13647
+ }, [state.isAuthenticated, state.reauthing, handleReauth2]);
13648
+ useEffect(() => {
13649
+ if (state.isAuthenticated && hasTriedReauth.current) {
13650
+ hasTriedReauth.current = false;
13651
+ }
13652
+ }, [state.isAuthenticated]);
13653
+ return context2;
13654
+ };
13655
+ const AuthCallbackHandler = ({ reauthCallback }) => {
13656
+ useAuthContext(reauthCallback);
13657
+ return null;
13658
+ };
13622
13659
  const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
13623
13660
  const htmlEntities = {
13624
13661
  "&": "&",
@@ -35683,7 +35720,8 @@ const ReachProvider = ({
35683
35720
  language,
35684
35721
  children: children2,
35685
35722
  theme: theme2,
35686
- debug
35723
+ debug,
35724
+ callbacks
35687
35725
  }) => {
35688
35726
  const [queryClient] = React__default.useState(() => {
35689
35727
  if (authToken2) {
@@ -35727,6 +35765,12 @@ const ReachProvider = ({
35727
35765
  language,
35728
35766
  initialLanguage: language?.default,
35729
35767
  children: /* @__PURE__ */ jsx(Provider$2, { initialTheme: theme2, children: /* @__PURE__ */ jsxs(Provider$3, { children: [
35768
+ /* @__PURE__ */ jsx(
35769
+ AuthCallbackHandler,
35770
+ {
35771
+ reauthCallback: callbacks?.onReauthRequested
35772
+ }
35773
+ ),
35730
35774
  children2,
35731
35775
  /* @__PURE__ */ jsx(Toaster, {})
35732
35776
  ] }) })
@@ -64449,14 +64493,14 @@ function SegmentBuilder({
64449
64493
  {
64450
64494
  onSuccess: () => {
64451
64495
  toast2({
64452
- title: "Segment updated successfully"
64496
+ title: `${t("engage:segment")} updated successfully`
64453
64497
  });
64454
64498
  setOpen(false);
64455
- onSegmentUpdated?.(segment2.id);
64499
+ onSegmentUpdated?.(segmentId);
64456
64500
  },
64457
64501
  onError: () => {
64458
64502
  toast2({
64459
- title: "Error updating segment",
64503
+ title: `Error updating ${t("engage:segment")}`,
64460
64504
  description: "Please try again",
64461
64505
  variant: "destructive"
64462
64506
  });
@@ -64472,16 +64516,16 @@ function SegmentBuilder({
64472
64516
  conditions: segment2.conditions
64473
64517
  },
64474
64518
  {
64475
- onSuccess: () => {
64519
+ onSuccess: (data) => {
64476
64520
  toast2({
64477
- title: "Segment created successfully"
64521
+ title: `${t("engage:segment")} created successfully`
64478
64522
  });
64523
+ onSegmentUpdated?.(data?.id ?? false);
64479
64524
  setOpen(false);
64480
- onSegmentUpdated?.(segment2.id);
64481
64525
  },
64482
64526
  onError: () => {
64483
64527
  toast2({
64484
- title: "Error creating segment",
64528
+ title: `Error creating ${t("engage:segment")}`,
64485
64529
  description: "Please try again",
64486
64530
  variant: "destructive"
64487
64531
  });
@@ -64492,7 +64536,7 @@ function SegmentBuilder({
64492
64536
  }
64493
64537
  } catch (error22) {
64494
64538
  toast2({
64495
- title: "Error saving segment",
64539
+ title: `Error saving ${t("engage:segment")}`,
64496
64540
  description: "Please try again",
64497
64541
  variant: "destructive"
64498
64542
  });