@pushwoosh/smart-components-kit 1.0.46 → 1.0.48

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.
@@ -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 = {
@@ -1,6 +1,7 @@
1
1
  import { type History } from 'history';
2
2
  import type { GrpcClient, HttpClient, RpcClient } from '@pushwoosh/http-client';
3
3
  import type { API as RpcGatewayJourneyAPI } from '@pushwoosh/rpc-gateway-journey-data';
4
+ import type { API as RpcGatewayPaymentAPI } from '@pushwoosh/rpc-gateway-payment-data';
4
5
  import type { API as RpcGatewayAPI } from '@pushwoosh/rpc-v2-http-api-data';
5
6
  import type { SessionStore } from '@pushwoosh/session-store';
6
7
  export type SPAContextType = {
@@ -16,6 +17,7 @@ export type SPAContextType = {
16
17
  readonly sessionStore: SessionStore;
17
18
  readonly rpcGateway: RpcGatewayAPI;
18
19
  readonly rpcGatewayJourney: RpcGatewayJourneyAPI;
20
+ readonly rpcGatewayPayment: RpcGatewayPaymentAPI;
19
21
  readonly language: string;
20
22
  readonly helpers: {
21
23
  getApiOrigin: (name: string) => string;
package/package.json CHANGED
@@ -41,6 +41,7 @@
41
41
  "peerDependencies": {
42
42
  "@pushwoosh/http-client": "^2.5.0",
43
43
  "@pushwoosh/rpc-gateway-journey-data": "^0.26.206",
44
+ "@pushwoosh/rpc-gateway-payment-data": "^0.2.135",
44
45
  "@pushwoosh/rpc-v2-http-api-data": "^0.1.566",
45
46
  "@pushwoosh/session-store": "^2.5.0",
46
47
  "react": "^16.14.0 || ^18.0.0",
@@ -49,5 +50,5 @@
49
50
  "engines": {
50
51
  "node": ">= 18"
51
52
  },
52
- "version": "1.0.46"
53
+ "version": "1.0.48"
53
54
  }