-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ameerul /Bug 74362 Give feedback button does nothing when user in existing order page #6456
Changes from all commits
4b3a061
ea78d3c
4d569fd
d57ed78
aaeac4a
6f76f3e
40a5f26
7a23953
59dbeb2
845562c
a07a152
5bcd9a2
dc331bf
ea704f6
27ef4e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ export default class NotificationStore extends BaseStore { | |
@observable push_notifications = []; | ||
@observable client_notifications = {}; | ||
@observable should_show_popups = true; | ||
@observable p2p_order_props = {}; | ||
|
||
constructor(root_store) { | ||
super({ root_store }); | ||
|
@@ -55,6 +56,7 @@ export default class NotificationStore extends BaseStore { | |
root_store.common?.selected_contract_type, | ||
root_store.client.is_eu, | ||
root_store.client.has_enabled_two_fa, | ||
this.p2p_order_props.order_id, | ||
], | ||
async () => { | ||
if ( | ||
|
@@ -435,14 +437,41 @@ export default class NotificationStore extends BaseStore { | |
} | ||
} | ||
|
||
@action.bound | ||
showCompletedOrderNotification(advertiser_name, order_id) { | ||
const notification_key = `order-${order_id}`; | ||
|
||
const notification_redirect_action = | ||
routes.cashier_p2p === window.location.pathname | ||
? { | ||
onClick: () => { | ||
this.p2p_order_props.redirectToOrderDetails(order_id); | ||
this.setP2POrderProps({ | ||
...this.p2p_order_props, | ||
order_id, | ||
}); | ||
if (this.is_notifications_visible) this.toggleNotificationsModal(); | ||
this.refreshNotifications(); | ||
}, | ||
text: localize('Give feedback'), | ||
} | ||
: { | ||
route: `${routes.cashier_p2p}?order=${order_id}`, | ||
text: localize('Give feedback'), | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When the user is within p2p, if they click give feedback, it doesn't navigate them to the order details page of that order. Hence I needed to take the redirectToOrderDetails function from p2p to redirect them to that page in p2p. |
||
|
||
this.addNotificationMessage({ | ||
action: { | ||
route: `${routes.cashier_p2p}?order=${order_id}`, | ||
text: localize('Give feedback'), | ||
}, | ||
action: | ||
this.p2p_order_props?.order_id === order_id | ||
? { | ||
onClick: () => { | ||
this.p2p_order_props.setIsRatingModalOpen(true); | ||
if (this.is_notifications_visible) this.toggleNotificationsModal(); | ||
this.refreshNotifications(); | ||
}, | ||
text: localize('Give feedback'), | ||
} | ||
: notification_redirect_action, | ||
header: <Localize i18n_default_text='Your order {{order_id}} is complete' values={{ order_id }} />, | ||
key: notification_key, | ||
message: ( | ||
|
@@ -1114,6 +1143,11 @@ export default class NotificationStore extends BaseStore { | |
this.client_notifications = notifications; | ||
} | ||
|
||
@action.bound | ||
setP2POrderProps(p2p_order_props) { | ||
this.p2p_order_props = p2p_order_props; | ||
} | ||
|
||
@action.bound | ||
setShouldShowPopups(should_show_popups) { | ||
this.should_show_popups = should_show_popups; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,7 +101,7 @@ | |
height: fit-content; | ||
width: fit-content; | ||
|
||
> span { | ||
> span { | ||
padding-right: 0.8rem; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,11 @@ const App = props => { | |
general_store.redirectTo('orders'); | ||
order_store.setOrderId(order_id); | ||
} | ||
general_store.props.setP2POrderProps({ | ||
order_id, | ||
redirectToOrderDetails: general_store.redirectToOrderDetails, | ||
setIsRatingModalOpen: order_store.setIsRatingModalOpen, | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. called setP2POrderProps whenever order_id changes, so when clicking between the different order give feedback buttons, the user can navigate to each order. If this is not here, there will be a bug where the user could navigate from one order to the other, but then wouldn't be able to click the give feedback button as the order_id in p2p_order_props won't be updated |
||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [order_id]); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,11 @@ const OrderDetails = observer(() => { | |
disposeReactions(); | ||
order_store.setOrderPaymentMethodDetails(undefined); | ||
order_store.setOrderId(null); | ||
general_store.props.setP2POrderProps({ | ||
order_id: order_store.order_id, | ||
redirectToOrderDetails: general_store.redirectToOrderDetails, | ||
setIsRatingModalOpen: order_store.setIsRatingModalOpen, | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. set the p2p_order_props when unmounting order-details page as if the user navigates from the order-details page to another page outside of p2p, then if they click the give feedback button in notifications that has the same order_id as the previous order-details page they had just left, they would not be able to navigate to the same order page. Hence the need to reset the p2p_order_props. |
||
}; | ||
}, []); // eslint-disable-line react-hooks/exhaustive-deps | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,7 +231,17 @@ export default class GeneralStore extends BaseStore { | |
this.updateP2pNotifications(notifications); | ||
} | ||
|
||
@action.bound | ||
redirectToOrderDetails(order_id) { | ||
const { order_store } = this.root_store; | ||
this.redirectTo('orders'); | ||
this.setOrderTableType(order_list.INACTIVE); | ||
order_store.setOrderId(order_id); | ||
} | ||
|
||
@action.bound | ||
showCompletedOrderNotification(advertiser_name, order_id) { | ||
const { order_store } = this.root_store; | ||
const notification_key = `order-${order_id}`; | ||
|
||
// we need to refresh notifications in notifications-store in the case of a bug when user closes the notification, the notification count is not synced up with the closed notification | ||
|
@@ -240,9 +250,10 @@ export default class GeneralStore extends BaseStore { | |
this.props.addNotificationMessage({ | ||
action: { | ||
onClick: () => { | ||
this.redirectTo('orders'); | ||
this.setOrderTableType(order_list.INACTIVE); | ||
this.root_store.order_store.setOrderId(order_id); | ||
if (order_store.order_id === order_id) { | ||
order_store.setIsRatingModalOpen(true); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. have to check if order_id has been set already or else if the user is not on order_details page and click the Give Feedback button, it'll redirect to order_details and the rating modal will open automatically |
||
this.redirectToOrderDetails(order_id); | ||
}, | ||
text: localize('Give feedback'), | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added p2p_order_props.order_id in reactions as notifications count would not be updated when the user has completed rating an order and then navigates out of the order-details page. Even though the order_id has been reset to null when unmounting order_details, the p2p_order_props.order_id in showCompletedOrderNotification function doesn't recognise that p2p_order_props has been updated and won't refresh the notifications. Hence I needed to check it here and refresh the notifications here.