Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsegura committed Dec 20, 2024
1 parent ffa5b25 commit f4a4c4e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 20 deletions.
5 changes: 5 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ const config = {
},
},
},
CheckoutNav: {
screens: {
CheckoutPaygreenReturn: 'paygreen/return',
},
},
},
};

Expand Down
23 changes: 23 additions & 0 deletions src/navigation/checkout/PaygreenReturn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React, { useEffect } from 'react';
import { Text } from 'native-base';
import { useNavigation, useRoute } from '@react-navigation/native';
import { useDispatch } from 'react-redux';

import { checkout } from '../../redux/Checkout/actions';

export default () => {

const route = useRoute();
const dispatch = useDispatch();

const paymentOrderId = route.params.po_id;

useEffect(() => {
dispatch(checkout('', null, false, route.params.po_id));
}, []);

Check failure on line 17 in src/navigation/checkout/PaygreenReturn.js

View workflow job for this annotation

GitHub Actions / Basic tests

React Hook useEffect has missing dependencies: 'dispatch' and 'route.params.po_id'. Either include them or remove the dependency array

// TODO Add a waiting text
return (
<Text>LOADING</Text>
)
}
2 changes: 2 additions & 0 deletions src/navigation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import CheckoutMoreInfos from './checkout/MoreInfos';
import CheckoutPayment from './checkout/Payment';
import CheckoutProductDetails from './checkout/ProductDetails';
import CheckoutSummary from './checkout/Summary';
import CheckoutPaygreenReturn from './checkout/PaygreenReturn';

import CheckoutLoopeat from './checkout/Loopeat';
import CheckoutRestaurant from './checkout/Restaurant';
Expand Down Expand Up @@ -108,6 +109,7 @@ export default {
CheckoutPaymentMethodCashOnDelivery,
CheckoutPaymentMethodEdenred,
CheckoutLoopeat,
CheckoutPaygreenReturn,
AccountHome,
AccountAddressesPage,
AccountOrdersPage,
Expand Down
7 changes: 7 additions & 0 deletions src/navigation/navigators/CheckoutNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,13 @@ const DefaultNav = () => {
title: i18n.t('ZERO_WASTE'),
}}
/>
<RootStack.Screen
name="CheckoutPaygreenReturn"
component={screens.CheckoutPaygreenReturn}
options={{
title: i18n.t('PAYGREEN_RETURN'),
}}
/>
</RootStack.Navigator>
);
};
Expand Down
22 changes: 2 additions & 20 deletions src/redux/Checkout/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1113,24 +1113,6 @@ export function checkout(

const httpClient = selectHttpClient(getState());

if (!validateCart(cart)) {
dispatch(checkoutFailure());
NavigationHolder.dispatch(
CommonActions.navigate({
name: 'Cart',
}),
);
dispatch(
setModal({
show: true,
skippable: true,
content: 'An error occurred, please try again later',
type: 'error',
}),
);
return;
}

if (paygreenPaymentOrderID) {
httpClient
.put(
Expand All @@ -1146,8 +1128,8 @@ export function checkout(
),
},
)
.then(o => dispatch(handleSuccessNav(o)))
.catch(e => dispatch(checkoutFailure(e)));
.then(o => dispatch(handlePaymentSuccess(o)))
.catch(e => dispatch(handlePaymentFailed(e)));

return;
}
Expand Down

0 comments on commit f4a4c4e

Please sign in to comment.