Skip to content
This repository was archived by the owner on Mar 4, 2022. It is now read-only.

Commit b00f5f4

Browse files
committed
Added organizer navbar
1 parent 6bb7c79 commit b00f5f4

File tree

6 files changed

+52
-26
lines changed

6 files changed

+52
-26
lines changed

backend/config/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
require('dotenv').config();
1+
// require('dotenv').config();
2+
require('dotenv').config({ path: '../../.env' });
23

34
const env = process.env;
45

backend/utils/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ export const uploadToStorage = async (
7777
if (!file) return 'No image file';
7878
else if (
7979
folder === 'pictures' &&
80-
!file.originalname.match(/\.(jpg|jpeg|png|gif)$/)
80+
!file.originalname.match(/\.(jpg|jpeg|png|gif)$/i)
8181
)
8282
return `File: ${file.originalname} is an invalid image type`;
83-
else if (folder === 'resume' && !file.originalname.match(/\.(png|PNG)$/))
83+
else if (folder === 'resumes' && !file.originalname.match(/\.(pdf)$/i))
8484
return `File: ${file.originalname} is an invalid image type`;
8585

8686
const fileName = `${folder}/${user.email.replace('@', '_')}`;
@@ -99,9 +99,14 @@ export const uploadToStorage = async (
9999
reject('Something is wrong! Unable to upload at the moment.');
100100
});
101101

102+
// blobStream.on('finish', () => {
103+
// // The public URL can be used to directly access the file via HTTP.
104+
// fileUpload.getMetadata().then(meta => resolve(meta['0'].mediaLink));
105+
// });
106+
102107
blobStream.on('finish', () => {
103108
// The public URL can be used to directly access the file via HTTP.
104-
fileUpload.getMetadata().then(meta => resolve(meta['0'].mediaLink));
109+
resolve(`https://storage.googleapis.com/purduehackers/${fileName}`);
105110
});
106111

107112
blobStream.end(file.buffer);

frontend/src/components/App/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class App extends Component {
7171
const { token, user } = this.props;
7272
return (
7373
<React.Fragment>
74-
<Navigation auth={!!token} id={user ? user._id : null} />
74+
<Navigation auth={!!token} id={user ? user._id : null} user={user} />
7575
<div className="pageWrap">
7676
<FlashMessage />
7777
<Switch>
@@ -166,5 +166,8 @@ const mapStateToProps = state => ({
166166
});
167167

168168
export default withRouter(
169-
connect(mapStateToProps, { storageChanged, clearFlashMessages, fetchProfile })(App)
169+
connect(
170+
mapStateToProps,
171+
{ storageChanged, clearFlashMessages, fetchProfile }
172+
)(App)
170173
);

frontend/src/components/Common/Navbar.js

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { Link } from 'react-router-dom';
4-
import { Nav, Navbar, NavItem } from 'react-bootstrap';
4+
import { Nav, Navbar, NavItem, NavDropdown, MenuItem } from 'react-bootstrap';
5+
import routes, { hasPermission } from '../../constants';
56

67
const CommonNav = () => (
78
<React.Fragment>
8-
<NavItem href="/members">Members</NavItem>
9-
<NavItem href="/events">Events</NavItem>
10-
<NavItem href="/calendar">Calendar</NavItem>
9+
<NavItem href={routes.MEMBERS}>Members</NavItem>
10+
<NavItem href={routes.EVENTS}>Events</NavItem>
11+
<NavItem href={routes.CALENDAR}>Calendar</NavItem>
1112
</React.Fragment>
1213
);
1314

14-
const PHNavbar = ({ auth, id }) => (
15-
<Navbar collapseOnSelect bsStyle="default" style={{ marginBottom: '10px' }}>
15+
const PHNavbar = ({ auth, id, user }) => (
16+
<Navbar collapseOnSelect bsStyle="default" style={{ marginBottom: '10px', maxWidth: '100%' }}>
1617
<Navbar.Header>
1718
<Navbar.Brand>
1819
<Link id="nav-brand" to="/">
@@ -26,19 +27,32 @@ const PHNavbar = ({ auth, id }) => (
2627
<Nav pullRight>
2728
{auth && id ? (
2829
<React.Fragment>
29-
<li>
30+
<li role="presentation">
3031
<Link to={`/member/${id}`}>Profile</Link>
3132
</li>
3233
<CommonNav />
33-
<li>
34-
<Link to="/logout">Logout</Link>
34+
<NavDropdown title="Organizers" id="protected-nav-dropdown">
35+
<style>{`.privateItem a {padding-top: 5px !important;}`}</style>
36+
{hasPermission(user, 'permissions') && (
37+
<MenuItem className="privateItem" href={routes.PERMISSIONS}>
38+
Permissions
39+
</MenuItem>
40+
)}
41+
{hasPermission(user, 'credentials') && (
42+
<MenuItem className="privateItem" href={routes.CREDENTIALS}>
43+
Credentials
44+
</MenuItem>
45+
)}
46+
</NavDropdown>
47+
<li role="presentation">
48+
<Link to={routes.LOGOUT}>Logout</Link>
3549
</li>
3650
</React.Fragment>
3751
) : (
3852
<React.Fragment>
3953
<CommonNav />
40-
<NavItem href="/login">Login</NavItem>
41-
<NavItem href="/signup">Join</NavItem>
54+
<NavItem href={routes.LOGIN}>Login</NavItem>
55+
<NavItem href={routes.SIGNUP}>Join</NavItem>
4256
</React.Fragment>
4357
)}
4458
</Nav>

frontend/src/components/Signup/index.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,11 @@ class SignUpPage extends Component {
201201
</span>
202202
</div>
203203
<br />
204-
<label htmlFor="gradYear">
204+
<label htmlFor="graduationYear">
205205
Year of Graduation *
206206
<input
207207
type="number"
208-
name="gradYear"
209-
id="gradYear"
208+
id="graduationYear"
210209
min="1869"
211210
max={new Date().getFullYear() + 20}
212211
placeholder="Graduation Year"
@@ -492,8 +491,11 @@ const mapStateToProps = state => ({
492491
...state.sessionState
493492
});
494493

495-
export default connect(mapStateToProps, {
496-
flash: sendFlashMessage,
497-
clear: clearFlashMessages,
498-
signUp
499-
})(SignUpPage);
494+
export default connect(
495+
mapStateToProps,
496+
{
497+
flash: sendFlashMessage,
498+
clear: clearFlashMessages,
499+
signUp
500+
}
501+
)(SignUpPage);

frontend/src/index.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ body {
1616
/*------------ NAVBAR STYLING ----------------*/
1717

1818
.container {
19-
max-width: 55em;
19+
max-width: 65em;
2020
}
2121

2222
.navbar {
@@ -54,6 +54,7 @@ body {
5454
font-family: MontserratLite, sans-serif !important;
5555
color: #666;
5656
font-size: 1.3em;
57+
/* padding-top: 20px !important; */
5758
padding-top: 20px !important;
5859
-webkit-transition: color 300ms;
5960
-moz-transition: color 300ms;

0 commit comments

Comments
 (0)