Skip to content

Commit

Permalink
fixed loading of payment details (binary-com#6847)
Browse files Browse the repository at this point in the history
  • Loading branch information
farrah-deriv authored and adrienne-deriv committed Nov 17, 2022
1 parent a6faeb2 commit 6b35025
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const OrderDetails = observer(() => {
disposeReactions();
order_store.setOrderPaymentMethodDetails(undefined);
order_store.setOrderId(null);
order_store.setActiveOrder(null);
general_store.props.setP2POrderProps({
order_id: order_store.order_id,
redirectToOrderDetails: general_store.redirectToOrderDetails,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const OrderRow = ({ style, row: order }) => {

const onRowClick = () => {
if (should_show_order_details.current) {
return order_store.setQueryDetails(order);
return order_store.setOrderId(order.id);
}

return () => {};
Expand Down
17 changes: 12 additions & 5 deletions packages/p2p/src/stores/order-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { api_error_codes } from '../constants/api-error-codes';
export default class OrderStore {
constructor(root_store) {
makeObservable(this, {
active_order: observable,
api_error_message: observable,
cancellation_block_duration: observable,
cancellation_count_period: observable,
Expand Down Expand Up @@ -47,6 +48,7 @@ export default class OrderStore {
onOrdersUpdate: action.bound,
onPageReturn: action.bound,
onUnmount: action.bound,
setActiveOrder: action.bound,
setForceRerenderOrders: action.bound,
setApiErrorMessage: action.bound,
setCancellationBlockDuration: action.bound,
Expand Down Expand Up @@ -91,6 +93,7 @@ export default class OrderStore {
);
}

active_order = null;
api_error_message = '';
cancellation_block_duration = 0;
cancellation_count_period = 0;
Expand Down Expand Up @@ -124,11 +127,7 @@ export default class OrderStore {
}

get order_information() {
const { general_store } = this.root_store;
const order = this.orders.find(o => o.id === this.order_id);
return order
? createExtendedOrderDetails(order, general_store.client.loginid, general_store.props.server_time)
: null;
return this.active_order;
}

get nav() {
Expand Down Expand Up @@ -255,6 +254,7 @@ export default class OrderStore {
this.root_store.general_store.redirectTo(this.nav.location);
}
this.setOrderId(null);
this.setActiveOrder(null);
}

loadMoreOrders({ startIndex }) {
Expand Down Expand Up @@ -370,6 +370,10 @@ export default class OrderStore {
});
}

setActiveOrder(active_order) {
this.active_order = active_order;
}

setQueryDetails(input_order) {
const { general_store } = this.root_store;
const order_information = createExtendedOrderDetails(
Expand All @@ -386,6 +390,9 @@ export default class OrderStore {
if (order_information?.payment_method_details) {
this.setOrderPaymentMethodDetails(Object.values(order_information?.payment_method_details));
}

this.setActiveOrder(order_information);

// When viewing specific order, update its read state in localStorage.
const { notifications } = this.root_store.general_store.getLocalStorageSettingsForLoginId();

Expand Down

0 comments on commit 6b35025

Please sign in to comment.