diff --git a/client/src/pages/FroshRetreat/FroshRetreat.jsx b/client/src/pages/FroshRetreat/FroshRetreat.jsx
index 0450ea2a..c5104784 100644
--- a/client/src/pages/FroshRetreat/FroshRetreat.jsx
+++ b/client/src/pages/FroshRetreat/FroshRetreat.jsx
@@ -28,11 +28,11 @@ export const FroshRetreat = () => {
remainingTicketsSetter();
}, []);
- useEffect(() => {
- if (!isRegistered) {
- navigate('/profile');
- }
- }, [isRegistered]);
+ // useEffect(() => {
+ // if (!isRegistered) {
+ // navigate('/profile');
+ // }
+ // }, [isRegistered]);
return (
diff --git a/server/src/controllers/PaymentController.js b/server/src/controllers/PaymentController.js
index 661111db..3fc92bba 100644
--- a/server/src/controllers/PaymentController.js
+++ b/server/src/controllers/PaymentController.js
@@ -68,8 +68,8 @@ const PaymentController = {
'retreat',
);
- const frosh = await FroshServices.addRetreatPayment(user, payment_intent);
- if (!frosh) {
+ const updatedUser = await FroshServices.addRetreatPayment(user, payment_intent);
+ if (!updatedUser) {
res.status(400).send({ message: 'Something went wrong!' });
}
res.status(200).send({ url });
diff --git a/server/src/routes/paymentRoutes.js b/server/src/routes/paymentRoutes.js
index bf0fb26e..b82cfb97 100644
--- a/server/src/routes/paymentRoutes.js
+++ b/server/src/routes/paymentRoutes.js
@@ -18,7 +18,7 @@ router.get(
router.post(
'/frosh-retreat-payment',
checkLoggedIn,
- checkUserType('frosh'),
+ // checkUserType('frosh'),
PaymentController.froshRetreatPayment,
);
diff --git a/server/src/services/FroshServices.js b/server/src/services/FroshServices.js
index 26451f8e..ce32c20b 100644
--- a/server/src/services/FroshServices.js
+++ b/server/src/services/FroshServices.js
@@ -65,23 +65,46 @@ const FroshServices = {
* @returns {User} updated user
*/
async addRetreatPayment(user, paymentIntent) {
- return FroshModel.findByIdAndUpdate(user.id, {
- $push: {
- payments: [
- {
- item: 'Retreat Ticket',
- paymentIntent: paymentIntent.toString(),
- amountDue: 9500,
- },
- ],
- },
- }).then(
- (frosh) => frosh,
- (error) => {
- throw new Error('UNABLE_TO_ADD_PAYMENT', { cause: error });
- },
- );
+ try {
+ const updatedUser = await UserModel.findByIdAndUpdate(user.id, {
+ $push: {
+ payments: [
+ {
+ item: 'Retreat Ticket',
+ paymentIntent: paymentIntent.toString(),
+ amountDue: 9500,
+ },
+ ],
+ },
+ }, { new: true});
+
+ if (!updatedUser){
+ throw new Error('user not found');
+ }
+
+ return updatedUser;
+
+ } catch (error) {
+ throw new Error('UNABLE_TO_ADD_PAYMENT', { cause: error });
+ }
},
+ // return FroshModel.findByIdAndUpdate(user.id, {
+ // $push: {
+ // payments: [
+ // {
+ // item: 'Retreat Ticket',
+ // paymentIntent: paymentIntent.toString(),
+ // amountDue: 9500,
+ // },
+ // ],
+ // },
+ // }).then(
+ // (frosh) => frosh,
+ // (error) => {
+ // throw new Error('UNABLE_TO_ADD_PAYMENT', { cause: error });
+ // },
+ // );
+ // },
/**
* @description Gets the frosh info from ID.