-
Notifications
You must be signed in to change notification settings - Fork 69
/
dispute-steps.tsx
189 lines (181 loc) · 5.57 KB
/
dispute-steps.tsx
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/** @format **/
/**
* External dependencies
*/
import React from 'react';
import { __, _n, sprintf } from '@wordpress/i18n';
import { createInterpolateElement } from '@wordpress/element';
import { dateI18n } from '@wordpress/date';
import moment from 'moment';
import HelpOutlineIcon from 'gridicons/dist/help-outline';
import classNames from 'classnames';
/**
* Internal dependencies
*/
import type { Dispute } from 'wcpay/types/disputes';
import { ChargeBillingDetails } from 'wcpay/types/charges';
import { formatExplicitCurrency } from 'utils/currency';
import { ClickTooltip } from 'wcpay/components/tooltip';
interface Props {
dispute: Dispute;
customer: ChargeBillingDetails | null;
chargeCreated: number;
daysRemaining: number;
}
const DisputeSteps: React.FC< Props > = ( {
dispute,
customer,
chargeCreated,
daysRemaining,
} ) => {
let emailLink;
if ( customer?.email ) {
const chargeDate = dateI18n(
'Y-m-d',
moment( chargeCreated * 1000 ).toISOString()
);
const disputeDate = dateI18n(
'Y-m-d',
moment( dispute.created * 1000 ).toISOString()
);
const emailSubject = `Problem with your purchase from ${ wcpaySettings.storeName } on ${ chargeDate }?`;
const emailBody =
`Hello ${ customer?.name }\n\n` +
`We noticed that on ${ disputeDate }, you disputed a ${ formatExplicitCurrency(
dispute.amount,
dispute.currency
) } from ${ chargeDate }. We wanted to contact you to make sure everything was all right with your purchase and see if there's anything else we can do to resolve any problems you might have had.\n\n` +
`Alternatively, if the dispute was a mistake, you could easily withdraw it by calling the number on the back of your card. Thank you so much - we appreciate your business and look forward to working with you.`;
emailLink = `mailto:${ customer.email }?subject=${ encodeURIComponent(
emailSubject
) }&body=${ encodeURIComponent( emailBody ) }`;
}
const respondByDate = dispute.evidence_details?.due_by
? dateI18n(
'M j, Y, g:ia',
moment( dispute.evidence_details?.due_by * 1000 ).toISOString()
)
: '–';
return (
<div className="dispute-steps">
<div className="dispute-steps__header">
{ __( 'Steps to resolve:', 'woocommercts' ) }
</div>
<ol className="dispute-steps__steps">
<li>
{
// TODO: add link to the issuer evidence files link. See https://github.com/Automattic/woocommerce-payments/pull/7192.
__(
"Review the claim issued by the cardholder's bank.",
'woocommerce-payments'
)
}
</li>
<li>
{ customer?.email
? createInterpolateElement(
__(
'<a>Email the customer</a> to address their concerns.',
'woocommerce-payments'
),
{
a: (
// eslint-disable-next-line jsx-a11y/anchor-has-content
<a
target="_blank"
rel="noopener noreferrer"
href={ emailLink }
/>
),
}
)
: __(
'Email the customer to address their concerns.',
'woocommerce-payments'
) }
</li>
<li>
{
// TODO: link 'guidance on dispute withdrawal' to the docs when it's ready.
__(
'Provide guidance on dispute withdrawal if the customer agrees.',
'woocommerce-payments'
)
}
</li>
<li>
{ createInterpolateElement(
__(
'Challenge <challengeicon/> or accept <accepticon/> the dispute by <disputeduedate/>.',
'woocommerce-payments'
),
{
challengeicon: (
<ClickTooltip
buttonIcon={ <HelpOutlineIcon /> }
buttonLabel={ __(
'Challenge the dispute',
'woocommerce-payments'
) }
content={ __(
"Challenge the dispute if you consider the claim invalid. You'll need to provide evidence to back your claim. Keep in mind that challenging doesn't ensure a resolution in your favor.",
'woocommerce-payments'
) }
/>
),
accepticon: (
<ClickTooltip
buttonIcon={ <HelpOutlineIcon /> }
buttonLabel={ __(
'Accept the dispute',
'woocommerce-payments'
) }
content={ sprintf(
// Translators: %s is a formatted currency amount, eg $10.00.
__(
`Accepting this dispute will automatically close it. Your account will be charged a %s fee, and the disputed amount will be refunded to the cardholder.`,
'woocommerce-payments'
),
// TODO: use getDisputeFee() from https://github.com/Automattic/woocommerce-payments/pull/7118.
''
) }
/>
),
disputeduedate: (
<span className="dispute-steps__steps__response-date">
{ respondByDate }
<span
className={ classNames( {
'dispute-steps__steps__response-date--urgent':
daysRemaining < 3,
'dispute-steps__steps__response-date--warning':
daysRemaining < 7 &&
daysRemaining > 2,
} ) }
>
{ daysRemaining === 0
? __(
'(Last day today)',
'woocommerce-payments'
)
: sprintf(
// Translators: %s is the number of days left to respond to the dispute.
_n(
'(%s day left to respond)',
'(%s days left to respond)',
daysRemaining,
'woocommerce-payments'
),
daysRemaining
) }
</span>
</span>
),
}
) }
</li>
</ol>
</div>
);
};
export default DisputeSteps;