@servicetitan/mpa-components 1.0.0 → 1.1.1
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/CHANGELOG.md +23 -0
- package/lib/components/campaign-actions/action-button/action-button-archive.d.ts +7 -0
- package/lib/components/campaign-actions/action-button/action-button-archive.d.ts.map +1 -0
- package/lib/components/campaign-actions/action-button/action-button-archive.js +4 -0
- package/lib/components/campaign-actions/action-button/action-button-archive.js.map +1 -0
- package/lib/components/campaign-actions/action-button/action-button-clone.d.ts +6 -0
- package/lib/components/campaign-actions/action-button/action-button-clone.d.ts.map +1 -0
- package/lib/components/campaign-actions/action-button/action-button-clone.js +4 -0
- package/lib/components/campaign-actions/action-button/action-button-clone.js.map +1 -0
- package/lib/components/campaign-actions/action-button/action-button-edit.d.ts +7 -0
- package/lib/components/campaign-actions/action-button/action-button-edit.d.ts.map +1 -0
- package/lib/components/campaign-actions/action-button/action-button-edit.js +4 -0
- package/lib/components/campaign-actions/action-button/action-button-edit.js.map +1 -0
- package/lib/components/campaign-actions/action-button/action-button-unarchive.d.ts +6 -0
- package/lib/components/campaign-actions/action-button/action-button-unarchive.d.ts.map +1 -0
- package/lib/components/campaign-actions/action-button/action-button-unarchive.js +4 -0
- package/lib/components/campaign-actions/action-button/action-button-unarchive.js.map +1 -0
- package/lib/components/campaign-actions/action-button/action-button.d.ts +14 -0
- package/lib/components/campaign-actions/action-button/action-button.d.ts.map +1 -0
- package/lib/components/campaign-actions/action-button/action-button.js +29 -0
- package/lib/components/campaign-actions/action-button/action-button.js.map +1 -0
- package/lib/components/campaign-actions/action-button/action-button.module.less +17 -0
- package/lib/components/campaign-actions/actions-button/actions-button.d.ts +5 -0
- package/lib/components/campaign-actions/actions-button/actions-button.d.ts.map +1 -0
- package/lib/components/campaign-actions/actions-button/actions-button.js +33 -0
- package/lib/components/campaign-actions/actions-button/actions-button.js.map +1 -0
- package/lib/components/campaign-actions/actions-button/actions-button.module.less +10 -0
- package/lib/components/campaign-actions/actions-button/campaign-actions.d.ts +11 -0
- package/lib/components/campaign-actions/actions-button/campaign-actions.d.ts.map +1 -0
- package/lib/components/campaign-actions/actions-button/campaign-actions.js +15 -0
- package/lib/components/campaign-actions/actions-button/campaign-actions.js.map +1 -0
- package/lib/components/campaign-actions/actions-button/campaign-actions.stories.d.ts +9 -0
- package/lib/components/campaign-actions/actions-button/campaign-actions.stories.d.ts.map +1 -0
- package/lib/components/campaign-actions/actions-button/campaign-actions.stories.js +11 -0
- package/lib/components/campaign-actions/actions-button/campaign-actions.stories.js.map +1 -0
- package/lib/components/campaign-actions/index.d.ts +2 -0
- package/lib/components/campaign-actions/index.d.ts.map +1 -0
- package/lib/components/campaign-actions/index.js +2 -0
- package/lib/components/campaign-actions/index.js.map +1 -0
- package/lib/components/settings/company-details/company-details-form.stories.js +1 -1
- package/lib/components/settings/company-details/company-details-form.stories.js.map +1 -1
- package/lib/components/settings/company-details/index.js +2 -2
- package/lib/components/settings/company-details/index.js.map +1 -1
- package/lib/components/settings/company-email-footer/company-email-footer.stories.js +1 -1
- package/lib/components/settings/company-email-footer/company-email-footer.stories.js.map +1 -1
- package/lib/components/settings/company-email-footer/index.js +1 -1
- package/lib/components/settings/company-email-footer/index.js.map +1 -1
- package/lib/components/settings/company-email-reply-to/company-email-reply-to.stories.js +1 -1
- package/lib/components/settings/company-email-reply-to/company-email-reply-to.stories.js.map +1 -1
- package/lib/components/settings/company-email-reply-to/index.js +1 -1
- package/lib/components/settings/company-email-reply-to/index.js.map +1 -1
- package/lib/components/settings/company-email-sender/company-email-sender.stories.js +2 -2
- package/lib/components/settings/company-email-sender/company-email-sender.stories.js.map +1 -1
- package/lib/components/settings/company-email-sender/custom-domain-sender.js +1 -1
- package/lib/components/settings/company-email-sender/custom-domain-sender.js.map +1 -1
- package/lib/components/settings/company-email-sender/simple-sender.js +1 -1
- package/lib/components/settings/company-email-sender/simple-sender.js.map +1 -1
- package/lib/components/settings/company-trade-checkbox/index.js +1 -1
- package/lib/components/settings/company-trade-checkbox/index.js.map +1 -1
- package/lib/components/settings/company-trades-picker/company-trades-picker.stories.js +1 -1
- package/lib/components/settings/company-trades-picker/company-trades-picker.stories.js.map +1 -1
- package/lib/components/settings/company-trades-picker/index.js +2 -2
- package/lib/components/settings/company-trades-picker/index.js.map +1 -1
- package/lib/components/settings/double-opt-in/double-opt-in.stories.js +1 -1
- package/lib/components/settings/double-opt-in/double-opt-in.stories.js.map +1 -1
- package/lib/components/settings/double-opt-in/index.js +1 -1
- package/lib/components/settings/double-opt-in/index.js.map +1 -1
- package/lib/components/settings/email-preview/email-preview.js +1 -1
- package/lib/components/settings/email-preview/email-preview.js.map +1 -1
- package/lib/components/settings/email-preview/opt-in-email-preview.js +1 -1
- package/lib/components/settings/email-preview/opt-in-email-preview.js.map +1 -1
- package/lib/components/settings/email-preview/opt-out-email-preview.js +1 -1
- package/lib/components/settings/email-preview/opt-out-email-preview.js.map +1 -1
- package/lib/components/settings/email-validation/email-validation.stories.js +2 -2
- package/lib/components/settings/email-validation/email-validation.stories.js.map +1 -1
- package/lib/components/settings/email-validation/index.js +2 -2
- package/lib/components/settings/email-validation/index.js.map +1 -1
- package/lib/components/settings/form-errors-list/index.js +1 -1
- package/lib/components/settings/form-errors-list/index.js.map +1 -1
- package/lib/components/settings/logo-picker/index.js +3 -3
- package/lib/components/settings/logo-picker/index.js.map +1 -1
- package/lib/components/settings/logo-picker/logo-picker.stories.js +1 -1
- package/lib/components/settings/logo-picker/logo-picker.stories.js.map +1 -1
- package/lib/components/settings/opt-out-message/index.js +1 -1
- package/lib/components/settings/opt-out-message/index.js.map +1 -1
- package/lib/components/settings/opt-out-message/opt-out-message.stories.js +1 -1
- package/lib/components/settings/opt-out-message/opt-out-message.stories.js.map +1 -1
- package/lib/components/settings/result-definitions-modal/header.js +1 -1
- package/lib/components/settings/result-definitions-modal/header.js.map +1 -1
- package/lib/components/settings/result-definitions-modal/index.js +1 -1
- package/lib/components/settings/result-definitions-modal/index.js.map +1 -1
- package/lib/components/settings/result-definitions-modal/row.js +1 -1
- package/lib/components/settings/result-definitions-modal/row.js.map +1 -1
- package/lib/components/settings/settings-section/index.js +1 -1
- package/lib/components/settings/settings-section/index.js.map +1 -1
- package/lib/components/settings/settings-section/settings-section.stories.js +1 -1
- package/lib/components/settings/settings-section/settings-section.stories.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/package.json +5 -2
- package/src/components/campaign-actions/action-button/action-button-archive.tsx +18 -0
- package/src/components/campaign-actions/action-button/action-button-clone.tsx +13 -0
- package/src/components/campaign-actions/action-button/action-button-edit.tsx +18 -0
- package/src/components/campaign-actions/action-button/action-button-unarchive.tsx +13 -0
- package/src/components/campaign-actions/action-button/action-button.module.less +17 -0
- package/src/components/campaign-actions/action-button/action-button.module.less.d.ts +5 -0
- package/src/components/campaign-actions/action-button/action-button.tsx +78 -0
- package/src/components/campaign-actions/actions-button/actions-button.module.less +10 -0
- package/src/components/campaign-actions/actions-button/actions-button.module.less.d.ts +3 -0
- package/src/components/campaign-actions/actions-button/actions-button.tsx +76 -0
- package/src/components/campaign-actions/actions-button/campaign-actions.stories.tsx +19 -0
- package/src/components/campaign-actions/actions-button/campaign-actions.tsx +77 -0
- package/src/components/campaign-actions/index.ts +1 -0
- package/src/index.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-section.stories.js","sourceRoot":"","sources":["../../../../src/components/settings/settings-section/settings-section.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,eAAe,IAAI,SAAS,EAAE,MAAM,GAAG,CAAC;AAEjD,eAAe;IACX,KAAK,EAAE,yCAAyC;IAChD,SAAS,EAAE,SAAS;IACpB,UAAU,EAAE,EAAE;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAChC,OAAO,CACH,KAAC,SAAS,kBAAC,KAAK,EAAC,eAAe,gBAC5B,KAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"settings-section.stories.js","sourceRoot":"","sources":["../../../../src/components/settings/settings-section/settings-section.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,eAAe,IAAI,SAAS,EAAE,MAAM,GAAG,CAAC;AAEjD,eAAe;IACX,KAAK,EAAE,yCAAyC;IAChD,SAAS,EAAE,SAAS;IACpB,UAAU,EAAE,EAAE;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAChC,OAAO,CACH,KAAC,SAAS,kBAAC,KAAK,EAAC,eAAe,gBAC5B,KAAC,QAAQ,2BAAoB,IACrB,CACf,CAAC;AACN,CAAC,CAAC"}
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAE9C,cAAc,iBAAiB,CAAC"}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAE9C,cAAc,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/mpa-components",
|
|
3
|
-
"
|
|
3
|
+
"repository": {
|
|
4
|
+
"url": "https://github.com/servicetitan/marketing"
|
|
5
|
+
},
|
|
6
|
+
"version": "1.1.1",
|
|
4
7
|
"description": "",
|
|
5
8
|
"main": "./lib/index.js",
|
|
6
9
|
"typings": "./lib/index.d.ts",
|
|
@@ -27,5 +30,5 @@
|
|
|
27
30
|
"cli": {
|
|
28
31
|
"webpack": false
|
|
29
32
|
},
|
|
30
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "2ac514219fc62a114bd05bd5bbc64c211963ceab"
|
|
31
34
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ActionButton } from './action-button';
|
|
3
|
+
|
|
4
|
+
export const ActionButtonArchive: FC<{
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
tooltip?: string;
|
|
7
|
+
onClick?(): void;
|
|
8
|
+
}> = props => (
|
|
9
|
+
<ActionButton
|
|
10
|
+
{...props}
|
|
11
|
+
iconName="archive"
|
|
12
|
+
hover="primary"
|
|
13
|
+
tooltip={props.tooltip}
|
|
14
|
+
qaPrefix="qa-action-button-archive"
|
|
15
|
+
>
|
|
16
|
+
Archive
|
|
17
|
+
</ActionButton>
|
|
18
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ActionButton } from './action-button';
|
|
3
|
+
|
|
4
|
+
export const ActionButtonClone: FC<{ disabled?: boolean; onClick?(): void }> = props => (
|
|
5
|
+
<ActionButton
|
|
6
|
+
{...props}
|
|
7
|
+
iconName="control_point_duplicate"
|
|
8
|
+
hover="primary"
|
|
9
|
+
qaPrefix="qa-action-button-clone"
|
|
10
|
+
>
|
|
11
|
+
Clone
|
|
12
|
+
</ActionButton>
|
|
13
|
+
);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ActionButton } from './action-button';
|
|
3
|
+
|
|
4
|
+
export const ActionButtonEdit: FC<{
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
tooltip?: string;
|
|
7
|
+
onClick?(): void;
|
|
8
|
+
}> = props => (
|
|
9
|
+
<ActionButton
|
|
10
|
+
{...props}
|
|
11
|
+
iconName="edit"
|
|
12
|
+
hover="primary"
|
|
13
|
+
qaPrefix="qa-action-button-edit"
|
|
14
|
+
tooltip={props.tooltip}
|
|
15
|
+
>
|
|
16
|
+
Edit
|
|
17
|
+
</ActionButton>
|
|
18
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ActionButton } from './action-button';
|
|
3
|
+
|
|
4
|
+
export const ActionButtonUnarchive: FC<{ disabled?: boolean; onClick?(): void }> = props => (
|
|
5
|
+
<ActionButton
|
|
6
|
+
{...props}
|
|
7
|
+
iconName="unarchive"
|
|
8
|
+
hover="primary"
|
|
9
|
+
qaPrefix="qa-action-button-unarchive"
|
|
10
|
+
>
|
|
11
|
+
Unarchive
|
|
12
|
+
</ActionButton>
|
|
13
|
+
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
@import (reference) '@servicetitan/tokens/dist/tokens.less';
|
|
2
|
+
|
|
3
|
+
.action-button {
|
|
4
|
+
padding: @spacing-1 @spacing-2;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
border: none;
|
|
7
|
+
background-color: transparent;
|
|
8
|
+
width: 210px;
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
|
|
12
|
+
&.primary:hover,
|
|
13
|
+
&.primary.focus-visible:focus {
|
|
14
|
+
background-color: @color-blue-100;
|
|
15
|
+
border-radius: @border-radius-1;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Icon,
|
|
3
|
+
BodyText,
|
|
4
|
+
IconNameType,
|
|
5
|
+
Tooltip,
|
|
6
|
+
useFocusVisible,
|
|
7
|
+
} from '@servicetitan/design-system';
|
|
8
|
+
import classnames from 'classnames';
|
|
9
|
+
import { ReactNode, FC, useRef } from 'react';
|
|
10
|
+
import * as Styles from './action-button.module.less';
|
|
11
|
+
|
|
12
|
+
export interface ActionButtonProps {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
iconName?: IconNameType;
|
|
15
|
+
hover?: 'primary' | 'negative' | 'none';
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
tooltip?: string;
|
|
18
|
+
qaPrefix?: string;
|
|
19
|
+
active?: boolean;
|
|
20
|
+
onClick?(): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const ActionButton: FC<ActionButtonProps> = ({
|
|
24
|
+
active,
|
|
25
|
+
children,
|
|
26
|
+
disabled,
|
|
27
|
+
iconName,
|
|
28
|
+
onClick,
|
|
29
|
+
qaPrefix,
|
|
30
|
+
tooltip,
|
|
31
|
+
}) => {
|
|
32
|
+
const buttonRef = useRef<HTMLButtonElement>(null);
|
|
33
|
+
const { blurFunction, focusFunction, isFocusVisible } = useFocusVisible(buttonRef);
|
|
34
|
+
|
|
35
|
+
const handleClick = () => {
|
|
36
|
+
if (disabled) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (onClick) {
|
|
41
|
+
onClick();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const getButton = () => {
|
|
46
|
+
const classes = classnames(Styles.actionButton, qaPrefix, {
|
|
47
|
+
[Styles.primary]: !disabled,
|
|
48
|
+
[Styles.focusVisible]: isFocusVisible,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<button
|
|
53
|
+
type="button"
|
|
54
|
+
ref={buttonRef}
|
|
55
|
+
className={classes}
|
|
56
|
+
onClick={handleClick}
|
|
57
|
+
disabled={disabled}
|
|
58
|
+
onFocus={focusFunction}
|
|
59
|
+
onBlur={blurFunction}
|
|
60
|
+
>
|
|
61
|
+
{iconName && <Icon name={iconName} size="20px" className="m-r-1" />}
|
|
62
|
+
<BodyText className={`${qaPrefix}-text ${active ? 'c-blue-500' : 'c-neutral-100'}`}>
|
|
63
|
+
{children}
|
|
64
|
+
</BodyText>
|
|
65
|
+
</button>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
if (!tooltip) {
|
|
70
|
+
return getButton();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<Tooltip text={tooltip} direction="l" el="div" className={`${qaPrefix}-tooltip`}>
|
|
75
|
+
{getButton()}
|
|
76
|
+
</Tooltip>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Card, Popover, Icon } from '@servicetitan/design-system';
|
|
2
|
+
import { FC, useState, useRef, useEffect, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
import * as Styles from './actions-button.module.less';
|
|
5
|
+
|
|
6
|
+
export const ActionsButton: FC<{
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}> = ({ children }) => {
|
|
9
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
10
|
+
const wrapElem = useRef<HTMLDivElement>(null);
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const handleClick = (event: MouseEvent) => {
|
|
14
|
+
if (!wrapElem.current) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const isClickedInside = wrapElem.current.contains(event.target as Node);
|
|
19
|
+
|
|
20
|
+
if (!isClickedInside) {
|
|
21
|
+
close();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
window.addEventListener('click', handleClick);
|
|
26
|
+
|
|
27
|
+
return () => {
|
|
28
|
+
window.removeEventListener('click', handleClick);
|
|
29
|
+
};
|
|
30
|
+
}, []);
|
|
31
|
+
|
|
32
|
+
const toggle = () => {
|
|
33
|
+
setIsOpen(!isOpen);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const close = () => {
|
|
37
|
+
setIsOpen(false);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div
|
|
42
|
+
ref={wrapElem}
|
|
43
|
+
className="qa-actions-button d-ib"
|
|
44
|
+
onClick={e => {
|
|
45
|
+
e.stopPropagation();
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
<Popover
|
|
49
|
+
className={Styles.popover}
|
|
50
|
+
width="xs"
|
|
51
|
+
open={isOpen}
|
|
52
|
+
direction="bl"
|
|
53
|
+
trigger={
|
|
54
|
+
<Card
|
|
55
|
+
raised
|
|
56
|
+
sharp
|
|
57
|
+
padding="none"
|
|
58
|
+
active={isOpen}
|
|
59
|
+
onClick={toggle}
|
|
60
|
+
className="qa-actions-button-menu-button"
|
|
61
|
+
>
|
|
62
|
+
<Card.Section className="p-half-i">
|
|
63
|
+
<Icon
|
|
64
|
+
name="more_vert"
|
|
65
|
+
size="22px"
|
|
66
|
+
className={isOpen ? 'c-blue-400' : ''}
|
|
67
|
+
/>
|
|
68
|
+
</Card.Section>
|
|
69
|
+
</Card>
|
|
70
|
+
}
|
|
71
|
+
>
|
|
72
|
+
{children}
|
|
73
|
+
</Popover>
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CampaignActions as Component } from './campaign-actions';
|
|
2
|
+
|
|
3
|
+
export function CampaignActions() {
|
|
4
|
+
return (
|
|
5
|
+
<Component
|
|
6
|
+
onClickEdit={() => {}}
|
|
7
|
+
onClickStop={() => {}}
|
|
8
|
+
onClickClone={() => {}}
|
|
9
|
+
onClickArchive={() => {}}
|
|
10
|
+
onClickUnarchive={() => {}}
|
|
11
|
+
/>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
title: 'MRK Components/CampaignActions',
|
|
17
|
+
component: CampaignActions,
|
|
18
|
+
parameters: {},
|
|
19
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ButtonGroup, Button } from '@servicetitan/design-system';
|
|
3
|
+
import { Confirm } from '@servicetitan/confirm';
|
|
4
|
+
import { ActionButtonArchive } from '../action-button/action-button-archive';
|
|
5
|
+
import { ActionButtonUnarchive } from '../action-button/action-button-unarchive';
|
|
6
|
+
import { ActionsButton } from './actions-button';
|
|
7
|
+
import { ActionButtonClone } from '../action-button/action-button-clone';
|
|
8
|
+
import { ActionButtonEdit } from '../action-button/action-button-edit';
|
|
9
|
+
|
|
10
|
+
interface CampaignActionsProps {
|
|
11
|
+
onClickEdit?(): void;
|
|
12
|
+
onClickStop?(): void;
|
|
13
|
+
onClickClone?(): void;
|
|
14
|
+
onClickArchive?(): void;
|
|
15
|
+
onClickUnarchive?(): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const CampaignActions: FC<CampaignActionsProps> = ({
|
|
19
|
+
onClickEdit,
|
|
20
|
+
onClickStop,
|
|
21
|
+
onClickClone,
|
|
22
|
+
onClickArchive,
|
|
23
|
+
onClickUnarchive,
|
|
24
|
+
}) => {
|
|
25
|
+
const stopAction = (handleClick: () => void) => (
|
|
26
|
+
<Button outline onClick={handleClick} small negative className="qa-campaign-actions-stop">
|
|
27
|
+
Stop
|
|
28
|
+
</Button>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const archiveAction = (handleClick: () => void) => (
|
|
32
|
+
<ActionButtonArchive onClick={handleClick} />
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const unarchiveAction = (handleClick: () => void) => (
|
|
36
|
+
<ActionButtonUnarchive onClick={handleClick} />
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<ButtonGroup>
|
|
41
|
+
{onClickStop && (
|
|
42
|
+
<Confirm
|
|
43
|
+
onConfirm={onClickStop}
|
|
44
|
+
title="Confirm stop"
|
|
45
|
+
message="Are you sure you want to stop this campaign?"
|
|
46
|
+
negative
|
|
47
|
+
>
|
|
48
|
+
{stopAction}
|
|
49
|
+
</Confirm>
|
|
50
|
+
)}
|
|
51
|
+
<ActionsButton>
|
|
52
|
+
{onClickClone && <ActionButtonClone onClick={onClickClone} />}
|
|
53
|
+
{onClickArchive && (
|
|
54
|
+
<Confirm
|
|
55
|
+
onConfirm={onClickArchive}
|
|
56
|
+
title="Confirm archive"
|
|
57
|
+
message="Are you sure you want to archive this campaign?"
|
|
58
|
+
negative={false}
|
|
59
|
+
>
|
|
60
|
+
{archiveAction}
|
|
61
|
+
</Confirm>
|
|
62
|
+
)}
|
|
63
|
+
{onClickUnarchive && (
|
|
64
|
+
<Confirm
|
|
65
|
+
onConfirm={onClickUnarchive}
|
|
66
|
+
title="Confirm unarchive"
|
|
67
|
+
message="Are you sure you want to unarchive this campaign?"
|
|
68
|
+
negative={false}
|
|
69
|
+
>
|
|
70
|
+
{unarchiveAction}
|
|
71
|
+
</Confirm>
|
|
72
|
+
)}
|
|
73
|
+
{onClickEdit && <ActionButtonEdit onClick={onClickEdit} />}
|
|
74
|
+
</ActionsButton>
|
|
75
|
+
</ButtonGroup>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './actions-button/campaign-actions';
|
package/src/index.ts
CHANGED