Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New sign up page with form completed and major and year dropdown done. #75

Merged
merged 25 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cafa47d
Test run for CircleCI with different cypress version
Jun 19, 2020
d036d4d
Test out CircleCI after changing Cypress version
Jun 19, 2020
3f846e0
Finished the frontend of the sign up page, besides making HTTP reques…
Jun 23, 2020
08f8c57
Forgot to integrate the cypress+circleci bug fix lol mb
Jun 23, 2020
2fe0d99
Minor fixes to the front end of this new sign up page (first name fie…
Jun 23, 2020
2058bc3
Removed binding statement for handleState in <SignUpPage /> in src/pa…
Jun 23, 2020
3045a41
Test run for CircleCI with different cypress version
Jun 19, 2020
2e62a6e
Finished the frontend of the sign up page, besides making HTTP reques…
Jun 23, 2020
14f5930
Minor fixes to the front end of this new sign up page (first name fie…
Jun 23, 2020
959070c
Removed binding statement for handleState in <SignUpPage /> in src/pa…
Jun 23, 2020
de71729
Finish merging master with newSignupPage
Jun 23, 2020
c551b1c
Finish merging master with newSignupPage
Jun 23, 2020
5430eba
Fixed minor bugs relating to proptypes and props, now just the buggy …
Jun 23, 2020
df153a0
Added major dropdown and generic year dropdown for Formik's <Field />.
Jun 27, 2020
5afc7d3
Added most changes commented on PR #75.
Jun 28, 2020
faa946b
Made more changes in terms of caps and <Grid />.
Jun 28, 2020
a77c04b
Fix casing for dropdowns.
godwinpang Jun 28, 2020
c4d2572
Modified major and year dropdowns so they use Formik's <Field />.
Jun 28, 2020
e4cc0c5
Merge branch 'newSignupPage' of https://github.com/HKN-UCSD/hkn-membe…
Jun 28, 2020
677fd4a
Moved fetch call to /signup in SignUpPageNew to services/auth.
Jul 9, 2020
83b1317
Added base API url as an env var.
Jul 20, 2020
2e0922d
Merge branch 'master' into newSignupPage
thai-truong Jul 23, 2020
b05455b
Ran Prettier to make sure everything complies with Prettier code style.
Jul 23, 2020
6a77b39
Merge branch 'newSignupPage' of https://github.com/HKN-UCSD/hkn-membe…
Jul 23, 2020
db011ea
Removed old signup page and put in new sign up page.
Jul 25, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
758 changes: 393 additions & 365 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
"formik-material-ui-pickers": "0.0.8",
"material-table": "^1.61.0",
"material-ui": "^0.20.2",
"moment": "^2.26.0",
"moment": "^2.27.0",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-app-rewired": "^2.1.5",
"react-app-rewired": "^2.1.6",
"react-dom": "^16.13.1",
"react-router": "^5.1.2",
"react-router-dom": "^5.1.2",
Expand Down Expand Up @@ -56,7 +56,7 @@
"customize-cra": "^0.9.1",
"cypress": "4.5.0",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^18.1.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-react": "^7.20.0",
Expand Down
40 changes: 21 additions & 19 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--

<head>
<meta charset="utf-8">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this file changed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing indentation? Not sure why this was changed, it might have been done by VSCode

Copy link
Collaborator Author

@thai-truong thai-truong Jun 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay yeah it's indentation changes made automatically by VSCode, the actual code is still the same as the original html file.

<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<!--
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Expand All @@ -19,17 +20,17 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Member Portal | Eta Kappa Nu | Kappa Psi - HKN@UCSD</title>
<title>Member Portal | Eta Kappa Nu | Kappa Psi - HKN@UCSD</title>

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
</head>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
</head>

<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

Expand All @@ -39,5 +40,6 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
</body>

</html>
58 changes: 58 additions & 0 deletions src/components/Dropdowns/MajorDropdown/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import * as React from 'react';
import { MenuItem, TextField } from '@material-ui/core';
import { getIn } from 'formik';

import ELIGIBLE_MAJORS from '../../../constants/eligibleMajors';

const createFullMajorTitle = (department, major) => {
let fullMajorTitle = '';

if (ELIGIBLE_MAJORS[department][major] === 'Computer Engineering') {
if (department === 'CSE')
fullMajorTitle = `${ELIGIBLE_MAJORS[department][major]} - CSE`;
else if (department === 'ECE')
fullMajorTitle = `${ELIGIBLE_MAJORS[department][major]} - ECE`;
} else fullMajorTitle = ELIGIBLE_MAJORS[department][major];

return fullMajorTitle;
};

/*
* From https://github.com/stackworx/formik-material-ui/tree/master/packages/formik-material-ui/src (TextField) :p
* This essentially takes the props received at the top-level <Field /> as well
* as the default props for that <Field /> (field, form, meta) and transforms
* all that into a props that is suitable for MUI's <TextField />
*/
export function fieldToTextField({
disabled,
field,
form: { isSubmitting, touched, errors },
...props
}) {
const fieldError = getIn(errors, field.name);
const showError = getIn(touched, field.name) && !!fieldError;

return {
...props,
...field,
error: showError,
helperText: showError ? fieldError : props.helperText,
disabled: disabled ?? isSubmitting,
variant: props.variant,
};
}

const MajorDropdown = props => {
return (
<TextField select {...fieldToTextField(props)}>
{Object.keys(ELIGIBLE_MAJORS).map(department =>
Object.keys(ELIGIBLE_MAJORS[department]).map(major => {
const fullMajorTitle = createFullMajorTitle(department, major);
return <MenuItem value={fullMajorTitle}>{fullMajorTitle}</MenuItem>;
})
)}
</TextField>
);
};

export default MajorDropdown;
54 changes: 54 additions & 0 deletions src/components/Dropdowns/YearDropdown/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import * as React from 'react';
import { MenuItem, TextField } from '@material-ui/core';
import { getIn } from 'formik';

const yearDropdownChoices = (minYear, maxYear) => {
const yearChoices = [];

for (let year = 0; year <= maxYear - minYear; year += 1) {
yearChoices.push(year + minYear);
}

return yearChoices;
};

/*
* From https://github.com/stackworx/formik-material-ui/tree/master/packages/formik-material-ui/src (TextField) :p
* This essentially takes the props received at the top-level <Field /> as well
* as the default props for that <Field /> (field, form, meta) and transforms
* all that into a props that is suitable for MUI's <TextField />
*/
export function fieldToTextField({
disabled,
field,
form: { isSubmitting, touched, errors },
...props
}) {
const fieldError = getIn(errors, field.name);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's getIn?

Copy link
Collaborator Author

@thai-truong thai-truong Jun 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://stackoverflow.com/questions/56089054/how-to-dynamically-access-nested-errors-touched-on-formik-field

This is probably the only thing I found that actually explains what getIn() does lol. I don't know why there is no documentation for it on Formik's official website, even though getIn() is imported from formik.

const showError = getIn(touched, field.name) && !!fieldError;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no bang bang hacks :) just check if it's null or sth idk what getIn returns


return {
...props,
...field,
error: showError,
helperText: showError ? fieldError : props.helperText,
disabled: disabled ?? isSubmitting,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again change to null check for future sustainability - not a big fan of ??

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly that stuff is the stuff that came from formik-material-ui that I didn't touch. I'll change it tho

variant: props.variant,
};
}

const YearDropdown = props => {
const { minyear, maxyear } = fieldToTextField(props);

return (
<TextField select {...fieldToTextField(props)}>
{yearDropdownChoices(minyear, maxyear).map(year => (
<MenuItem key={year} value={year}>
{year}
</MenuItem>
))}
</TextField>
);
};

export default YearDropdown;
2 changes: 1 addition & 1 deletion src/components/EventDetails/Links.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function Links(props) {
Links
</Typography>

<List dense={1}>
<List dense>
<ListItem className={classes.list_item}>
<Link href={rsvp}>
<ListItemText
Expand Down
8 changes: 5 additions & 3 deletions src/components/EventDetails/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ function EventDetailsComponent(props) {
<Typography className={classes.hosts} variant='h6'>
Hosts:{' '}
{hosts.map(host => (
<Typography className={classes.hostName}>{host}</Typography>
<Typography key={host} className={classes.hostName}>
{host}
</Typography>
))}
</Typography>
</Grid>
Expand Down Expand Up @@ -110,8 +112,8 @@ function EventDetailsComponent(props) {

EventDetailsComponent.propTypes = {
eventInfo: PropTypes.shape({
startDate: PropTypes.string.isRequired,
endDate: PropTypes.string.isRequired,
startDate: PropTypes.instanceOf(Date).isRequired,
endDate: PropTypes.instanceOf(Date).isRequired,
hosts: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired,
location: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
Expand Down
18 changes: 15 additions & 3 deletions src/components/EventEditForm/edit_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,21 @@ const EventEditForm = props => {
EventEditForm.propTypes = {
handleSubmit: PropTypes.func.isRequired,
handleCancel: PropTypes.func.isRequired,
initialValues: PropTypes.objectOf(
PropTypes.oneOfType(PropTypes.object, PropTypes.string)
).isRequired,
initialValues: PropTypes.shape({
startDate: PropTypes.instanceOf(Date).isRequired,
endDate: PropTypes.instanceOf(Date).isRequired,
hosts: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired,
location: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
tags: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired,
description: PropTypes.string.isRequired,
urls: PropTypes.shape({
fb: PropTypes.string.isRequired,
canva: PropTypes.string.isRequired,
rsvp: PropTypes.string.isRequired,
signin: PropTypes.string.isRequired,
}),
}).isRequired,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol looking at all these long af proptypes makes me miss typescript

};

export default withStyles(styles)(EventEditForm);
2 changes: 1 addition & 1 deletion src/components/Loading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { LinearProgress as CircularProgress } from '@material-ui/core';

const styles = theme => ({
progress: {
margin: theme.spacing.unit * 3,
margin: theme.spacing(3),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty for fixing

},
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/NavBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class NavBar extends React.Component {
NavBar.contextType = AuthUserContext;

NavBar.propTypes = {
children: PropTypes.objectOf(React.Component).isRequired,
children: PropTypes.node.isRequired,
};

export default compose(withStyles(styles))(NavBar);
Loading