Skip to content

Commit

Permalink
Merge pull request #49 from atlp-rwanda/ft-translate-status
Browse files Browse the repository at this point in the history
translate paid status to pending
  • Loading branch information
sevelinCa authored Jul 25, 2024
2 parents bf06100 + 89cccd6 commit 102bfd8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Components/OrderTracking/orderStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,19 @@ const OrderStatus: React.FC<OrderStatusProps> = ({
const [updateOrderStatus, { isLoading: isUpdating }] =
useUpdateOrderStatusMutation();

useEffect(() => {
if (data && data.status) {
setOrderStatus(data.status);
}
}, [data]);
useEffect(() => {
if (data && data.status) {
const translatedStatus = data.status.toLowerCase() === 'paid' ? 'pending': data.status
setOrderStatus(translatedStatus);
}
}, [data]);

useEffect(() => {
const channel = pusher.subscribe("order-channel");
channel.bind("order-updated", (data: OrderUpdateEvent) => {
if (data.orderId === orderId) {
setOrderStatus(data.status);
const translatedStatus = data.status.toLowerCase() === 'paid' ? 'pending' : data.status;
setOrderStatus(translatedStatus);
}
});

Expand Down

0 comments on commit 102bfd8

Please sign in to comment.