Skip to content

Commit

Permalink
Alerts are still not functional for some reason. Removed link from Na…
Browse files Browse the repository at this point in the history
…vbar.Brand for now.
  • Loading branch information
chardbres committed Dec 6, 2019
1 parent 7bcfd4e commit 0ffdcd0
Show file tree
Hide file tree
Showing 9 changed files with 380 additions and 25 deletions.
367 changes: 346 additions & 21 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"promise": "8.0.1",
"raf": "3.4.0",
"react": "^16.4.2",
"react-alert": "^6.0.0",
"react-bootstrap": "^1.0.0-beta.5",
"react-dom": "^16.4.2",
"react-router-dom": "^4.3.1",
Expand Down
2 changes: 1 addition & 1 deletion src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class App extends Component {
<AuthenticatedRoute user={user} path='/change-password' render={() => (
<ChangePassword alert={this.alert} user={user} />
)} />
<AuthenticatedRoute user={user} exact path='/clubs' render={() => (
<AuthenticatedRoute user={user} exact path='/clubs' render={(props) => (
<Clubs alert={this.alert} user={user} />
)} />
<AuthenticatedRoute user={user} exact path='/clubs/:id' render={(props) => (
Expand Down
3 changes: 2 additions & 1 deletion src/components/AutoDismissAlert/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export default {
// Club crud failure messages
clubCreateFailure: 'Failed to create club! Make sure the club style is filled in, and that the club is unique and try again',
clubCreateSuccess: 'Club was successfully created!',
clubDeleteFailure: 'Failed to delete club! Make sure the club style is filled in, and that the club is unique and try again'
clubDeleteFailure: 'Failed to delete club!',
clubDeleteSuccess: 'Club successfully deleted!'
}
6 changes: 6 additions & 0 deletions src/components/Clubs/Club.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ const Club = props => {
// Removes a single resource via the axios call in api/clubs.js
const destroy = () => {
deleteClub(club._id, props.user)
// Alerts user to successful club deletion
.then(() => alert({
heading: 'Club deleted successfully!',
message: messages.clubDeleteSuccess,
variant: 'success'
}))
.then(() => setDeleted(true))
.catch(error => {
console.error(error)
Expand Down
9 changes: 9 additions & 0 deletions src/components/Clubs/Clubs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ const Clubs = props => {
useEffect(() => {
index(props.user)
.then(res => setClubs(res.data.clubs))
// Attempt at function to sort clubs alphabetically by style upon indexing
.then(clubs.sort(function (a, b) {
if (a.clubs.style < b.clubs.club.style) {
return -1
}
if (a.clubs.style > b.clubs.club.style) {
return 1
}
}))
.catch(console.error)
}, [])

Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const unauthenticatedOptions = (

const Header = ({ user }) => (
<Navbar bg="primary" variant="dark" expand="md">
<Navbar.Brand href="#">
<Navbar.Brand>
Smash Factor: The Ultimate Golf Club Performance Tracker!
</Navbar.Brand>
<Navbar.Toggle aria-controls="basic-navbar-nav" />
Expand Down
12 changes: 12 additions & 0 deletions src/components/Shared/TextAlerts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react'
import '../../index.scss'

const TextAlert = message => {
return (
<div>
{message}
</div>
)
}

export default TextAlert
3 changes: 2 additions & 1 deletion src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@
display: flex;
flex-direction: column;
justify-content: center;
margin-top: 20%;

* {
margin: auto;
margin: 1% auto;
}
}

0 comments on commit 0ffdcd0

Please sign in to comment.