Skip to content
This repository was archived by the owner on Feb 9, 2022. It is now read-only.

Commit 75af8bb

Browse files
committed
Cancel Refund request feature
UX Fixes Signed-off-by: smarcet <[email protected]>
1 parent 733e326 commit 75af8bb

File tree

6 files changed

+45
-40
lines changed

6 files changed

+45
-40
lines changed

src/actions/order-actions.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -502,12 +502,7 @@ export const cancelRefundPurchaseOrder = (orderId) => (dispatch, getState) => {
502502
authErrorHandler
503503
)(params)(dispatch).then(() => {
504504
dispatch(stopLoading());
505-
dispatch(showMessage(
506-
success_message,
507-
() => {
508-
history.push(`/app/summits/${currentSummit.id}/purchase-orders/${orderId}`)
509-
}
510-
));
505+
dispatch(showMessage(success_message));
511506
}
512507
);
513508
}

src/actions/ticket-actions.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import {
2727
getCSV,
2828
escapeFilterValue
2929
} from 'openstack-uicore-foundation/lib/methods';
30-
import {ORDER_EMAIL_SENT, PURCHASE_ORDER_CANCEL_REFUND} from "./order-actions";
31-
3230

3331
export const REQUEST_TICKETS = 'REQUEST_TICKETS';
3432
export const RECEIVE_TICKETS = 'RECEIVE_TICKETS';
@@ -302,18 +300,13 @@ export const cancelRefundTicket = (orderId, ticketId) => (dispatch, getState) =>
302300

303301
return deleteRequest(
304302
null,
305-
createAction(TICKET_CANCEL_REFUND)({orderId}),
303+
createAction(TICKET_CANCEL_REFUND)({ticketId}),
306304
`${window.API_BASE_URL}/api/v1/summits/all/orders/${orderId}/tickets/${ticketId}/refund/cancel`,
307305
{},
308306
authErrorHandler
309307
)(params)(dispatch).then(() => {
310308
dispatch(stopLoading());
311-
dispatch(showMessage(
312-
success_message,
313-
() => {
314-
history.push(`/app/summits/${currentSummit.id}/purchase-orders/${orderId}`)
315-
}
316-
));
309+
dispatch(showMessage(success_message));
317310
}
318311
);
319312
}

src/pages/orders/edit-purchase-order-page.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,25 @@ class EditPurchaseOrderPage extends React.Component {
107107
<div className="container">
108108
<h3>
109109
{title} {T.translate("edit_purchase_order.purchase_order")}
110-
{entity.id != 0 &&
110+
{entity.id !== 0 &&
111111
<div className="pull-right form-inline">
112-
<input
112+
{
113+
(entity.status === 'RefundRequested' || entity.status === 'Paid') &&
114+
< input
113115
className="form-control"
114116
type="number"
115117
min="0"
116118
value={refund_amount}
117119
onChange={this.handleRefundChange}
118-
/>
119-
<button className="btn btn-sm btn-primary right-space" onClick={this.handleRefundOrder.bind(this, entity)}>
120-
{T.translate("edit_purchase_order.refund")}
121-
</button>
120+
/>
121+
}
122+
{
123+
(entity.status === 'RefundRequested' || entity.status === 'Paid') &&
124+
<button className="btn btn-sm btn-primary right-space"
125+
onClick={this.handleRefundOrder.bind(this, entity)}>
126+
{T.translate("edit_purchase_order.refund")}
127+
</button>
128+
}
122129
{
123130
entity.status === 'RefundRequested' &&
124131
<button className="btn btn-sm btn-primary right-space" onClick={this.handleCancelRefundOrder.bind(this, entity)}>
@@ -128,7 +135,7 @@ class EditPurchaseOrderPage extends React.Component {
128135
<button className="btn btn-sm btn-danger" onClick={this.handleDeleteOrder.bind(this, entity)}>
129136
{T.translate("edit_purchase_order.delete_order")}
130137
</button>
131-
{entity.status === 'Paid' &&
138+
{ entity.status === 'Paid' &&
132139
<button className="btn btn-sm btn-primary left-space"
133140
onClick={this.handleResendEmail.bind(this, entity)}>
134141
{T.translate("edit_purchase_order.resend_order_email")}

src/pages/orders/edit-ticket-page.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,20 +157,21 @@ class EditTicketPage extends React.Component {
157157

158158
<div className="row">
159159
<div className="col-md-6">
160-
{entity.status != 'Cancelled' &&
161-
<div className="pull-left form-inline">
162-
<input
163-
className="form-control"
164-
type="number"
165-
min="0"
166-
value={refund_amount}
167-
onChange={this.handleRefundChange}
168-
/>
169-
<button className="btn btn-sm btn-primary pull-right"
170-
onClick={this.handleRefundTicket.bind(this, entity)}>
171-
{T.translate("edit_ticket.refund_ticket")}
172-
</button>
173-
</div>
160+
{
161+
(entity.status === 'RefundRequested' || entity.status === 'Paid') &&
162+
<div className="pull-left form-inline">
163+
<input
164+
className="form-control"
165+
type="number"
166+
min="0"
167+
value={refund_amount}
168+
onChange={this.handleRefundChange}
169+
/>
170+
<button className="btn btn-sm btn-primary pull-right"
171+
onClick={this.handleRefundTicket.bind(this, entity)}>
172+
{T.translate("edit_ticket.refund_ticket")}
173+
</button>
174+
</div>
174175
}
175176
</div>
176177
<div className="col-md-6">

src/reducers/orders/purchase-order-reducer.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
import
1515
{
1616
RECEIVE_PURCHASE_ORDER,
17-
RESET_PURCHASE_ORDER_FORM, UPDATE_PURCHASE_ORDER
17+
RESET_PURCHASE_ORDER_FORM,
18+
UPDATE_PURCHASE_ORDER,
19+
PURCHASE_ORDER_CANCEL_REFUND
1820
} from '../../actions/order-actions';
1921

20-
2122
import { LOGOUT_USER, VALIDATE } from 'openstack-uicore-foundation/lib/actions';
2223
import {SET_CURRENT_SUMMIT} from "../../actions/summit-actions";
2324

@@ -106,6 +107,10 @@ const purchaseOrderReducer = (state = DEFAULT_STATE, action) => {
106107
case VALIDATE: {
107108
return {...state, errors: payload.errors };
108109
}
110+
case PURCHASE_ORDER_CANCEL_REFUND:{
111+
let { entity} = state;
112+
return {...state, entity: {...entity, status: 'Paid' }};
113+
}
109114
break;
110115
default:
111116
return state;

src/reducers/tickets/ticket-reducer.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
UPDATE_TICKET,
1717
TICKET_UPDATED,
1818
TICKET_MEMBER_REASSIGNED,
19-
BADGE_ADDED_TO_TICKET
19+
BADGE_ADDED_TO_TICKET, TICKET_CANCEL_REFUND
2020
} from '../../actions/ticket-actions';
2121
import {
2222
BADGE_DELETED,
@@ -124,7 +124,7 @@ const ticketReducer = (state = DEFAULT_STATE, action) => {
124124
break;
125125
case FEATURE_BADGE_REMOVED: {
126126
let {featureId} = payload;
127-
let badgeFeatures = state.entity.badge.features.filter(f => f.id != featureId);
127+
let badgeFeatures = state.entity.badge.features.filter(f => f.id !== featureId);
128128
return {...state, entity: {...state.entity, badge: {...state.entity.badge, features: badgeFeatures} } };
129129
}
130130
break;
@@ -134,6 +134,10 @@ const ticketReducer = (state = DEFAULT_STATE, action) => {
134134

135135
return {...state, entity: {...state.entity, badge: {...state.entity.badge, features: badgeFeatures}} };
136136
}
137+
case TICKET_CANCEL_REFUND:{
138+
let { entity} = state;
139+
return {...state, entity: {...entity, status: 'Paid' }};
140+
}
137141
break;
138142
default:
139143
return state;

0 commit comments

Comments
 (0)