File size: 3,818 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import { CALYPSO_CONTACT } from '@automattic/urls';
import { translate } from 'i18n-calypso';

const contactLink = <a href={ CALYPSO_CONTACT } target="_blank" rel="noopener noreferrer" />;
const transferCodeErrorMessages = {
	unlock_domain_and_disable_private_reg_failed: translate(
		'The domain could not be unlocked. ' +
			'Additionally, Privacy Protection could not be disabled. ' +
			'The transfer will most likely fail due to these errors.'
	),
	unlock_domain_failed: translate(
		'The domain could not be unlocked. ' + 'The transfer will most likely fail due to this error.'
	),
	disable_private_reg_failed: translate(
		'Privacy Protection could not be disabled. ' +
			'The transfer will most likely fail due to this error.'
	),
};
const cancelTransferErrorMessages = {
	enable_private_reg_failed: translate(
		'We were unable to enable Privacy Protection for your domain. ' +
			'Please try again or {{contactLink}}Contact Support{{/contactLink}} if you continue to have trouble.',
		{ components: { contactLink } }
	),
	decline_transfer_failed: translate(
		'We were unable to stop the transfer for your domain. ' +
			'Please try again or {{contactLink}}Contact Support{{/contactLink}} if you continue to have trouble.',
		{ components: { contactLink } }
	),
	lock_domain_failed: translate(
		'We were unable to lock your domain. ' +
			'Please try again or {{contactLink}}Contact Support{{/contactLink}} if you continue to have trouble.',
		{ components: { contactLink } }
	),
};

export const getDomainLockError = ( isLocking ) => {
	const options = {
		components: {
			a: contactLink,
		},
	};
	return isLocking
		? translate(
				'The domain could not be locked. ' +
					'Please try again or {{a}}Contact Support{{/a}} if you continue to have trouble.',
				options
		  )
		: translate(
				'The domain could not be unlocked. ' +
					'Please try again or {{a}}Contact Support{{/a}} if you continue to have trouble.',
				options
		  );
};

export const getDomainTransferCodeError = ( errorCode ) => {
	if ( errorCode && transferCodeErrorMessages.hasOwnProperty( errorCode ) ) {
		return translate(
			'An error occurred while trying to send the Domain Transfer code: {{strong}}%s{{/strong}} ' +
				'Please {{a}}Contact Support{{/a}}.',
			{
				args: transferCodeErrorMessages[ errorCode ],
				components: {
					strong: <strong />,
					a: contactLink,
				},
			}
		);
	}

	return translate(
		'An error occurred while trying to send the Domain Transfer code. ' +
			'Please try again or {{a}}Contact Support{{/a}} if you continue ' +
			'to have trouble.',
		{
			components: {
				a: contactLink,
			},
		}
	);
};

export const getCancelTransferSuccessMessage = ( { enablePrivacy, lockDomain } ) => {
	if ( enablePrivacy && lockDomain ) {
		return translate(
			"We've canceled your domain transfer. Your domain is now re-locked and " +
				'Privacy Protection has been enabled.'
		);
	} else if ( enablePrivacy ) {
		return translate(
			"We've canceled your domain transfer and " + 'Privacy Protection has been re-enabled.'
		);
	} else if ( lockDomain ) {
		return translate( "We've canceled your domain transfer and " + 're-locked your domain.' );
	}

	return translate( "We've canceled your domain transfer. " );
};

export const getCancelTransferErrorMessage = ( errorCode ) => {
	if ( errorCode && cancelTransferErrorMessages.hasOwnProperty( errorCode ) ) {
		return cancelTransferErrorMessages[ errorCode ];
	}

	return translate(
		'Oops! Something went wrong and your request could not be ' +
			'processed. Please try again or {{contactLink}}Contact Support{{/contactLink}} if ' +
			'you continue to have trouble.',
		{ components: { contactLink } }
	);
};

export const getNoticeOptions = ( domain ) => ( {
	duration: 5000,
	id: `domain-transfer-notification-${ domain }`,
} );