-
Notifications
You must be signed in to change notification settings - Fork 69
/
index.tsx
80 lines (74 loc) · 2.16 KB
/
index.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
/** @format **/
/**
* External dependencies
*/
import React from 'react';
import moment from 'moment';
import { __ } from '@wordpress/i18n';
import { Card, CardBody } from '@wordpress/components';
import { edit } from '@wordpress/icons';
/**
* Internal dependencies
*/
import type { Dispute } from 'wcpay/types/disputes';
import { isAwaitingResponse } from 'wcpay/disputes/utils';
import DisputeNotice from './dispute-notice';
import DisputeSummaryRow from './dispute-summary-row';
import DisputeSteps from './dispute-steps';
import InlineNotice from 'components/inline-notice';
import './style.scss';
import { ChargeBillingDetails } from 'wcpay/types/charges';
interface DisputeDetailsProps {
dispute: Dispute;
customer: ChargeBillingDetails | null;
chargeCreated: number;
}
const DisputeDetails: React.FC< DisputeDetailsProps > = ( {
dispute,
customer,
chargeCreated,
} ) => {
const now = moment();
const dueBy = moment.unix( dispute.evidence_details?.due_by ?? 0 );
const countdownDays = Math.floor( dueBy.diff( now, 'days', true ) );
const hasStagedEvidence = dispute.evidence_details?.has_evidence;
return (
<div className="transaction-details-dispute-details-wrapper">
<Card>
<CardBody className="transaction-details-dispute-details-body">
{ isAwaitingResponse( dispute.status ) &&
countdownDays >= 0 && (
<>
<DisputeNotice
dispute={ dispute }
urgent={ countdownDays <= 2 }
/>
{ hasStagedEvidence && (
<InlineNotice
icon={ edit }
isDismissible={ false }
>
{ __(
`You initiated a dispute a challenge to this dispute. Click 'Continue with challenge' to proceed with your drafted response.`,
'woocommerce-payments'
) }
</InlineNotice>
) }
<DisputeSummaryRow
dispute={ dispute }
daysRemaining={ countdownDays }
/>
<DisputeSteps
dispute={ dispute }
customer={ customer }
chargeCreated={ chargeCreated }
daysRemaining={ countdownDays }
/>
</>
) }
</CardBody>
</Card>
</div>
);
};
export default DisputeDetails;