@pushwoosh/smart-components-kit 1.0.45 → 1.0.47

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.
@@ -14,6 +14,7 @@ type ExportCsvBannerProps = {
14
14
  showLastExportLocalStorageKey?: string;
15
15
  lastTasksParams?: GetLastTasksRequest;
16
16
  isKeepPageOpenWarning?: boolean;
17
+ onClose?: () => void;
17
18
  };
18
- export declare const ExportCsvBanner: ({ exportTask, updateExportTask, showLastExportLocalStorageKey, lastTasksParams, isKeepPageOpenWarning, }: ExportCsvBannerProps) => React.JSX.Element | null;
19
+ export declare const ExportCsvBanner: ({ exportTask, updateExportTask, showLastExportLocalStorageKey, lastTasksParams, isKeepPageOpenWarning, onClose, }: ExportCsvBannerProps) => React.JSX.Element | null;
19
20
  export {};
@@ -1,4 +1,4 @@
1
- import React, { useEffect } from 'react';
1
+ import React, { useCallback, useEffect } from 'react';
2
2
  import { ExportResult, ProgressBar, Button } from '@pushwoosh/dumb-components';
3
3
  import { Color, ShapeRadius } from '@pushwoosh/kit-constants';
4
4
  import { Horizontal } from '@pushwoosh/kit-helpers';
@@ -11,7 +11,8 @@ export const ExportCsvBanner = ({
11
11
  updateExportTask,
12
12
  showLastExportLocalStorageKey,
13
13
  lastTasksParams,
14
- isKeepPageOpenWarning
14
+ isKeepPageOpenWarning,
15
+ onClose
15
16
  }) => {
16
17
  const {
17
18
  getLastTasks,
@@ -78,6 +79,10 @@ export const ExportCsvBanner = ({
78
79
  });
79
80
  }
80
81
  }, [getLastTasks, isHidden, lastTasksParams, updateExportTask]);
82
+ const handleClose = useCallback(() => {
83
+ hide();
84
+ onClose === null || onClose === void 0 || onClose();
85
+ }, [hide, onClose]);
81
86
  if (!exportTask || isHidden) return null;
82
87
  const {
83
88
  filename,
@@ -95,7 +100,7 @@ export const ExportCsvBanner = ({
95
100
  type: "success",
96
101
  title: "Exporting complete",
97
102
  subtitle: `${resultSubTitle} ${filename}`,
98
- handleClose: hide,
103
+ handleClose: handleClose,
99
104
  rightSlot: React.createElement("a", {
100
105
  href: `/api/v2/statistics/exportMessagesStatistics/download/${filename}`,
101
106
  download: filename
@@ -126,6 +131,6 @@ export const ExportCsvBanner = ({
126
131
  size: "medium",
127
132
  view: "filled"
128
133
  }),
129
- handleClose: hide
134
+ handleClose: handleClose
130
135
  }));
131
136
  };
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
- import { useParams, Link as ReactLink } from 'react-router-dom';
2
+ import { useParams } from 'react-router-dom';
3
3
  import { Link, Spinner } from '@pushwoosh/dumb-components';
4
4
  import { Color, PlatformsIcons, PlatformsLabels, Tag } from '@pushwoosh/kit-constants';
5
5
  import { Horizontal, useAsync, Vertical } from '@pushwoosh/kit-helpers';
6
- import { OpenIcon, PlatformLogoIcon } from '@pushwoosh/kit-icons';
7
- import { H4, Text } from '@pushwoosh/kit-typography';
6
+ import { PlatformLogoIcon } from '@pushwoosh/kit-icons';
7
+ import { Text } from '@pushwoosh/kit-typography';
8
8
  import { LinkRow, ClickActionSection } from './styles';
9
9
  import { useSPAContext } from '../../../context';
10
10
  import { getSafariUrl } from '../../helpers';
@@ -30,12 +30,12 @@ export const OpenActionsSummary = ({
30
30
  }) : Promise.resolve(undefined), [rpcGateway, applicationCode]);
31
31
  const hasCustomPlatformsDeeplink = Object.keys(platformsDeeplinkUrls).length > 0;
32
32
  const safariUrl = getSafariUrl((applicationData === null || applicationData === void 0 || (_applicationData$valu = applicationData.value) === null || _applicationData$valu === void 0 ? void 0 : _applicationData$valu.application) || null, safariUrlArgs ?? '');
33
- const renderInfoBlock = (device, action, url = null) => React.createElement(Vertical, null, React.createElement("span", null, "For", ' ', React.createElement("strong", null, device), ' ', "subscribers:", ' ', React.createElement("strong", null, action)), url && React.createElement(LinkRow, null, React.createElement(Link, {
33
+ const renderInfoBlock = (device, action, url = null, urlText) => React.createElement(Vertical, null, React.createElement("span", null, "For", ' ', React.createElement("strong", null, device), ' ', "subscribers:", ' ', React.createElement("strong", null, action)), url && React.createElement(LinkRow, null, React.createElement(Link, {
34
34
  as: Tag.A,
35
35
  rel: "noopener noreferrer",
36
36
  target: "_blank",
37
37
  href: url
38
- }, url)));
38
+ }, urlText ?? url)));
39
39
  const renderPlatformDeepLink = (platformKey, url, label = 'deep link') => {
40
40
  const isEnumKey = typeof platformKey === 'number';
41
41
  const icon = isEnumKey ? PlatformsIcons[platformKey] : null;
@@ -56,28 +56,19 @@ export const OpenActionsSummary = ({
56
56
  "$uppercase": true
57
57
  }, labelText, ' ', label)), React.createElement(LinkRow, null, url));
58
58
  };
59
- const renderRichmedia = richmedia => {
60
- if (richmedia.url) {
61
- return React.createElement(Vertical, null, React.createElement(H4, null, "Show in-app banner"), React.createElement(ClickActionSection, null, React.createElement(LinkRow, null, richmedia.url)));
62
- } else if (richmedia.code) {
63
- return React.createElement(Horizontal, {
64
- "$gap": 4,
65
- "$justifyContent": "start",
66
- "$alignItems": "center"
67
- }, React.createElement(H4, null, "Show in-app banner:"), React.createElement(Text, null, richmedia.code), React.createElement(ReactLink, {
68
- to: `/applications/${applicationCode}/rich-media/${richmedia.code}/edit`,
69
- target: "_blank"
70
- }, React.createElement(OpenIcon, {
71
- color: Color.SOFT,
72
- size: "small",
73
- view: "lined"
74
- })));
59
+ const getRichmediaLink = ({
60
+ url,
61
+ code,
62
+ createdType = 'BUILDER'
63
+ }) => {
64
+ if (code) {
65
+ return createdType === 'BUILDER' ? `/applications/${applicationCode}/rich-media/${code}/edit` : `/applications/${applicationCode}/richMedia/edit/${Date.now()}/${code}`;
75
66
  }
76
- return null;
67
+ return url;
77
68
  };
78
69
  return React.createElement(Vertical, {
79
70
  "$gap": 8
80
- }, openActions ? React.createElement(React.Fragment, null, hasCustomPlatformsDeeplink && renderInfoBlock('mobile', 'follow the Deep link'), Object.entries(platformsDeeplinkUrls).map(([platformKey, url]) => renderPlatformDeepLink(+platformKey, url)), allPlatformsDeeplinkUrl && hasCustomPlatformsDeeplink && renderPlatformDeepLink('Other platforms', allPlatformsDeeplinkUrl), allPlatformsDeeplinkUrl && !hasCustomPlatformsDeeplink && renderInfoBlock('mobile', 'follow the Deep link', allPlatformsDeeplinkUrl), !allPlatformsDeeplinkUrl && !hasCustomPlatformsDeeplink && renderInfoBlock('mobile', 'open home page in application'), webPageUrl && renderInfoBlock('web', 'open URL in browser', webPageUrl), webPageUrl && safariUrl && renderInfoBlock('Safari', 'open URL in Safari browser', safariUrl), !webPageUrl && renderInfoBlock('web', 'open home page in browser'), showRichmedia && renderRichmedia(showRichmedia)) : React.createElement(Spinner, {
71
+ }, openActions ? React.createElement(React.Fragment, null, showRichmedia && renderInfoBlock('mobile', 'open in-app banner', getRichmediaLink(showRichmedia), showRichmedia.name || showRichmedia.code), !showRichmedia && hasCustomPlatformsDeeplink && renderInfoBlock('mobile', 'follow the Deep link'), !showRichmedia && Object.entries(platformsDeeplinkUrls).map(([platformKey, url]) => renderPlatformDeepLink(+platformKey, url)), !showRichmedia && allPlatformsDeeplinkUrl && hasCustomPlatformsDeeplink && renderPlatformDeepLink('Other platforms', allPlatformsDeeplinkUrl), !showRichmedia && allPlatformsDeeplinkUrl && !hasCustomPlatformsDeeplink && renderInfoBlock('mobile', 'follow the Deep link', allPlatformsDeeplinkUrl), !showRichmedia && !allPlatformsDeeplinkUrl && !hasCustomPlatformsDeeplink && renderInfoBlock('mobile', 'open home page in application'), webPageUrl && renderInfoBlock('web', 'open URL in browser', webPageUrl), webPageUrl && safariUrl && renderInfoBlock('Safari', 'open URL in Safari browser', safariUrl), !webPageUrl && renderInfoBlock('web', 'open home page in browser')) : React.createElement(Spinner, {
81
72
  color: Color.MAIN,
82
73
  size: "medium"
83
74
  }));
@@ -1,12 +1,16 @@
1
1
  import { type AllPlatforms } from '@pushwoosh/kit-constants';
2
+ import { type RichMedia_CreatedType } from '@pushwoosh/rpc-v2-http-api-data/rich_medias';
3
+ export type RichmediaOpenAction = {
4
+ url?: string;
5
+ code?: string;
6
+ name?: string;
7
+ createdType?: RichMedia_CreatedType;
8
+ };
2
9
  export type ParsedOpenActions = {
3
10
  platformsDeeplinkUrls: Partial<Record<AllPlatforms, string>>;
4
11
  defaultDeeplinkUrl: string | null;
5
12
  webPageUrl: string | null;
6
- showRichmedia: {
7
- url?: string;
8
- code?: string;
9
- } | null;
13
+ showRichmedia: RichmediaOpenAction | null;
10
14
  safariUrlArgs: string | null;
11
15
  };
12
16
  export type OpenActionsSummaryProps = {
package/package.json CHANGED
@@ -49,5 +49,5 @@
49
49
  "engines": {
50
50
  "node": ">= 18"
51
51
  },
52
- "version": "1.0.45"
52
+ "version": "1.0.47"
53
53
  }