@pushwoosh/dumb-components 1.1.30 → 1.1.31
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.
- package/Chip/Chip.d.ts +1 -0
- package/Chip/Chip.js +2 -0
- package/Chip/Chip.types.d.ts +1 -0
- package/Chip/styles.d.ts +1 -0
- package/Chip/styles.js +16 -4
- package/FrequencyCapping/FrequencyCappingEdit.d.ts +3 -0
- package/FrequencyCapping/FrequencyCappingEdit.js +90 -0
- package/FrequencyCapping/FrequencyCappingReadonly.d.ts +3 -0
- package/FrequencyCapping/FrequencyCappingReadonly.js +35 -0
- package/FrequencyCapping/components/Condition/index.d.ts +8 -0
- package/FrequencyCapping/components/Condition/index.js +29 -0
- package/FrequencyCapping/components/Condition/styles.d.ts +1 -0
- package/FrequencyCapping/components/Condition/styles.js +5 -0
- package/FrequencyCapping/components/Description/index.d.ts +10 -0
- package/FrequencyCapping/components/Description/index.js +27 -0
- package/FrequencyCapping/components/Settings/index.d.ts +8 -0
- package/FrequencyCapping/components/Settings/index.js +34 -0
- package/FrequencyCapping/helpers/getCappingOption.d.ts +6 -0
- package/FrequencyCapping/helpers/getCappingOption.js +20 -0
- package/FrequencyCapping/helpers/getReadonlyCappingHelpers.d.ts +7 -0
- package/FrequencyCapping/helpers/getReadonlyCappingHelpers.js +79 -0
- package/FrequencyCapping/index.d.ts +3 -0
- package/FrequencyCapping/index.js +2 -0
- package/FrequencyCapping/styles.d.ts +113 -0
- package/FrequencyCapping/styles.js +15 -0
- package/FrequencyCapping/types.d.ts +32 -0
- package/FrequencyCapping/types.js +6 -0
- package/SendRate/SendRateEdit.d.ts +14 -0
- package/SendRate/SendRateEdit.js +77 -0
- package/SendRate/SendRateReadonly.d.ts +11 -0
- package/SendRate/SendRateReadonly.js +35 -0
- package/SendRate/components/Condition/index.d.ts +7 -0
- package/SendRate/components/Condition/index.js +12 -0
- package/SendRate/components/Condition/styles.d.ts +1 -0
- package/SendRate/components/Condition/styles.js +5 -0
- package/SendRate/components/Description/index.d.ts +10 -0
- package/SendRate/components/Description/index.js +25 -0
- package/SendRate/components/Settings/index.d.ts +9 -0
- package/SendRate/components/Settings/index.js +27 -0
- package/SendRate/helpers/getReadonlySendRateHelpers.d.ts +7 -0
- package/SendRate/helpers/getReadonlySendRateHelpers.js +78 -0
- package/SendRate/helpers/getSendRateOptions.d.ts +2 -0
- package/SendRate/helpers/getSendRateOptions.js +10 -0
- package/SendRate/index.d.ts +2 -0
- package/SendRate/index.js +2 -0
- package/SendRate/styles.d.ts +113 -0
- package/SendRate/styles.js +15 -0
- package/SendRate/types.d.ts +9 -0
- package/SendRate/types.js +1 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +1 -1
package/Chip/Chip.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare const Chip: React.ForwardRefExoticComponent<{
|
|
|
3
3
|
$variant?: import("./Chip.types").ChipVariant;
|
|
4
4
|
$selected?: boolean;
|
|
5
5
|
$onClose?: React.HTMLAttributes<HTMLDivElement>["onClick"];
|
|
6
|
+
$readOnly?: boolean;
|
|
6
7
|
as?: string;
|
|
7
8
|
} & {
|
|
8
9
|
children?: React.ReactNode | undefined;
|
package/Chip/Chip.js
CHANGED
|
@@ -4,6 +4,7 @@ import { ChipStyled } from './styles';
|
|
|
4
4
|
export const Chip = forwardRef(({
|
|
5
5
|
$variant = 'primary',
|
|
6
6
|
$selected,
|
|
7
|
+
$readOnly,
|
|
7
8
|
$onClose,
|
|
8
9
|
children,
|
|
9
10
|
as,
|
|
@@ -14,6 +15,7 @@ export const Chip = forwardRef(({
|
|
|
14
15
|
"$variant": $variant,
|
|
15
16
|
"$selected": $selected,
|
|
16
17
|
"$closeable": !!$onClose,
|
|
18
|
+
"$readOnly": $readOnly,
|
|
17
19
|
as: as,
|
|
18
20
|
...rest
|
|
19
21
|
}, children, $onClose && React.createElement(CloseIcon, {
|
package/Chip/Chip.types.d.ts
CHANGED
package/Chip/styles.d.ts
CHANGED
package/Chip/styles.js
CHANGED
|
@@ -8,8 +8,20 @@ export const ChipStyled = styled.div.withConfig({
|
|
|
8
8
|
$closeable
|
|
9
9
|
}) => $closeable ? '4px' : '8px', ({
|
|
10
10
|
$variant,
|
|
11
|
-
$selected
|
|
12
|
-
|
|
11
|
+
$selected,
|
|
12
|
+
$readOnly
|
|
13
|
+
}) => {
|
|
14
|
+
if ($readOnly) {
|
|
15
|
+
return Color.MAIN;
|
|
16
|
+
}
|
|
17
|
+
return $selected ? Color.CLEAR : variants[$variant].color;
|
|
18
|
+
}, ({
|
|
13
19
|
$variant,
|
|
14
|
-
$selected
|
|
15
|
-
|
|
20
|
+
$selected,
|
|
21
|
+
$readOnly
|
|
22
|
+
}) => {
|
|
23
|
+
if ($readOnly) {
|
|
24
|
+
return Color.SOFT_LIGHT;
|
|
25
|
+
}
|
|
26
|
+
return $selected ? Color.MAIN : variants[$variant].background;
|
|
27
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type CappingBase, type FrequencyCappingEditProps } from './types';
|
|
3
|
+
export declare function FrequencyCappingEdit<T extends CappingBase>({ capping, globalCapping, onChange, applicationCode }: FrequencyCappingEditProps<T>): React.JSX.Element;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { OpenIcon } from '@pushwoosh/kit-icons';
|
|
5
|
+
import { Description } from './components/Description';
|
|
6
|
+
import { EditCappingSettings } from './components/Settings';
|
|
7
|
+
import { getCappingOption, getCappingOptions } from './helpers/getCappingOption';
|
|
8
|
+
import { CappingTypes } from './types';
|
|
9
|
+
import { FieldBox } from '../FieldBox';
|
|
10
|
+
import { Link } from '../Link';
|
|
11
|
+
import { Select } from '../Select';
|
|
12
|
+
import { Container, LinkWrapper } from './styles';
|
|
13
|
+
export function FrequencyCappingEdit({
|
|
14
|
+
capping,
|
|
15
|
+
globalCapping,
|
|
16
|
+
onChange,
|
|
17
|
+
applicationCode
|
|
18
|
+
}) {
|
|
19
|
+
const {
|
|
20
|
+
enabled,
|
|
21
|
+
messages,
|
|
22
|
+
days,
|
|
23
|
+
ignoreGlobalCapping
|
|
24
|
+
} = capping;
|
|
25
|
+
const cappingOption = getCappingOption(enabled, ignoreGlobalCapping);
|
|
26
|
+
const isGlobalCappingDisabled = globalCapping.count === 0 && globalCapping.days === 0;
|
|
27
|
+
const globalCappingLinkText = isGlobalCappingDisabled ? 'Set up' : 'Settings';
|
|
28
|
+
const cappingOptions = getCappingOptions(isGlobalCappingDisabled);
|
|
29
|
+
const onChangeFrequencyCapping = React.useCallback(value => {
|
|
30
|
+
if (value === CappingTypes.IGNORE) {
|
|
31
|
+
onChange({
|
|
32
|
+
...capping,
|
|
33
|
+
enabled: false,
|
|
34
|
+
ignoreGlobalCapping: true
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (value === CappingTypes.CUSTOM) {
|
|
38
|
+
onChange({
|
|
39
|
+
...capping,
|
|
40
|
+
enabled: true,
|
|
41
|
+
ignoreGlobalCapping: false,
|
|
42
|
+
messages: 5,
|
|
43
|
+
days: 1
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (value === CappingTypes.GLOBAL) {
|
|
47
|
+
onChange({
|
|
48
|
+
...capping,
|
|
49
|
+
enabled: false,
|
|
50
|
+
ignoreGlobalCapping: false
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}, [capping, onChange]);
|
|
54
|
+
const onSettingsChange = React.useCallback((messages, days) => {
|
|
55
|
+
onChange({
|
|
56
|
+
...capping,
|
|
57
|
+
messages,
|
|
58
|
+
days
|
|
59
|
+
});
|
|
60
|
+
}, [capping, onChange]);
|
|
61
|
+
return React.createElement(Container, {
|
|
62
|
+
"$padding": 16,
|
|
63
|
+
"$bgColor": Color.SOFT_LIGHT,
|
|
64
|
+
"$borderRadius": 8
|
|
65
|
+
}, React.createElement(Vertical, {
|
|
66
|
+
"$gap": 12
|
|
67
|
+
}, React.createElement(FieldBox, {
|
|
68
|
+
title: "Frequency capping"
|
|
69
|
+
}, React.createElement(Select, {
|
|
70
|
+
name: "cappingOption",
|
|
71
|
+
options: cappingOptions,
|
|
72
|
+
value: cappingOptions.find(option => option.value === cappingOption),
|
|
73
|
+
onChange: newValue => onChangeFrequencyCapping(newValue.value)
|
|
74
|
+
})), React.createElement(Description, {
|
|
75
|
+
cappingOption: cappingOption,
|
|
76
|
+
messages: globalCapping.count,
|
|
77
|
+
days: globalCapping.days
|
|
78
|
+
}, cappingOption === CappingTypes.GLOBAL && React.createElement(Link, {
|
|
79
|
+
href: `/applications/${applicationCode}/message-delivery-settings?tab=capping`,
|
|
80
|
+
title: globalCappingLinkText
|
|
81
|
+
}, React.createElement(LinkWrapper, null, globalCappingLinkText, React.createElement(OpenIcon, {
|
|
82
|
+
size: "small",
|
|
83
|
+
view: "lined",
|
|
84
|
+
as: "span"
|
|
85
|
+
})))), cappingOption === CappingTypes.CUSTOM && React.createElement(EditCappingSettings, {
|
|
86
|
+
messages: messages,
|
|
87
|
+
days: days,
|
|
88
|
+
onChange: onSettingsChange
|
|
89
|
+
})));
|
|
90
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type CappingBase, type FrequencyCappingReadonlyProps } from './types';
|
|
3
|
+
export declare function FrequencyCappingReadonly<T extends CappingBase>({ capping, globalCapping, applicationCode }: FrequencyCappingReadonlyProps<T>): React.JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
3
|
+
import { OpenIcon } from '@pushwoosh/kit-icons';
|
|
4
|
+
import { Link } from '../Link';
|
|
5
|
+
import { getCappingOption } from './helpers/getCappingOption';
|
|
6
|
+
import { getReadonlyCappingIcon, getReadonlyCappingLabel } from './helpers/getReadonlyCappingHelpers';
|
|
7
|
+
import { CappingTypes } from './types';
|
|
8
|
+
export function FrequencyCappingReadonly({
|
|
9
|
+
capping,
|
|
10
|
+
globalCapping,
|
|
11
|
+
applicationCode
|
|
12
|
+
}) {
|
|
13
|
+
const cappingOption = getCappingOption(capping === null || capping === void 0 ? void 0 : capping.enabled, capping === null || capping === void 0 ? void 0 : capping.ignoreGlobalCapping);
|
|
14
|
+
const isGlobalCappingDisabled = globalCapping.count === 0 && globalCapping.days === 0;
|
|
15
|
+
const globalCappingLinkText = isGlobalCappingDisabled ? 'Set up' : 'Settings';
|
|
16
|
+
const label = getReadonlyCappingLabel(cappingOption, isGlobalCappingDisabled, capping, globalCapping);
|
|
17
|
+
const checkIcon = getReadonlyCappingIcon(cappingOption, isGlobalCappingDisabled);
|
|
18
|
+
return React.createElement(Vertical, {
|
|
19
|
+
"$gap": 24
|
|
20
|
+
}, React.createElement(Horizontal, {
|
|
21
|
+
"$gap": 8,
|
|
22
|
+
"$justifyContent": "start",
|
|
23
|
+
"$alignItems": "center"
|
|
24
|
+
}, checkIcon, label, cappingOption === CappingTypes.GLOBAL && React.createElement(Link, {
|
|
25
|
+
href: `/applications/${applicationCode}/message-delivery-settings?tab=capping`,
|
|
26
|
+
title: globalCappingLinkText
|
|
27
|
+
}, React.createElement(Horizontal, {
|
|
28
|
+
"$gap": 4,
|
|
29
|
+
"$justifyContent": "start",
|
|
30
|
+
"$alignItems": "center"
|
|
31
|
+
}, globalCappingLinkText, React.createElement(OpenIcon, {
|
|
32
|
+
size: "small",
|
|
33
|
+
view: "lined"
|
|
34
|
+
})))));
|
|
35
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { HelpRoundIcon } from '@pushwoosh/kit-icons';
|
|
4
|
+
import { ChipWithinTextContainer } from './styles';
|
|
5
|
+
import { Chip } from '../../../Chip';
|
|
6
|
+
import { Tooltip } from '../../../Tooltip';
|
|
7
|
+
export function Condition({
|
|
8
|
+
messages,
|
|
9
|
+
days,
|
|
10
|
+
tooltip
|
|
11
|
+
}) {
|
|
12
|
+
return React.createElement(ChipWithinTextContainer, null, tooltip ? React.createElement(Tooltip, {
|
|
13
|
+
content: tooltip,
|
|
14
|
+
position: "top-middle"
|
|
15
|
+
}, React.createElement(Chip, {
|
|
16
|
+
"$variant": "primary",
|
|
17
|
+
"$readOnly": true,
|
|
18
|
+
as: "span"
|
|
19
|
+
}, `${messages} messages per ${days} ${days > 1 ? 'days' : 'day'}`, React.createElement(HelpRoundIcon, {
|
|
20
|
+
as: "span",
|
|
21
|
+
size: "small",
|
|
22
|
+
view: "lined",
|
|
23
|
+
color: Color.PHANTOM
|
|
24
|
+
}))) : React.createElement(Chip, {
|
|
25
|
+
"$variant": "primary",
|
|
26
|
+
"$readOnly": true,
|
|
27
|
+
as: "span"
|
|
28
|
+
}, `${messages} messages per ${days} ${days > 1 ? 'days' : 'day'}`));
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ChipWithinTextContainer: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import { CappingTypes } from '../../types';
|
|
3
|
+
type Props = {
|
|
4
|
+
cappingOption: CappingTypes;
|
|
5
|
+
messages: number;
|
|
6
|
+
days: number;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export declare function Description(props: Props): React.JSX.Element | undefined;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Paragraph } from '@pushwoosh/kit-typography';
|
|
3
|
+
import { CappingTypes } from '../../types';
|
|
4
|
+
import { Condition } from '../Condition';
|
|
5
|
+
export function Description(props) {
|
|
6
|
+
const {
|
|
7
|
+
cappingOption,
|
|
8
|
+
messages,
|
|
9
|
+
days,
|
|
10
|
+
children
|
|
11
|
+
} = props;
|
|
12
|
+
if (cappingOption === CappingTypes.GLOBAL) {
|
|
13
|
+
if (messages === 0 && days === 0) {
|
|
14
|
+
return React.createElement(Paragraph, null, "To ensure you don\u2019t overwhelm your subscribers with excessive communication, consider setting up Global frequency capping.", ' ', children);
|
|
15
|
+
}
|
|
16
|
+
return React.createElement(Paragraph, null, "Under the current setup, If the user receives more than", React.createElement(Condition, {
|
|
17
|
+
messages: messages,
|
|
18
|
+
days: days
|
|
19
|
+
}), ", this message will not be delivered, and the user will proceed to the next step.", ' ', children);
|
|
20
|
+
}
|
|
21
|
+
if (cappingOption === CappingTypes.CUSTOM) {
|
|
22
|
+
return React.createElement(Paragraph, null, "Instead of Global frequency capping, the limit of sent messages you set will be used. If the subscriber exceeds the limit of received messages, they will not receive this message and will proceed to the next step.", ' ', children);
|
|
23
|
+
}
|
|
24
|
+
if (cappingOption === CappingTypes.IGNORE) {
|
|
25
|
+
return React.createElement(Paragraph, null, "The user will receive this message regardless, even if they have exceeded the set message limits for the channel. Use with caution to avoid sending too many messages.", ' ', children);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
3
|
+
import { Paragraph } from '@pushwoosh/kit-typography';
|
|
4
|
+
import { NumberPicker } from '../../../NumberPicker';
|
|
5
|
+
export function EditCappingSettings(props) {
|
|
6
|
+
const {
|
|
7
|
+
messages,
|
|
8
|
+
days,
|
|
9
|
+
onChange
|
|
10
|
+
} = props;
|
|
11
|
+
const onMessagesChange = React.useCallback(value => {
|
|
12
|
+
onChange(value, days);
|
|
13
|
+
}, [days, onChange]);
|
|
14
|
+
const onDaysChange = React.useCallback(value => {
|
|
15
|
+
onChange(messages, value);
|
|
16
|
+
}, [messages, onChange]);
|
|
17
|
+
return React.createElement(Horizontal, {
|
|
18
|
+
"$gap": 12,
|
|
19
|
+
"$alignItems": "center",
|
|
20
|
+
style: {
|
|
21
|
+
gridTemplateColumns: '145px 70px 90px 70px 40px'
|
|
22
|
+
}
|
|
23
|
+
}, React.createElement(Paragraph, null, "Limit to a maximum of"), React.createElement(NumberPicker, {
|
|
24
|
+
onChange: value => onMessagesChange(value),
|
|
25
|
+
value: messages,
|
|
26
|
+
minValue: 1,
|
|
27
|
+
maxValue: 1000
|
|
28
|
+
}), React.createElement(Paragraph, null, "messages per"), React.createElement(NumberPicker, {
|
|
29
|
+
maxValue: 30,
|
|
30
|
+
minValue: 1,
|
|
31
|
+
onChange: value => onDaysChange(value),
|
|
32
|
+
value: days
|
|
33
|
+
}), React.createElement(Paragraph, null, "day(s)"));
|
|
34
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CappingTypes } from '../types';
|
|
2
|
+
export declare const getCappingOption: (enabled: boolean, ignoreGlobalCapping: boolean) => CappingTypes;
|
|
3
|
+
export declare const getCappingOptions: (isGlobalCappingDisabled: boolean) => {
|
|
4
|
+
value: CappingTypes;
|
|
5
|
+
label: string;
|
|
6
|
+
}[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CappingTypes } from '../types';
|
|
2
|
+
export const getCappingOption = (enabled, ignoreGlobalCapping) => {
|
|
3
|
+
if (enabled) {
|
|
4
|
+
return CappingTypes.CUSTOM;
|
|
5
|
+
}
|
|
6
|
+
if (ignoreGlobalCapping) {
|
|
7
|
+
return CappingTypes.IGNORE;
|
|
8
|
+
}
|
|
9
|
+
return CappingTypes.GLOBAL;
|
|
10
|
+
};
|
|
11
|
+
export const getCappingOptions = isGlobalCappingDisabled => [{
|
|
12
|
+
value: CappingTypes.GLOBAL,
|
|
13
|
+
label: `Use global frequency capping settings${isGlobalCappingDisabled ? ' (currently inactive)' : ''}`
|
|
14
|
+
}, {
|
|
15
|
+
value: CappingTypes.IGNORE,
|
|
16
|
+
label: 'Send messages without global frequency capping'
|
|
17
|
+
}, {
|
|
18
|
+
value: CappingTypes.CUSTOM,
|
|
19
|
+
label: 'Use custom frequency capping'
|
|
20
|
+
}];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type CappingBase, CappingTypes } from '../types';
|
|
3
|
+
export declare function getReadonlyCappingIcon(cappingOption: CappingTypes, isGlobalCappingDisabled: boolean): React.JSX.Element;
|
|
4
|
+
export declare function getReadonlyCappingLabel<T extends CappingBase>(cappingOption: CappingTypes, isGlobalCappingDisabled: boolean, capping: T, globalCapping: {
|
|
5
|
+
count: number;
|
|
6
|
+
days: number;
|
|
7
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { CheckRoundIcon, CloseRoundIcon, HelpRoundIcon } from '@pushwoosh/kit-icons';
|
|
5
|
+
import { Paragraph } from '@pushwoosh/kit-typography';
|
|
6
|
+
import { Tooltip } from '../../Tooltip';
|
|
7
|
+
import { Condition } from '../components/Condition';
|
|
8
|
+
import { IconWrapper } from '../styles';
|
|
9
|
+
import { CappingTypes } from '../types';
|
|
10
|
+
export function getReadonlyCappingIcon(cappingOption, isGlobalCappingDisabled) {
|
|
11
|
+
if (cappingOption === CappingTypes.GLOBAL && isGlobalCappingDisabled) {
|
|
12
|
+
return React.createElement(CloseRoundIcon, {
|
|
13
|
+
size: "small",
|
|
14
|
+
view: "filled",
|
|
15
|
+
color: Color.LOCKED
|
|
16
|
+
});
|
|
17
|
+
;
|
|
18
|
+
}
|
|
19
|
+
return React.createElement(CheckRoundIcon, {
|
|
20
|
+
size: "small",
|
|
21
|
+
view: "filled",
|
|
22
|
+
type: "fill",
|
|
23
|
+
color: Color.BRIGHT
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export function getReadonlyCappingLabel(cappingOption, isGlobalCappingDisabled, capping, globalCapping) {
|
|
27
|
+
const tooltip = getReadonlyTooltip(cappingOption, isGlobalCappingDisabled);
|
|
28
|
+
if (cappingOption === CappingTypes.CUSTOM) {
|
|
29
|
+
return React.createElement(Paragraph, null, "Custom frequency capping for this message:", React.createElement(Condition, {
|
|
30
|
+
messages: capping.messages,
|
|
31
|
+
days: capping.days,
|
|
32
|
+
tooltip: tooltip
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
if (cappingOption === CappingTypes.IGNORE) {
|
|
36
|
+
return React.createElement(Horizontal, {
|
|
37
|
+
"$alignItems": "center",
|
|
38
|
+
"$gap": 4,
|
|
39
|
+
"$justifyContent": "start"
|
|
40
|
+
}, "Send messages without global frequency capping", React.createElement(Tooltip, {
|
|
41
|
+
content: tooltip,
|
|
42
|
+
position: "top-middle"
|
|
43
|
+
}, React.createElement(IconWrapper, {
|
|
44
|
+
"$padding": "4px 0"
|
|
45
|
+
}, React.createElement(HelpRoundIcon, {
|
|
46
|
+
size: "small",
|
|
47
|
+
view: "lined"
|
|
48
|
+
}))));
|
|
49
|
+
}
|
|
50
|
+
return isGlobalCappingDisabled ? React.createElement(Horizontal, {
|
|
51
|
+
"$alignItems": "center",
|
|
52
|
+
"$gap": 4,
|
|
53
|
+
"$justifyContent": "start"
|
|
54
|
+
}, "Global frequency capping is not active for this channel", React.createElement(Tooltip, {
|
|
55
|
+
content: tooltip,
|
|
56
|
+
position: "top-middle"
|
|
57
|
+
}, React.createElement(IconWrapper, {
|
|
58
|
+
"$padding": "4px 0"
|
|
59
|
+
}, React.createElement(HelpRoundIcon, {
|
|
60
|
+
size: "small",
|
|
61
|
+
view: "lined"
|
|
62
|
+
})))) : React.createElement(Paragraph, null, "Global frequency capping:", React.createElement(Condition, {
|
|
63
|
+
messages: globalCapping.count,
|
|
64
|
+
days: globalCapping.days,
|
|
65
|
+
tooltip: tooltip
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
function getReadonlyTooltip(cappingOption, isGlobalCappingDisabled) {
|
|
69
|
+
if (cappingOption === CappingTypes.CUSTOM) {
|
|
70
|
+
return 'If the subscriber exceeds the limit of received messages, they will not receive this message and will proceed to the next step';
|
|
71
|
+
}
|
|
72
|
+
if (cappingOption === CappingTypes.IGNORE) {
|
|
73
|
+
return 'The user will receive this message regardless, even if they have exceeded the set limits for the channel';
|
|
74
|
+
}
|
|
75
|
+
if (isGlobalCappingDisabled) {
|
|
76
|
+
return 'Messages will be sent without global limits because capping is currently not active for this channel';
|
|
77
|
+
}
|
|
78
|
+
return 'If the subscriber exceeds the limit of received messages, they will not receive this message and will proceed to the next step';
|
|
79
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export declare const Container: import("styled-components").StyledComponent<"div", any, {
|
|
2
|
+
$alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
3
|
+
$alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
4
|
+
$bgColor?: string | undefined;
|
|
5
|
+
$border?: string | ({
|
|
6
|
+
top?: string | undefined;
|
|
7
|
+
right?: string | undefined;
|
|
8
|
+
bottom?: string | undefined;
|
|
9
|
+
left?: string | undefined;
|
|
10
|
+
} | {
|
|
11
|
+
horizontal: string;
|
|
12
|
+
top?: string | undefined;
|
|
13
|
+
bottom?: string | undefined;
|
|
14
|
+
} | {
|
|
15
|
+
vertical: string;
|
|
16
|
+
right?: string | undefined;
|
|
17
|
+
left?: string | undefined;
|
|
18
|
+
}) | undefined;
|
|
19
|
+
$borderRadius?: (string | number) | undefined;
|
|
20
|
+
$boxShadow?: string | undefined;
|
|
21
|
+
$gap?: (string | number) | undefined;
|
|
22
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
23
|
+
$justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
24
|
+
$justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
25
|
+
$margin?: (string | number) | ({
|
|
26
|
+
top?: (string | number) | undefined;
|
|
27
|
+
right?: (string | number) | undefined;
|
|
28
|
+
bottom?: (string | number) | undefined;
|
|
29
|
+
left?: (string | number) | undefined;
|
|
30
|
+
} | {
|
|
31
|
+
horizontal: string | number;
|
|
32
|
+
top?: (string | number) | undefined;
|
|
33
|
+
bottom?: (string | number) | undefined;
|
|
34
|
+
} | {
|
|
35
|
+
vertical: string | number;
|
|
36
|
+
right?: (string | number) | undefined;
|
|
37
|
+
left?: (string | number) | undefined;
|
|
38
|
+
}) | undefined;
|
|
39
|
+
$padding?: (string | number) | ({
|
|
40
|
+
top?: (string | number) | undefined;
|
|
41
|
+
right?: (string | number) | undefined;
|
|
42
|
+
bottom?: (string | number) | undefined;
|
|
43
|
+
left?: (string | number) | undefined;
|
|
44
|
+
} | {
|
|
45
|
+
horizontal: string | number;
|
|
46
|
+
top?: (string | number) | undefined;
|
|
47
|
+
bottom?: (string | number) | undefined;
|
|
48
|
+
} | {
|
|
49
|
+
vertical: string | number;
|
|
50
|
+
right?: (string | number) | undefined;
|
|
51
|
+
left?: (string | number) | undefined;
|
|
52
|
+
}) | undefined;
|
|
53
|
+
$placeItems?: "end" | "start" | "center" | "stretch" | undefined;
|
|
54
|
+
} & {
|
|
55
|
+
$gridAutoFlow: string;
|
|
56
|
+
}, "$gridAutoFlow">;
|
|
57
|
+
export declare const IconWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
58
|
+
$alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
59
|
+
$alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
60
|
+
$bgColor?: string | undefined;
|
|
61
|
+
$border?: string | ({
|
|
62
|
+
top?: string | undefined;
|
|
63
|
+
right?: string | undefined;
|
|
64
|
+
bottom?: string | undefined;
|
|
65
|
+
left?: string | undefined;
|
|
66
|
+
} | {
|
|
67
|
+
horizontal: string;
|
|
68
|
+
top?: string | undefined;
|
|
69
|
+
bottom?: string | undefined;
|
|
70
|
+
} | {
|
|
71
|
+
vertical: string;
|
|
72
|
+
right?: string | undefined;
|
|
73
|
+
left?: string | undefined;
|
|
74
|
+
}) | undefined;
|
|
75
|
+
$borderRadius?: (string | number) | undefined;
|
|
76
|
+
$boxShadow?: string | undefined;
|
|
77
|
+
$gap?: (string | number) | undefined;
|
|
78
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
79
|
+
$justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
80
|
+
$justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
81
|
+
$margin?: (string | number) | ({
|
|
82
|
+
top?: (string | number) | undefined;
|
|
83
|
+
right?: (string | number) | undefined;
|
|
84
|
+
bottom?: (string | number) | undefined;
|
|
85
|
+
left?: (string | number) | undefined;
|
|
86
|
+
} | {
|
|
87
|
+
horizontal: string | number;
|
|
88
|
+
top?: (string | number) | undefined;
|
|
89
|
+
bottom?: (string | number) | undefined;
|
|
90
|
+
} | {
|
|
91
|
+
vertical: string | number;
|
|
92
|
+
right?: (string | number) | undefined;
|
|
93
|
+
left?: (string | number) | undefined;
|
|
94
|
+
}) | undefined;
|
|
95
|
+
$padding?: (string | number) | ({
|
|
96
|
+
top?: (string | number) | undefined;
|
|
97
|
+
right?: (string | number) | undefined;
|
|
98
|
+
bottom?: (string | number) | undefined;
|
|
99
|
+
left?: (string | number) | undefined;
|
|
100
|
+
} | {
|
|
101
|
+
horizontal: string | number;
|
|
102
|
+
top?: (string | number) | undefined;
|
|
103
|
+
bottom?: (string | number) | undefined;
|
|
104
|
+
} | {
|
|
105
|
+
vertical: string | number;
|
|
106
|
+
right?: (string | number) | undefined;
|
|
107
|
+
left?: (string | number) | undefined;
|
|
108
|
+
}) | undefined;
|
|
109
|
+
$placeItems?: "end" | "start" | "center" | "stretch" | undefined;
|
|
110
|
+
} & {
|
|
111
|
+
$gridAutoFlow: string;
|
|
112
|
+
}, "$gridAutoFlow">;
|
|
113
|
+
export declare const LinkWrapper: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
export const Container = styled(Vertical).withConfig({
|
|
5
|
+
displayName: "Container",
|
|
6
|
+
componentId: "sc-1z3915-0"
|
|
7
|
+
})(["max-width:560px;"]);
|
|
8
|
+
export const IconWrapper = styled(Horizontal).withConfig({
|
|
9
|
+
displayName: "IconWrapper",
|
|
10
|
+
componentId: "sc-1z3915-1"
|
|
11
|
+
})(["color:", ";&:hover{color:", ";cursor:pointer;}"], Color.PHANTOM, Color.PRIMARY_HOVER);
|
|
12
|
+
export const LinkWrapper = styled.span.withConfig({
|
|
13
|
+
displayName: "LinkWrapper",
|
|
14
|
+
componentId: "sc-1z3915-2"
|
|
15
|
+
})(["display:inline-flex;gap:4px;align-items:center;justify-content:start;text-decoration:none;"]);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare enum CappingTypes {
|
|
2
|
+
GLOBAL = "global",
|
|
3
|
+
IGNORE = "ignore",
|
|
4
|
+
CUSTOM = "custom"
|
|
5
|
+
}
|
|
6
|
+
export type CappingOption = {
|
|
7
|
+
label: string;
|
|
8
|
+
value: CappingTypes;
|
|
9
|
+
};
|
|
10
|
+
export type CappingBase = {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
messages: number;
|
|
13
|
+
days: number;
|
|
14
|
+
ignoreGlobalCapping: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type FrequencyCappingEditProps<T extends CappingBase> = {
|
|
17
|
+
capping: T;
|
|
18
|
+
globalCapping: {
|
|
19
|
+
count: number;
|
|
20
|
+
days: number;
|
|
21
|
+
};
|
|
22
|
+
onChange: (newCappingState: T) => void;
|
|
23
|
+
applicationCode: string;
|
|
24
|
+
};
|
|
25
|
+
export type FrequencyCappingReadonlyProps<T extends CappingBase> = {
|
|
26
|
+
capping: T;
|
|
27
|
+
globalCapping: {
|
|
28
|
+
count: number;
|
|
29
|
+
days: number;
|
|
30
|
+
};
|
|
31
|
+
applicationCode: string;
|
|
32
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type SendRateBase } from './types';
|
|
3
|
+
export type SendRateEditProps<T extends SendRateBase> = {
|
|
4
|
+
sendRate: T;
|
|
5
|
+
globalSendRate: {
|
|
6
|
+
count: number;
|
|
7
|
+
seconds: number;
|
|
8
|
+
};
|
|
9
|
+
onChange: (newSendRateState: T) => void;
|
|
10
|
+
applicationCode: string;
|
|
11
|
+
minValue: number;
|
|
12
|
+
maxValue: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function SendRateEdit<T extends SendRateBase>({ sendRate, globalSendRate, onChange, applicationCode, minValue, maxValue }: SendRateEditProps<T>): React.JSX.Element;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { OpenIcon } from '@pushwoosh/kit-icons';
|
|
5
|
+
import { Description } from './components/Description';
|
|
6
|
+
import { EditSendRateSettings } from './components/Settings';
|
|
7
|
+
import { getSendRateOptions } from './helpers/getSendRateOptions';
|
|
8
|
+
import { FieldBox } from '../FieldBox';
|
|
9
|
+
import { Link } from '../Link';
|
|
10
|
+
import { Select } from '../Select';
|
|
11
|
+
import { Container, LinkWrapper } from './styles';
|
|
12
|
+
export function SendRateEdit({
|
|
13
|
+
sendRate,
|
|
14
|
+
globalSendRate,
|
|
15
|
+
onChange,
|
|
16
|
+
applicationCode,
|
|
17
|
+
minValue,
|
|
18
|
+
maxValue
|
|
19
|
+
}) {
|
|
20
|
+
const {
|
|
21
|
+
sendRate: count,
|
|
22
|
+
policy
|
|
23
|
+
} = sendRate;
|
|
24
|
+
const isGlobalSendRateDisabled = globalSendRate.count === 0 && globalSendRate.count === 0;
|
|
25
|
+
const globalSendRateLinkText = isGlobalSendRateDisabled ? 'Set up' : 'Settings';
|
|
26
|
+
const sendRateOptions = getSendRateOptions(isGlobalSendRateDisabled);
|
|
27
|
+
const onChangeSendRate = React.useCallback(value => {
|
|
28
|
+
if (value === 'CUSTOM') {
|
|
29
|
+
onChange({
|
|
30
|
+
...sendRate,
|
|
31
|
+
policy: value,
|
|
32
|
+
sendRate: minValue
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
onChange({
|
|
36
|
+
...sendRate,
|
|
37
|
+
policy: value
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}, [onChange, sendRate, minValue]);
|
|
41
|
+
const onSettingsChange = React.useCallback(count => {
|
|
42
|
+
onChange({
|
|
43
|
+
...sendRate,
|
|
44
|
+
sendRate: count
|
|
45
|
+
});
|
|
46
|
+
}, [sendRate, onChange]);
|
|
47
|
+
return React.createElement(Container, {
|
|
48
|
+
"$padding": 16,
|
|
49
|
+
"$bgColor": Color.SOFT_LIGHT,
|
|
50
|
+
"$borderRadius": 8
|
|
51
|
+
}, React.createElement(Vertical, {
|
|
52
|
+
"$gap": 12
|
|
53
|
+
}, React.createElement(FieldBox, {
|
|
54
|
+
title: "Send rate"
|
|
55
|
+
}, React.createElement(Select, {
|
|
56
|
+
name: "sendRateOption",
|
|
57
|
+
options: sendRateOptions,
|
|
58
|
+
value: sendRateOptions.find(option => option.value === policy),
|
|
59
|
+
onChange: newValue => onChangeSendRate(newValue.value)
|
|
60
|
+
})), React.createElement(Description, {
|
|
61
|
+
sendRateOption: policy,
|
|
62
|
+
messages: globalSendRate.count,
|
|
63
|
+
seconds: globalSendRate.seconds
|
|
64
|
+
}, policy === 'GLOBAL' && React.createElement(Link, {
|
|
65
|
+
href: `/applications/${applicationCode}/message-delivery-settings?tab=sendRate`,
|
|
66
|
+
title: globalSendRateLinkText
|
|
67
|
+
}, React.createElement(LinkWrapper, null, globalSendRateLinkText, React.createElement(OpenIcon, {
|
|
68
|
+
size: "small",
|
|
69
|
+
view: "lined",
|
|
70
|
+
as: "span"
|
|
71
|
+
})))), policy === 'CUSTOM' && React.createElement(EditSendRateSettings, {
|
|
72
|
+
messages: count,
|
|
73
|
+
onChange: onSettingsChange,
|
|
74
|
+
minValue: minValue,
|
|
75
|
+
maxValue: maxValue
|
|
76
|
+
})));
|
|
77
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type SendRateBase } from './types';
|
|
3
|
+
export type SendRateReadonlyProps<T extends SendRateBase> = {
|
|
4
|
+
sendRate: T;
|
|
5
|
+
globalSendRate: {
|
|
6
|
+
count: number;
|
|
7
|
+
seconds: number;
|
|
8
|
+
};
|
|
9
|
+
applicationCode: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function SendRateReadonly<T extends SendRateBase>({ sendRate, globalSendRate, applicationCode }: SendRateReadonlyProps<T>): React.JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
3
|
+
import { OpenIcon } from '@pushwoosh/kit-icons';
|
|
4
|
+
import { Link } from '../Link';
|
|
5
|
+
import { getReadonlySendRateIcon, getReadonlySendRateLabel } from './helpers/getReadonlySendRateHelpers';
|
|
6
|
+
export function SendRateReadonly({
|
|
7
|
+
sendRate,
|
|
8
|
+
globalSendRate,
|
|
9
|
+
applicationCode
|
|
10
|
+
}) {
|
|
11
|
+
const {
|
|
12
|
+
policy
|
|
13
|
+
} = sendRate;
|
|
14
|
+
const isGlobalSendRateDisabled = globalSendRate.count === 0 && globalSendRate.seconds === 0;
|
|
15
|
+
const globalSendRateLinkText = isGlobalSendRateDisabled ? 'Set up' : 'Settings';
|
|
16
|
+
const label = getReadonlySendRateLabel(sendRate, isGlobalSendRateDisabled, globalSendRate);
|
|
17
|
+
const checkIcon = getReadonlySendRateIcon(policy, isGlobalSendRateDisabled);
|
|
18
|
+
return React.createElement(Vertical, {
|
|
19
|
+
"$gap": 24
|
|
20
|
+
}, React.createElement(Horizontal, {
|
|
21
|
+
"$gap": 8,
|
|
22
|
+
"$justifyContent": "start",
|
|
23
|
+
"$alignItems": "center"
|
|
24
|
+
}, checkIcon, label, policy === 'GLOBAL' && React.createElement(Link, {
|
|
25
|
+
href: `/applications/${applicationCode}/message-delivery-settings?tab=sendRate`,
|
|
26
|
+
title: globalSendRateLinkText
|
|
27
|
+
}, React.createElement(Horizontal, {
|
|
28
|
+
"$gap": 4,
|
|
29
|
+
"$justifyContent": "start",
|
|
30
|
+
"$alignItems": "center"
|
|
31
|
+
}, globalSendRateLinkText, React.createElement(OpenIcon, {
|
|
32
|
+
size: "small",
|
|
33
|
+
view: "lined"
|
|
34
|
+
})))));
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ChipWithinTextContainer } from './styles';
|
|
3
|
+
import { Chip } from '../../../Chip';
|
|
4
|
+
export function Condition({
|
|
5
|
+
messages
|
|
6
|
+
}) {
|
|
7
|
+
return React.createElement(ChipWithinTextContainer, null, React.createElement(Chip, {
|
|
8
|
+
"$variant": "primary",
|
|
9
|
+
"$readOnly": true,
|
|
10
|
+
as: "span"
|
|
11
|
+
}, `${messages} messages per 1 sec`));
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ChipWithinTextContainer: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import { type SendRatePolicy } from '../../types';
|
|
3
|
+
type DescriptionProps = {
|
|
4
|
+
sendRateOption: SendRatePolicy;
|
|
5
|
+
messages: number;
|
|
6
|
+
seconds: number;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export declare function Description(props: DescriptionProps): React.JSX.Element | undefined;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Paragraph } from '@pushwoosh/kit-typography';
|
|
3
|
+
import { Condition } from '../Condition';
|
|
4
|
+
export function Description(props) {
|
|
5
|
+
const {
|
|
6
|
+
sendRateOption,
|
|
7
|
+
messages,
|
|
8
|
+
seconds,
|
|
9
|
+
children
|
|
10
|
+
} = props;
|
|
11
|
+
if (sendRateOption === 'GLOBAL') {
|
|
12
|
+
if (messages === 0 && seconds === 0) {
|
|
13
|
+
return React.createElement(Paragraph, null, "To ensure you don\u2019t overload your systems or backend during high-volume campaigns, consider setting up Global send rate control.", ' ', children);
|
|
14
|
+
}
|
|
15
|
+
return React.createElement(Paragraph, null, "This message will use the Global send rate limit of", React.createElement(Condition, {
|
|
16
|
+
messages: messages
|
|
17
|
+
}), "to help reduce backend load.", ' ', children);
|
|
18
|
+
}
|
|
19
|
+
if (sendRateOption === 'CUSTOM') {
|
|
20
|
+
return React.createElement(Paragraph, null, "Instead of using the Global send rate, a custom delivery speed will be applied. Messages will be sent at the rate defined below.", ' ', children);
|
|
21
|
+
}
|
|
22
|
+
if (sendRateOption === 'IGNORE') {
|
|
23
|
+
return React.createElement(Paragraph, null, "This message will be sent as fast as possible, regardless of any Global send rate limits. Use with caution to avoid overloading your backend or creating delivery spikes.", ' ', children);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
3
|
+
import { Paragraph } from '@pushwoosh/kit-typography';
|
|
4
|
+
import { NumberPicker } from '../../../NumberPicker';
|
|
5
|
+
export function EditSendRateSettings(props) {
|
|
6
|
+
const {
|
|
7
|
+
messages,
|
|
8
|
+
onChange,
|
|
9
|
+
minValue,
|
|
10
|
+
maxValue
|
|
11
|
+
} = props;
|
|
12
|
+
const onMessagesChange = React.useCallback(value => {
|
|
13
|
+
onChange(value);
|
|
14
|
+
}, [onChange]);
|
|
15
|
+
return React.createElement(Horizontal, {
|
|
16
|
+
"$gap": 12,
|
|
17
|
+
"$alignItems": "center",
|
|
18
|
+
style: {
|
|
19
|
+
gridTemplateColumns: '145px 70px 150px'
|
|
20
|
+
}
|
|
21
|
+
}, React.createElement(Paragraph, null, "Limit to a maximum of"), React.createElement(NumberPicker, {
|
|
22
|
+
onChange: value => onMessagesChange(value),
|
|
23
|
+
value: messages,
|
|
24
|
+
minValue: minValue,
|
|
25
|
+
maxValue: maxValue
|
|
26
|
+
}), React.createElement(Paragraph, null, "messages per 1 sec"));
|
|
27
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type SendRateBase, type SendRatePolicy } from '../types';
|
|
3
|
+
export declare function getReadonlySendRateIcon(sendRateOption: SendRatePolicy, isGlobalSendRateDisabled: boolean): React.JSX.Element;
|
|
4
|
+
export declare function getReadonlySendRateLabel<T extends SendRateBase>(sendRateOption: T, isGlobalSendRateDisabled: boolean, globalSendRate: {
|
|
5
|
+
count: number;
|
|
6
|
+
seconds: number;
|
|
7
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { CheckRoundIcon, CloseRoundIcon, HelpRoundIcon } from '@pushwoosh/kit-icons';
|
|
5
|
+
import { Paragraph } from '@pushwoosh/kit-typography';
|
|
6
|
+
import { Tooltip } from '../../Tooltip';
|
|
7
|
+
import { Condition } from '../components/Condition';
|
|
8
|
+
import { IconWrapper } from '../styles';
|
|
9
|
+
export function getReadonlySendRateIcon(sendRateOption, isGlobalSendRateDisabled) {
|
|
10
|
+
if (sendRateOption === 'GLOBAL' && isGlobalSendRateDisabled) {
|
|
11
|
+
return React.createElement(CloseRoundIcon, {
|
|
12
|
+
size: "small",
|
|
13
|
+
view: "filled",
|
|
14
|
+
color: Color.LOCKED
|
|
15
|
+
});
|
|
16
|
+
;
|
|
17
|
+
}
|
|
18
|
+
return React.createElement(CheckRoundIcon, {
|
|
19
|
+
size: "small",
|
|
20
|
+
view: "filled",
|
|
21
|
+
type: "fill",
|
|
22
|
+
color: Color.BRIGHT
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export function getReadonlySendRateLabel(sendRateOption, isGlobalSendRateDisabled, globalSendRate) {
|
|
26
|
+
const {
|
|
27
|
+
policy,
|
|
28
|
+
sendRate
|
|
29
|
+
} = sendRateOption;
|
|
30
|
+
const tooltip = getReadonlyTooltip(policy, isGlobalSendRateDisabled);
|
|
31
|
+
if (policy === 'CUSTOM') {
|
|
32
|
+
return React.createElement(Paragraph, null, "Custom send rate for this message:", React.createElement(Condition, {
|
|
33
|
+
messages: sendRate
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
if (policy === 'IGNORE') {
|
|
37
|
+
return React.createElement(Horizontal, {
|
|
38
|
+
"$alignItems": "center",
|
|
39
|
+
"$gap": 4,
|
|
40
|
+
"$justifyContent": "start"
|
|
41
|
+
}, "Send messages without send rate", React.createElement(Tooltip, {
|
|
42
|
+
content: tooltip,
|
|
43
|
+
position: "top-middle"
|
|
44
|
+
}, React.createElement(IconWrapper, {
|
|
45
|
+
"$padding": "4px 0"
|
|
46
|
+
}, React.createElement(HelpRoundIcon, {
|
|
47
|
+
size: "small",
|
|
48
|
+
view: "lined"
|
|
49
|
+
}))));
|
|
50
|
+
}
|
|
51
|
+
return isGlobalSendRateDisabled ? React.createElement(Horizontal, {
|
|
52
|
+
"$alignItems": "center",
|
|
53
|
+
"$gap": 4,
|
|
54
|
+
"$justifyContent": "start"
|
|
55
|
+
}, "Global send rate is not active for this channel", React.createElement(Tooltip, {
|
|
56
|
+
content: tooltip,
|
|
57
|
+
position: "top-middle"
|
|
58
|
+
}, React.createElement(IconWrapper, {
|
|
59
|
+
"$padding": "4px 0"
|
|
60
|
+
}, React.createElement(HelpRoundIcon, {
|
|
61
|
+
size: "small",
|
|
62
|
+
view: "lined"
|
|
63
|
+
})))) : React.createElement(Paragraph, null, "Global send rate:", React.createElement(Condition, {
|
|
64
|
+
messages: globalSendRate.count
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
function getReadonlyTooltip(sendRateOption, isGlobalSendRateDisabled) {
|
|
68
|
+
if (sendRateOption === 'CUSTOM') {
|
|
69
|
+
return '';
|
|
70
|
+
}
|
|
71
|
+
if (sendRateOption === 'IGNORE') {
|
|
72
|
+
return 'Messages will be sent without rate limits, if possible, because no send rate is applied to this message';
|
|
73
|
+
}
|
|
74
|
+
if (isGlobalSendRateDisabled) {
|
|
75
|
+
return 'Messages will be sent as fast as possible because the global send rate limit is currently not active for this channel';
|
|
76
|
+
}
|
|
77
|
+
return '';
|
|
78
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const getSendRateOptions = isGlobalSendRateDisabled => [{
|
|
2
|
+
value: 'GLOBAL',
|
|
3
|
+
label: `Use global send rate settings${isGlobalSendRateDisabled ? ' (currently inactive)' : ''}`
|
|
4
|
+
}, {
|
|
5
|
+
value: 'IGNORE',
|
|
6
|
+
label: 'Send messages without send rate'
|
|
7
|
+
}, {
|
|
8
|
+
value: 'CUSTOM',
|
|
9
|
+
label: 'Use custom send rate'
|
|
10
|
+
}];
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export declare const Container: import("styled-components").StyledComponent<"div", any, {
|
|
2
|
+
$alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
3
|
+
$alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
4
|
+
$bgColor?: string | undefined;
|
|
5
|
+
$border?: string | ({
|
|
6
|
+
top?: string | undefined;
|
|
7
|
+
right?: string | undefined;
|
|
8
|
+
bottom?: string | undefined;
|
|
9
|
+
left?: string | undefined;
|
|
10
|
+
} | {
|
|
11
|
+
horizontal: string;
|
|
12
|
+
top?: string | undefined;
|
|
13
|
+
bottom?: string | undefined;
|
|
14
|
+
} | {
|
|
15
|
+
vertical: string;
|
|
16
|
+
right?: string | undefined;
|
|
17
|
+
left?: string | undefined;
|
|
18
|
+
}) | undefined;
|
|
19
|
+
$borderRadius?: (string | number) | undefined;
|
|
20
|
+
$boxShadow?: string | undefined;
|
|
21
|
+
$gap?: (string | number) | undefined;
|
|
22
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
23
|
+
$justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
24
|
+
$justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
25
|
+
$margin?: (string | number) | ({
|
|
26
|
+
top?: (string | number) | undefined;
|
|
27
|
+
right?: (string | number) | undefined;
|
|
28
|
+
bottom?: (string | number) | undefined;
|
|
29
|
+
left?: (string | number) | undefined;
|
|
30
|
+
} | {
|
|
31
|
+
horizontal: string | number;
|
|
32
|
+
top?: (string | number) | undefined;
|
|
33
|
+
bottom?: (string | number) | undefined;
|
|
34
|
+
} | {
|
|
35
|
+
vertical: string | number;
|
|
36
|
+
right?: (string | number) | undefined;
|
|
37
|
+
left?: (string | number) | undefined;
|
|
38
|
+
}) | undefined;
|
|
39
|
+
$padding?: (string | number) | ({
|
|
40
|
+
top?: (string | number) | undefined;
|
|
41
|
+
right?: (string | number) | undefined;
|
|
42
|
+
bottom?: (string | number) | undefined;
|
|
43
|
+
left?: (string | number) | undefined;
|
|
44
|
+
} | {
|
|
45
|
+
horizontal: string | number;
|
|
46
|
+
top?: (string | number) | undefined;
|
|
47
|
+
bottom?: (string | number) | undefined;
|
|
48
|
+
} | {
|
|
49
|
+
vertical: string | number;
|
|
50
|
+
right?: (string | number) | undefined;
|
|
51
|
+
left?: (string | number) | undefined;
|
|
52
|
+
}) | undefined;
|
|
53
|
+
$placeItems?: "end" | "start" | "center" | "stretch" | undefined;
|
|
54
|
+
} & {
|
|
55
|
+
$gridAutoFlow: string;
|
|
56
|
+
}, "$gridAutoFlow">;
|
|
57
|
+
export declare const IconWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
58
|
+
$alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
59
|
+
$alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
60
|
+
$bgColor?: string | undefined;
|
|
61
|
+
$border?: string | ({
|
|
62
|
+
top?: string | undefined;
|
|
63
|
+
right?: string | undefined;
|
|
64
|
+
bottom?: string | undefined;
|
|
65
|
+
left?: string | undefined;
|
|
66
|
+
} | {
|
|
67
|
+
horizontal: string;
|
|
68
|
+
top?: string | undefined;
|
|
69
|
+
bottom?: string | undefined;
|
|
70
|
+
} | {
|
|
71
|
+
vertical: string;
|
|
72
|
+
right?: string | undefined;
|
|
73
|
+
left?: string | undefined;
|
|
74
|
+
}) | undefined;
|
|
75
|
+
$borderRadius?: (string | number) | undefined;
|
|
76
|
+
$boxShadow?: string | undefined;
|
|
77
|
+
$gap?: (string | number) | undefined;
|
|
78
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
79
|
+
$justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
80
|
+
$justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
81
|
+
$margin?: (string | number) | ({
|
|
82
|
+
top?: (string | number) | undefined;
|
|
83
|
+
right?: (string | number) | undefined;
|
|
84
|
+
bottom?: (string | number) | undefined;
|
|
85
|
+
left?: (string | number) | undefined;
|
|
86
|
+
} | {
|
|
87
|
+
horizontal: string | number;
|
|
88
|
+
top?: (string | number) | undefined;
|
|
89
|
+
bottom?: (string | number) | undefined;
|
|
90
|
+
} | {
|
|
91
|
+
vertical: string | number;
|
|
92
|
+
right?: (string | number) | undefined;
|
|
93
|
+
left?: (string | number) | undefined;
|
|
94
|
+
}) | undefined;
|
|
95
|
+
$padding?: (string | number) | ({
|
|
96
|
+
top?: (string | number) | undefined;
|
|
97
|
+
right?: (string | number) | undefined;
|
|
98
|
+
bottom?: (string | number) | undefined;
|
|
99
|
+
left?: (string | number) | undefined;
|
|
100
|
+
} | {
|
|
101
|
+
horizontal: string | number;
|
|
102
|
+
top?: (string | number) | undefined;
|
|
103
|
+
bottom?: (string | number) | undefined;
|
|
104
|
+
} | {
|
|
105
|
+
vertical: string | number;
|
|
106
|
+
right?: (string | number) | undefined;
|
|
107
|
+
left?: (string | number) | undefined;
|
|
108
|
+
}) | undefined;
|
|
109
|
+
$placeItems?: "end" | "start" | "center" | "stretch" | undefined;
|
|
110
|
+
} & {
|
|
111
|
+
$gridAutoFlow: string;
|
|
112
|
+
}, "$gridAutoFlow">;
|
|
113
|
+
export declare const LinkWrapper: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
export const Container = styled(Vertical).withConfig({
|
|
5
|
+
displayName: "Container",
|
|
6
|
+
componentId: "sc-18un4me-0"
|
|
7
|
+
})(["max-width:560px;"]);
|
|
8
|
+
export const IconWrapper = styled(Horizontal).withConfig({
|
|
9
|
+
displayName: "IconWrapper",
|
|
10
|
+
componentId: "sc-18un4me-1"
|
|
11
|
+
})(["color:", ";&:hover{color:", ";cursor:pointer;}"], Color.PHANTOM, Color.PRIMARY_HOVER);
|
|
12
|
+
export const LinkWrapper = styled.span.withConfig({
|
|
13
|
+
displayName: "LinkWrapper",
|
|
14
|
+
componentId: "sc-18un4me-2"
|
|
15
|
+
})(["display:inline-flex;gap:4px;align-items:center;justify-content:start;text-decoration:none;"]);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type SendRatePolicy = 'UNKNOWN' | 'GLOBAL' | 'CUSTOM' | 'IGNORE';
|
|
2
|
+
export type SendRateBase<K extends SendRatePolicy = SendRatePolicy> = {
|
|
3
|
+
sendRate: number;
|
|
4
|
+
policy: K;
|
|
5
|
+
};
|
|
6
|
+
export type SendRateOption = {
|
|
7
|
+
label: string;
|
|
8
|
+
value: SendRatePolicy;
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/index.d.ts
CHANGED
|
@@ -36,4 +36,6 @@ export { CodeEditor } from './CodeEditor';
|
|
|
36
36
|
export { EnhancedInput, SearchInput } from './EnhancedInput';
|
|
37
37
|
export { Chip } from './Chip';
|
|
38
38
|
export { RichMessageEditor, RichMessageViewer, type DynamicContent } from './RichMessageEditor';
|
|
39
|
+
export { FrequencyCappingEdit, FrequencyCappingReadonly, type LocalCapping } from './FrequencyCapping';
|
|
40
|
+
export { SendRateEdit, SendRateReadonly } from './SendRate';
|
|
39
41
|
export { Alert } from './Alert';
|
package/index.js
CHANGED
|
@@ -36,4 +36,6 @@ export { CodeEditor } from './CodeEditor';
|
|
|
36
36
|
export { EnhancedInput, SearchInput } from './EnhancedInput';
|
|
37
37
|
export { Chip } from './Chip';
|
|
38
38
|
export { RichMessageEditor, RichMessageViewer } from './RichMessageEditor';
|
|
39
|
+
export { FrequencyCappingEdit, FrequencyCappingReadonly } from './FrequencyCapping';
|
|
40
|
+
export { SendRateEdit, SendRateReadonly } from './SendRate';
|
|
39
41
|
export { Alert } from './Alert';
|