Skip to content

Commit

Permalink
Merge branch 'dev' into prod
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurikam2003 committed Jul 5, 2024
2 parents 4319910 + 16e2b96 commit 2fdcb59
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 41 deletions.
29 changes: 15 additions & 14 deletions client/src/pages/Home/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,30 @@ const HomeHeaderButton = () => {
<Button
label={loggedIn ? 'View Profile' : 'Register Now!'}
isSecondary
// style={{
// margin: '0px',
// height: '100%',
// fontSize: 'unset',
// display: 'flex',
// justifyContent: 'center',
// alignItems: 'center',
// }}
style={{
width: '0.px',
height: '0.px',
fontSize: '0px',
opacity: '0',
margin: '0px',
height: '100%',
fontSize: 'unset',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
// hidden button xD
// style={{
// width: '0.px',
// height: '0.px',
// fontSize: '0px',
// opacity: '0',
// }}
/>
</div>
{/* <div className="mobile-only">
<div className="mobile-only">
<Button
label={loggedIn ? 'View Profile' : 'Register Now!'}
isSecondary
style={{ margin: '0px' }}
/>
</div> */}
</div>
</div>
</Link>
</>
Expand Down
7 changes: 4 additions & 3 deletions client/src/pages/Profile/PageProfileFrosh.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,16 @@ const ProfilePageFroshHeader = ({ editButton }) => {

{!isRegistered ? (
<div className={'profile-not-registered'}>
<h1>You are not registered!</h1>
<h2>You will not be able to participate in F!rosh week events until you register.</h2>
<h1>YOU ARE NOT REGISTERED!</h1>
{/* <h2>You will not be able to participate in F!rosh week events until you register.</h2> */}
<h2>Registration opens soon. Stay tuned!</h2>
<Link
key={'/registration'}
to={'/registration'}
style={{ textDecoration: 'none' }}
className={'no-link-style'}
>
<Button label="Register" style={{}} />
{/* <Button label="Register" style={{}} /> */}
</Link>
</div>
) : null}
Expand Down
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -437,7 +437,7 @@ export const fields = {
'Will you be based in Toronto or the GTA over the summer? (or would you be available for events)',
values: ['Yes', 'No'],
initialSelectedIndex: 0,
isRequiredInput: false,
isRequiredInput: true,
noEdit: false,
localStorageKey: 'registration-summerLocationQuery',
},
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
24 changes: 12 additions & 12 deletions client/src/util/profile-pages.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ function logoutFunction({ dispatch, navigate }) {

export const profilePages = {
notLogin: [
// {
// label: 'Log in',
// icon: LoginIcon,
// iconDark: LoginIconDarkMode,
// path: '/login',
// },
],
login: [
{
label: 'Register',
icon: RegisterIcon,
iconDark: RegisterIconDarkMode,
path: '/registration',
label: 'Log in',
icon: LoginIcon,
iconDark: LoginIconDarkMode,
path: '/login',
},
],
login: [
// {
// label: 'Register',
// icon: RegisterIcon,
// iconDark: RegisterIconDarkMode,
// path: '/registration',
// },
{
label: 'Profile',
icon: ProfileIcon,
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 2fdcb59

Please sign in to comment.