diff --git a/client/src/pages/Registration/RegistrationFields.jsx b/client/src/pages/Registration/RegistrationFields.jsx index 7eb12d41..a51a7de2 100644 --- a/client/src/pages/Registration/RegistrationFields.jsx +++ b/client/src/pages/Registration/RegistrationFields.jsx @@ -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: { diff --git a/client/src/pages/Registration/RegistrationForm.jsx b/client/src/pages/Registration/RegistrationForm.jsx index 7f5a8fd6..000e1af6 100644 --- a/client/src/pages/Registration/RegistrationForm.jsx +++ b/client/src/pages/Registration/RegistrationForm.jsx @@ -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); } diff --git a/server/src/middlewares/errorResponseMiddleware.js b/server/src/middlewares/errorResponseMiddleware.js index bee91e19..c40d9cd4 100644 --- a/server/src/middlewares/errorResponseMiddleware.js +++ b/server/src/middlewares/errorResponseMiddleware.js @@ -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.'; diff --git a/server/src/models/FroshModel.js b/server/src/models/FroshModel.js index da5f154a..a4563802 100644 --- a/server/src/models/FroshModel.js +++ b/server/src/models/FroshModel.js @@ -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: {