@servicetitan/mpa-components 0.2.2 → 0.3.0
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/lib/components/settings/company-details/index.d.ts +10 -9
- package/lib/components/settings/company-details/index.d.ts.map +1 -1
- package/lib/components/settings/company-details/index.js.map +1 -1
- package/lib/components/settings/company-email-footer/company-email-footer.stories.js +2 -2
- package/lib/components/settings/company-email-footer/company-email-footer.stories.js.map +1 -1
- package/lib/components/settings/company-email-footer/index.d.ts +4 -4
- package/lib/components/settings/company-email-footer/index.d.ts.map +1 -1
- package/lib/components/settings/company-email-reply-to/index.d.ts +1 -1
- package/lib/components/settings/company-email-reply-to/index.d.ts.map +1 -1
- package/lib/components/settings/company-email-sender/company-email-sender.stories.d.ts +3 -1
- package/lib/components/settings/company-email-sender/company-email-sender.stories.d.ts.map +1 -1
- package/lib/components/settings/company-email-sender/company-email-sender.stories.js +7 -3
- 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.d.ts +12 -0
- package/lib/components/settings/company-email-sender/custom-domain-sender.d.ts.map +1 -0
- package/lib/components/settings/company-email-sender/custom-domain-sender.js +29 -0
- package/lib/components/settings/company-email-sender/custom-domain-sender.js.map +1 -0
- package/lib/components/settings/company-email-sender/index.d.ts +2 -11
- package/lib/components/settings/company-email-sender/index.d.ts.map +1 -1
- package/lib/components/settings/company-email-sender/index.js +2 -28
- package/lib/components/settings/company-email-sender/index.js.map +1 -1
- package/lib/components/settings/company-email-sender/simple-sender.d.ts +8 -0
- package/lib/components/settings/company-email-sender/simple-sender.d.ts.map +1 -0
- package/lib/components/settings/company-email-sender/simple-sender.js +18 -0
- package/lib/components/settings/company-email-sender/simple-sender.js.map +1 -0
- package/lib/components/settings/company-trade-checkbox/index.d.ts +2 -2
- package/lib/components/settings/company-trade-checkbox/index.d.ts.map +1 -1
- package/lib/components/settings/company-trade-checkbox/index.js.map +1 -1
- package/lib/components/settings/company-trades-picker/index.d.ts +3 -3
- package/lib/components/settings/company-trades-picker/index.d.ts.map +1 -1
- package/lib/components/settings/company-trades-picker/index.js.map +1 -1
- package/lib/components/settings/double-opt-in/double-opt-in.stories.js +2 -2
- package/lib/components/settings/double-opt-in/double-opt-in.stories.js.map +1 -1
- package/lib/components/settings/double-opt-in/index.d.ts +5 -5
- package/lib/components/settings/double-opt-in/index.d.ts.map +1 -1
- package/lib/components/settings/email-validation/email-validation.stories.d.ts +3 -2
- package/lib/components/settings/email-validation/email-validation.stories.d.ts.map +1 -1
- package/lib/components/settings/email-validation/index.d.ts +4 -4
- package/lib/components/settings/email-validation/index.d.ts.map +1 -1
- package/lib/components/settings/email-validation/index.js.map +1 -1
- package/lib/components/settings/form-errors-list/index.d.ts +7 -0
- package/lib/components/settings/form-errors-list/index.d.ts.map +1 -0
- package/lib/components/settings/form-errors-list/index.js +14 -0
- package/lib/components/settings/form-errors-list/index.js.map +1 -0
- package/lib/components/settings/index.d.ts +2 -0
- package/lib/components/settings/index.d.ts.map +1 -1
- package/lib/components/settings/index.js +2 -0
- package/lib/components/settings/index.js.map +1 -1
- package/lib/components/settings/opt-out-message/index.d.ts +6 -6
- package/lib/components/settings/opt-out-message/index.d.ts.map +1 -1
- package/lib/components/settings/opt-out-message/opt-out-message.stories.js +2 -2
- package/lib/components/settings/opt-out-message/opt-out-message.stories.js.map +1 -1
- package/package.json +3 -9
- package/src/components/settings/company-details/index.tsx +10 -9
- package/src/components/settings/company-email-footer/company-email-footer.stories.tsx +2 -2
- package/src/components/settings/company-email-footer/index.tsx +4 -4
- package/src/components/settings/company-email-reply-to/index.tsx +1 -1
- package/src/components/settings/company-email-sender/company-email-sender.stories.tsx +11 -3
- package/src/components/settings/company-email-sender/custom-domain-sender.tsx +129 -0
- package/src/components/settings/company-email-sender/index.tsx +2 -129
- package/src/components/settings/company-email-sender/simple-sender.tsx +71 -0
- package/src/components/settings/company-trade-checkbox/index.tsx +3 -3
- package/src/components/settings/company-trades-picker/index.tsx +4 -4
- package/src/components/settings/double-opt-in/double-opt-in.stories.tsx +2 -2
- package/src/components/settings/double-opt-in/index.tsx +5 -5
- package/src/components/settings/email-validation/index.tsx +8 -8
- package/src/components/settings/form-errors-list/index.tsx +41 -0
- package/src/components/settings/index.ts +2 -0
- package/src/components/settings/opt-out-message/index.tsx +6 -6
- package/src/components/settings/opt-out-message/opt-out-message.stories.tsx +2 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -2,7 +2,7 @@ import { FC, Fragment, useCallback, useState } from 'react';
|
|
|
2
2
|
import { observer } from 'mobx-react';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
|
|
5
|
-
import { CheckboxFieldState, InputFieldState } from '@servicetitan/form';
|
|
5
|
+
import { CheckboxFieldState, InputFieldState, TextAreaFieldState } from '@servicetitan/form';
|
|
6
6
|
import { Form, Text, ToggleSwitch, Button } from '@servicetitan/design-system';
|
|
7
7
|
import { useConfirm } from '@servicetitan/confirm';
|
|
8
8
|
|
|
@@ -15,10 +15,10 @@ export const footerText =
|
|
|
15
15
|
'If you’ve received this email by mistake, no action is needed, just delete this message.';
|
|
16
16
|
|
|
17
17
|
export interface DoubleOptInPropsFormState {
|
|
18
|
-
emailSubject: InputFieldState<string>;
|
|
19
|
-
emailHeader: InputFieldState<string>;
|
|
20
|
-
emailBody:
|
|
21
|
-
emailButtonText: InputFieldState<string>;
|
|
18
|
+
emailSubject: InputFieldState<string | undefined>;
|
|
19
|
+
emailHeader: InputFieldState<string | undefined>;
|
|
20
|
+
emailBody: TextAreaFieldState<string | undefined>;
|
|
21
|
+
emailButtonText: InputFieldState<string | undefined>;
|
|
22
22
|
enabled: CheckboxFieldState;
|
|
23
23
|
}
|
|
24
24
|
export interface DoubleOptInProps {
|
|
@@ -43,20 +43,20 @@ export interface EmailValidationTableRecord<T> {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export interface EmailValidationProps<
|
|
46
|
-
TEmailValidationType extends string = string,
|
|
47
|
-
TEmailValidationResult extends string = string
|
|
46
|
+
TEmailValidationType extends string | number = string,
|
|
47
|
+
TEmailValidationResult extends string | number = string
|
|
48
48
|
> {
|
|
49
49
|
className?: string;
|
|
50
50
|
loading: boolean;
|
|
51
51
|
resultGrid: TableState<EmailValidationTableRecord<TEmailValidationResult>>;
|
|
52
|
-
validationRiskType
|
|
52
|
+
validationRiskType?: TEmailValidationType;
|
|
53
53
|
handleDownload(): void;
|
|
54
54
|
setValidationRiskType(type: TEmailValidationType): void;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
interface EmailValidationHocOptions<
|
|
58
|
-
TEmailValidationType extends string = string,
|
|
59
|
-
TEmailValidationResult extends string = string
|
|
58
|
+
TEmailValidationType extends string | number = string,
|
|
59
|
+
TEmailValidationResult extends string | number = string
|
|
60
60
|
> {
|
|
61
61
|
resultToText: Map<TEmailValidationResult, string>;
|
|
62
62
|
levelTypeMap: {
|
|
@@ -70,8 +70,8 @@ interface EmailValidationHocOptions<
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
export function emailValidationHoc<
|
|
73
|
-
TEmailValidationType extends string = string,
|
|
74
|
-
TEmailValidationResult extends string = string
|
|
73
|
+
TEmailValidationType extends string | number = string,
|
|
74
|
+
TEmailValidationResult extends string | number = string
|
|
75
75
|
>({
|
|
76
76
|
resultToText,
|
|
77
77
|
levelTypeMap,
|
|
@@ -103,7 +103,7 @@ export function emailValidationHoc<
|
|
|
103
103
|
resultGrid,
|
|
104
104
|
setValidationRiskType,
|
|
105
105
|
validationRiskType,
|
|
106
|
-
}: EmailValidationProps<TEmailValidationType>) {
|
|
106
|
+
}: EmailValidationProps<TEmailValidationType, TEmailValidationResult>) {
|
|
107
107
|
const localStore: EmailValidationLocalStore = useLocalStore(() => ({
|
|
108
108
|
open: false,
|
|
109
109
|
setOpen: action(function (this: EmailValidationLocalStore, state: boolean) {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { FC, useMemo } from 'react';
|
|
2
|
+
import { observer } from 'mobx-react';
|
|
3
|
+
import { ComposibleValidatable, FormState, ValidatableMapOrArray } from 'formstate';
|
|
4
|
+
|
|
5
|
+
import { Banner } from '@servicetitan/design-system';
|
|
6
|
+
|
|
7
|
+
export interface FormErrorsListProps<T extends ValidatableMapOrArray = ValidatableMapOrArray> {
|
|
8
|
+
form: FormState<T>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const FormErrorsList: FC<FormErrorsListProps> = observer(({ form }: FormErrorsListProps) => {
|
|
12
|
+
if (!form.hasError) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const errorsList = useMemo(
|
|
17
|
+
() =>
|
|
18
|
+
Object.entries(form.$).map(
|
|
19
|
+
([key, field]: [key: string, field: ComposibleValidatable<unknown>]) => {
|
|
20
|
+
return field.hasError ? (
|
|
21
|
+
<li key={key} className="qa-settings-email-error-list-item">
|
|
22
|
+
{field.error}
|
|
23
|
+
</li>
|
|
24
|
+
) : null;
|
|
25
|
+
}
|
|
26
|
+
),
|
|
27
|
+
[form.$]
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Banner
|
|
32
|
+
status="critical"
|
|
33
|
+
title="Missing Fields"
|
|
34
|
+
icon
|
|
35
|
+
className="m-b-2 qa-settings-email-error"
|
|
36
|
+
>
|
|
37
|
+
<p>Please complete all required fields:</p>
|
|
38
|
+
<ul className="qa-settings-email-error-list">{errorsList}</ul>
|
|
39
|
+
</Banner>
|
|
40
|
+
);
|
|
41
|
+
});
|
|
@@ -4,6 +4,8 @@ export * from './company-email-reply-to';
|
|
|
4
4
|
export * from './company-email-sender';
|
|
5
5
|
export * from './company-trades-picker';
|
|
6
6
|
export * from './double-opt-in';
|
|
7
|
+
export * from './email-validation';
|
|
8
|
+
export * from './form-errors-list';
|
|
7
9
|
export * from './logo-picker';
|
|
8
10
|
export * from './opt-out-message';
|
|
9
11
|
export * from './settings-section';
|
|
@@ -2,7 +2,7 @@ import { observer } from 'mobx-react';
|
|
|
2
2
|
import { FC, Fragment, useCallback, useState } from 'react';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
|
|
5
|
-
import { CheckboxFieldState, InputFieldState } from '@servicetitan/form';
|
|
5
|
+
import { CheckboxFieldState, InputFieldState, TextAreaFieldState } from '@servicetitan/form';
|
|
6
6
|
import { Button, Form, Stack, Text, ToggleSwitch } from '@servicetitan/design-system';
|
|
7
7
|
import { useConfirm } from '@servicetitan/confirm';
|
|
8
8
|
|
|
@@ -12,11 +12,11 @@ import { OptOutEmailPreview } from '../email-preview/opt-out-email-preview';
|
|
|
12
12
|
import * as Styles from './opt-out-message.module.less';
|
|
13
13
|
|
|
14
14
|
export interface OptOutMessageState {
|
|
15
|
-
subjectLine: InputFieldState<string>;
|
|
16
|
-
header: InputFieldState<string>;
|
|
17
|
-
body:
|
|
18
|
-
buttonText: InputFieldState<string>;
|
|
19
|
-
monthsLimit: InputFieldState<number>;
|
|
15
|
+
subjectLine: InputFieldState<string | undefined>;
|
|
16
|
+
header: InputFieldState<string | undefined>;
|
|
17
|
+
body: TextAreaFieldState<string | undefined>;
|
|
18
|
+
buttonText: InputFieldState<string | undefined>;
|
|
19
|
+
monthsLimit: InputFieldState<number | undefined>;
|
|
20
20
|
enabled: CheckboxFieldState;
|
|
21
21
|
autoSuppressionEnabled: CheckboxFieldState;
|
|
22
22
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CheckboxFieldState, InputFieldState } from '@servicetitan/form';
|
|
1
|
+
import { CheckboxFieldState, InputFieldState, TextAreaFieldState } from '@servicetitan/form';
|
|
2
2
|
import { injectable, provide, useDependencies } from '@servicetitan/react-ioc';
|
|
3
3
|
import { FormState } from 'formstate';
|
|
4
4
|
import { OptOutMessage as Component } from '.';
|
|
@@ -14,7 +14,7 @@ class OptOutStore {
|
|
|
14
14
|
form = new FormState({
|
|
15
15
|
subjectLine: new InputFieldState('Good bye'),
|
|
16
16
|
header: new InputFieldState('Opt out of emails'),
|
|
17
|
-
body: new
|
|
17
|
+
body: new TextAreaFieldState('Sorry to see you go!'),
|
|
18
18
|
buttonText: new InputFieldState('Bye'),
|
|
19
19
|
monthsLimit: new InputFieldState(6),
|
|
20
20
|
enabled: new CheckboxFieldState(true),
|