Skip to content

Commit

Permalink
Refactor disputes
Browse files Browse the repository at this point in the history
  • Loading branch information
mgascam committed Oct 28, 2024
1 parent b5aef87 commit 284592d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions client/disputes/evidence/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ describe( 'Dispute evidence form', () => {

global.wcpaySettings = {
restUrl: 'http://example.com/wp-json/',
dateFormat: 'M j, Y',
};
} );
afterEach( () => {
Expand Down Expand Up @@ -190,6 +191,8 @@ describe( 'Dispute evidence page', () => {
precision: 2,
},
},
dateFormat: 'M j, Y',
timeFormat: 'g:iA',
};
} );

Expand Down
14 changes: 7 additions & 7 deletions client/disputes/info/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
import * as React from 'react';
import { __ } from '@wordpress/i18n';
import { dateI18n } from '@wordpress/date';
import moment from 'moment';
import { Link } from '@woocommerce/components';

Expand All @@ -20,6 +19,7 @@ import { formatExplicitCurrency } from 'multi-currency/interface/functions';
import './style.scss';
import Loadable from 'components/loadable';
import { Dispute } from 'wcpay/types/disputes';
import { formatDateTime } from 'wcpay/utils/date-time';

const fields: { key: string; label: string }[] = [
{ key: 'created', label: __( 'Dispute date', 'woocommerce-payments' ) },
Expand Down Expand Up @@ -69,20 +69,20 @@ const Info = ( {
transactionId: __( 'Transaction link', 'woocommerce-payments' ),
}
: {
created: dateI18n(
'M j, Y',
moment( dispute.created * 1000 ).toISOString()
created: formatDateTime(
moment( dispute.created * 1000 ).toISOString(),
{ includeTime: false, useGmt: false }
),
amount: formatExplicitCurrency(
dispute.amount || 0,
dispute.currency || 'USD'
),
dueBy: dispute.evidence_details
? dateI18n(
'M j, Y - g:iA',
? formatDateTime(
moment(
dispute.evidence_details.due_by * 1000
).toISOString()
).toISOString(),
{ separator: ' - ', useGmt: false }
)
: null,
reason: composeDisputeReason( dispute ),
Expand Down
4 changes: 4 additions & 0 deletions client/disputes/info/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ declare const global: {
precision: number;
};
};
dateFormat: string;
timeFormat: string;
};
};

Expand All @@ -49,6 +51,8 @@ describe( 'Dispute info', () => {
precision: 2,
},
},
dateFormat: 'M j, Y',
timeFormat: 'g:iA',
};
} );

Expand Down

0 comments on commit 284592d

Please sign in to comment.