Skip to content

Commit

Permalink
Configuring stripe payments and fixing some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurikam2003 committed Jul 5, 2024
1 parent 1ede00b commit 4c084dc
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 11 deletions.
2 changes: 1 addition & 1 deletion client/src/pages/Registration/RegistrationFields.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ export const fields = {
scuntInfo: {
type: 'label',
label:
"What is Havenget Scunt? Havenger Scunt is a scavenger hunt around the city of Toronto! Don't miss out on one of the most popular f!rosh week events! Scunt is an exciting night of challenges for all comfort levels.",
"What is Havenger Scunt? Havenger Scunt is a scavenger hunt around the city of Toronto! Don't miss out on one of the most popular f!rosh week events! Scunt is an exciting night of challenges for all comfort levels.",
isBold: true,
},
attendingNiteLifeCarnival: {
Expand Down
51 changes: 48 additions & 3 deletions client/src/pages/Registration/RegistrationForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,70 @@ const PageRegistrationForm = ({ editFieldsPage, initialValues, onEditSubmit }) =
const handleRegister = async () => {
setCanRegister(false);
const isFormValid = validateForm();
// console.log(isFormValid)
if (!isFormValid) {
return setCanRegister(true);
} else {
try {

const convertedFroshObject = { ...froshObject };

// Convert string values to booleans
if (convertedFroshObject.attendingScunt === 'Yes') {
convertedFroshObject.attendingScunt = true;
} else if (convertedFroshObject.attendingScunt === 'No') {
convertedFroshObject.attendingScunt = false;
}

if (convertedFroshObject.photograph === 'Yes') {
convertedFroshObject.photograph = true;
} else if (convertedFroshObject.photograph === 'No') {
convertedFroshObject.photograph = false;
}

if (convertedFroshObject.accommodation === 'Yes') {
convertedFroshObject.accommodation = true;
} else if (convertedFroshObject.accommodation === 'No') {
convertedFroshObject.accommodation = false;
}

if (convertedFroshObject.summerLocationQuery === 'Yes') {
convertedFroshObject.summerLocationQuery = true;
} else if (convertedFroshObject.summerLocationQuery === 'No') {
convertedFroshObject.summerLocationQuery = false;
}

let formData = new FormData();
for (const [key, value] of Object.entries(froshObject)) {
for (const [key, value] of Object.entries(convertedFroshObject)) {
if (value === undefined) continue;
formData.append(key, value);
}
froshObject['id'] = user.id;
// for (let [key, value] of formData.entries()) {
// console.log(`${key}: ${value}`);
// }
convertedFroshObject['id'] = user.id;
const ReactPDF = await import('@react-pdf/renderer');
const { MakeReceipt } = await import('../../components/MakeReceipt/MakeReceipt');
const dataReceipt = await ReactPDF.pdf(MakeReceipt(froshObject)).toBlob();
const dataReceipt = await ReactPDF.pdf(MakeReceipt(convertedFroshObject)).toBlob();
formData.append('dataReceipt', dataReceipt);
// console.log(formData)
// console.log("form data executed")
const response = await axios.post('/frosh/register', formData, {
headers: { 'content-type': 'multipart/form-data' },
});
// console.log("response executed")
// console.log(response.data.url)
window.location.href = response.data.url;
} catch (error) {
// console.error('Error message:', error.message);
// console.error('Error code:', error.code);
// console.error('Request config:', error.config);
// console.error('Request data:', error.config.data);
// if (error.response) {
// console.error('Response data:', error.response.data);
// console.error('Response status:', error.response.status);
// console.error('Response headers:', error.response.headers);
// }
console.log(error);
setCanRegister(true);
}
Expand Down
2 changes: 1 addition & 1 deletion server/src/middlewares/errorResponseMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function errorResponseMiddleware(err, req, res, next) {
} else if (err.errors) {
// TODO: finish error handling when implementing proper backend validation
statusCode = 400;
errorMessage = 'Please provide your full name.';
errorMessage = err.message;
} else if (err.message === 'INVALID_EMAIL') {
statusCode = 400;
errorMessage = 'Please submit a valid email address.';
Expand Down
8 changes: 2 additions & 6 deletions server/src/models/FroshModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,8 @@ const FroshSchema = new mongoose.Schema(
type: Boolean, // true is attending scunt, false is not attending
required: true,
},
summerLocationCity: {
type: String,
required: true,
},
summerLocationCountry: {
type: String,
summerLocationQuery: {
type: Boolean,
required: true,
},
moveToToronto: {
Expand Down

0 comments on commit 4c084dc

Please sign in to comment.