Skip to content

Commit a8b0266

Browse files
authored
Merge pull request #4855 from coopcycle/feature/invoicing-improvements
Minor invoicing UX improvements
2 parents 19ba145 + b676c19 commit a8b0266

File tree

6 files changed

+55
-6
lines changed

6 files changed

+55
-6
lines changed

cypress/e2e/invoicing/export_data_for_invoicing.cy.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ context('Invoicing (role: admin)', () => {
1414
cy.login('admin', '12345678')
1515
})
1616

17-
it('prepare data for invoicing', function () {
17+
it('show data for invoicing using custom date picker', function () {
1818
cy.visit('/admin/invoicing')
1919

20+
cy.get('[data-testid="invoicing.toggleRangePicker"]').click()
21+
2022
// Choose 1 month
2123
cy.get('.ant-picker-input-active > input').click()
2224
cy.get(

js/app/admin/invoicing/components/OrdersTable/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export default function OrdersTable({
130130
pagination={{
131131
pageSize,
132132
total,
133+
showSizeChanger: true,
133134
}}
134135
onChange={pagination => {
135136
setCurrentPage(pagination.current)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import React from 'react'
2+
import { DatePicker } from 'antd'
3+
import { useTranslation } from 'react-i18next'
4+
5+
export default function RangePicker({ setDateRange }) {
6+
const [isComplexPicker, setIsComplexPicker] = React.useState(false)
7+
8+
const { t } = useTranslation()
9+
10+
const title = isComplexPicker
11+
? t('ADMIN_ORDERS_TO_INVOICE_FILTER_RANGE_SIMPLE')
12+
: t('ADMIN_ORDERS_TO_INVOICE_FILTER_RANGE_COMPLEX')
13+
14+
return (
15+
<div className="d-flex flex-column">
16+
{t('ADMIN_ORDERS_TO_INVOICE_FILTER_RANGE')}
17+
{isComplexPicker ? (
18+
<DatePicker.RangePicker
19+
onChange={dates => {
20+
setDateRange(dates)
21+
}}
22+
/>
23+
) : (
24+
<DatePicker
25+
picker="month"
26+
onChange={date => {
27+
const range = [
28+
date.clone().local().startOf('month'),
29+
date.clone().local().endOf('month'),
30+
]
31+
setDateRange(range)
32+
}}
33+
/>
34+
)}
35+
<a
36+
className="text-secondary"
37+
title={title}
38+
data-testid="invoicing.toggleRangePicker"
39+
onClick={() => setIsComplexPicker(!isComplexPicker)}>
40+
{title}
41+
</a>
42+
</div>
43+
)
44+
}

js/app/admin/invoicing/components/OrdersToInvoice/index.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React, { useMemo, useState } from 'react'
22
import Modal from 'react-modal'
33
import { useTranslation } from 'react-i18next'
4-
import { DatePicker } from 'antd'
54

65
import Button from '../../../../components/core/Button'
76
import { prepareParams } from '../../redux/actions'
87
import ExportModalContent from '../ExportModalContent'
98
import OrganizationsTable from '../OrganizationsTable'
9+
import RangePicker from './RangePicker'
1010

1111
const ordersStates = ['new', 'accepted', 'fulfilled']
1212

@@ -45,11 +45,10 @@ export default () => {
4545
<h5>{t('ADMIN_ORDERS_TO_INVOICE_TITLE')}</h5>
4646
<div className="d-flex" style={{ marginTop: '12px', gap: '24px' }}>
4747
{t('ADMIN_DASHBOARD_NAV_FILTERS')}:
48+
<RangePicker setDateRange={setDateRange} />
4849
<div className="d-flex flex-column">
49-
{t('ADMIN_ORDERS_TO_INVOICE_FILTER_RANGE')}
50-
<DatePicker.RangePicker onChange={setDateRange} />
51-
</div>
52-
<div className="d-flex flex-column justify-content-end">
50+
{/*invisible text is used to align the Refresh button*/}
51+
<span style={{ visibility: 'hidden' }}>{'invisible text'}</span>
5352
<Button
5453
testID="invoicing.refresh"
5554
primary

js/app/admin/invoicing/components/OrganizationsTable/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export default function OrganizationsTable({
113113
pagination={{
114114
pageSize,
115115
total,
116+
showSizeChanger: true,
116117
}}
117118
onChange={pagination => {
118119
reloadData(pagination.current, pagination.pageSize)

js/app/i18n/locales/en.json

+2
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@
198198
"ADMIN_INVOICING_TITLE": "Invoicing [PREVIEW]",
199199
"ADMIN_ORDERS_TO_INVOICE_TITLE": "Orders to invoice",
200200
"ADMIN_ORDERS_TO_INVOICE_FILTER_RANGE": "Period",
201+
"ADMIN_ORDERS_TO_INVOICE_FILTER_RANGE_SIMPLE": "Select month",
202+
"ADMIN_ORDERS_TO_INVOICE_FILTER_RANGE_COMPLEX": "Select custom period",
201203
"ADMIN_ORDERS_TO_INVOICE_REFRESH": "Refresh",
202204
"ADMIN_ORDERS_TO_INVOICE_DOWNLOAD": "Download",
203205
"ADMIN_ORDERS_TO_INVOICE_ORGANIZATION_LABEL": "Organization (number of orders)",

0 commit comments

Comments
 (0)