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

Ryan #244

Open
wants to merge 67 commits into
base: main
Choose a base branch
from
Open

Ryan #244

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
6cb5308
FRIGGIN FINALLY YEEEEEE
ShreddedPork Mar 3, 2022
016e48b
fixed bootstrap issue
7dunham22 Mar 3, 2022
2961db7
single pizza add-to-cart button renders cart
7dunham22 Mar 3, 2022
a64f106
cart total rounds two decimal places
7dunham22 Mar 3, 2022
43d074b
cleaned up with authentication
bgskinner3 Mar 3, 2022
e256df5
Merge pull request #2 from 2201-GraceShopper-CharmanderChargers/brennan
bgskinner3 Mar 3, 2022
c1cf3e8
Merge branch 'main' of github.com:2201-GraceShopper-CharmanderCharger…
7dunham22 Mar 3, 2022
2c4a140
resolving issues in vs code
bgskinner3 Mar 3, 2022
a357083
Merge pull request #3 from 2201-GraceShopper-CharmanderChargers/brennan
bgskinner3 Mar 3, 2022
a112b07
merging
ShreddedPork Mar 3, 2022
f04220f
Merge pull request #4 from 2201-GraceShopper-CharmanderChargers/tester
ShreddedPork Mar 3, 2022
b465520
Merge branch 'main' of github.com:2201-GraceShopper-CharmanderCharger…
7dunham22 Mar 3, 2022
0c6ba3f
Merge remote-tracking branch 'origin/main' into David
7dunham22 Mar 3, 2022
2ba4be1
working on fixing merge
7dunham22 Mar 3, 2022
53eb70e
fixed the cart table styles
7dunham22 Mar 3, 2022
4937c3f
Merge pull request #7 from 2201-GraceShopper-CharmanderChargers/David
7dunham22 Mar 3, 2022
16cb783
changed PizzaCard to react component => button adds to cart
7dunham22 Mar 3, 2022
c404505
cart formatting and structure
7dunham22 Mar 3, 2022
b6557bd
gratekeeping file and more authorization
bgskinner3 Mar 3, 2022
3713ad2
Merge pull request #8 from 2201-GraceShopper-CharmanderChargers/brennan
bgskinner3 Mar 3, 2022
ecce043
go to checkout button
7dunham22 Mar 3, 2022
9538415
Merge branch 'main' of github.com:2201-GraceShopper-CharmanderCharger…
7dunham22 Mar 3, 2022
43aaa89
stylized forms
ShreddedPork Mar 3, 2022
56f9f91
Merge pull request #9 from 2201-GraceShopper-CharmanderChargers/David
7dunham22 Mar 3, 2022
1b09802
added changes
ShreddedPork Mar 3, 2022
d4d4a02
Merge pull request #10 from 2201-GraceShopper-CharmanderChargers/ryan
ShreddedPork Mar 3, 2022
52fe8f6
Merge branch 'main' of github.com:2201-GraceShopper-CharmanderCharger…
7dunham22 Mar 3, 2022
4306aac
added homepage compoenent and updated the navlink to seperate what a …
bgskinner3 Mar 4, 2022
2e85b0a
button on pizzacard shows overlay for 5 seconds
7dunham22 Mar 4, 2022
0b18ab2
more work on the cart
7dunham22 Mar 4, 2022
c04e3c3
started checkout, fixed routes in navbar to point to a user logged in…
bgskinner3 Mar 4, 2022
7f51d49
checkout cart updated
bgskinner3 Mar 4, 2022
19dfb57
Merge pull request #11 from 2201-GraceShopper-CharmanderChargers/brennan
bgskinner3 Mar 4, 2022
3945906
Merge branch 'main' of github.com:2201-GraceShopper-CharmanderCharger…
7dunham22 Mar 4, 2022
b0b11c4
Merge pull request #12 from 2201-GraceShopper-CharmanderChargers/David
7dunham22 Mar 4, 2022
5923dae
checkout button on cart links to checkout page
7dunham22 Mar 4, 2022
e61d37c
cart icon on navbar with badge indicating quantity
7dunham22 Mar 4, 2022
0b70fea
added icons to links on navbar
7dunham22 Mar 4, 2022
dcb2d45
more navbar icons
7dunham22 Mar 4, 2022
ab16ffb
handled edit user page
ShreddedPork Mar 4, 2022
7e40c20
Merge pull request #13 from 2201-GraceShopper-CharmanderChargers/David
7dunham22 Mar 4, 2022
4be6c79
fixed models added full address, styled the checkoutpage and added li…
bgskinner3 Mar 4, 2022
01215b3
merging
bgskinner3 Mar 4, 2022
aa14606
finishing the merge
bgskinner3 Mar 4, 2022
76d88d2
Merge pull request #14 from 2201-GraceShopper-CharmanderChargers/brennan
bgskinner3 Mar 4, 2022
c148bbb
added david and brennans changes
ShreddedPork Mar 4, 2022
79c9582
modified pkg Json and navbar
ShreddedPork Mar 4, 2022
b36327b
Merge pull request #15 from 2201-GraceShopper-CharmanderChargers/ryan
ShreddedPork Mar 4, 2022
9240a2b
Merge branch 'main' of github.com:2201-GraceShopper-CharmanderCharger…
7dunham22 Mar 4, 2022
42f0da6
added new products and changed cart to render new button when not log…
bgskinner3 Mar 5, 2022
40d5e78
Signup creates new cart as pending order. Adding item to cart creates…
7dunham22 Mar 5, 2022
358129e
fixed the allpizzas page, all cards are now the same hieght and width
bgskinner3 Mar 5, 2022
9273c51
beginning of the filtering, before finsihing going to attempt to conv…
bgskinner3 Mar 5, 2022
148f532
added hooks to the all pizzas view and included the filter options as…
bgskinner3 Mar 6, 2022
51cdfbf
cart updates orderItems. Cart is unique to each user, loads on login.
7dunham22 Mar 6, 2022
7b93a22
fixed some issues with possible injection attacks, as well as added s…
bgskinner3 Mar 6, 2022
bba8fe5
fixed routes associated with linking carts to user profiles
7dunham22 Mar 6, 2022
562dbea
correction: There should be no 'guest' cart. Their orders are only cr…
7dunham22 Mar 6, 2022
022503e
changed user.js in store to auth and added a user.js to store
bgskinner3 Mar 6, 2022
1296879
minior change to routes page
bgskinner3 Mar 6, 2022
c4d477e
link added to confimation of checkout
bgskinner3 Mar 7, 2022
a4d59c9
connected to admin page
bgskinner3 Mar 7, 2022
84b3208
Merge pull request #16 from 2201-GraceShopper-CharmanderChargers/brennan
bgskinner3 Mar 7, 2022
c1acea6
resolved conflicts b/w David and Brennan
7dunham22 Mar 7, 2022
b2d85c6
changed the process for loading the cart. Now it happens on loading t…
7dunham22 Mar 7, 2022
5f73cc8
Merge pull request #17 from 2201-GraceShopper-CharmanderChargers/David
7dunham22 Mar 7, 2022
513c1eb
order history pages and backend
ShreddedPork Mar 7, 2022
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,6 @@ production server to be cluttered up with dev dependencies like
git-tracking to be cluttered with production build files like
`bundle.js`! By doing these steps, we make sure our development and
production environments both stay nice and clean!

"webpack": "^4.16.4",
"webpack-cli": "^3.1.0",
1 change: 1 addition & 0 deletions client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'

import {Navbar} from './components'
import Routes from './routes'
// import 'bootstrap/dist/css/bootstrap.min.css'

const App = () => {
return (
Expand Down
35 changes: 35 additions & 0 deletions client/components/AdminPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React, {useState} from 'react'
import {connect} from 'react-redux'
import { fetchAllUsers } from '../store/users'



class AdminPage extends React.Component {
componentDidMount() {
this.props.fetchAllUsers()
}

render() {
const users = this.props.users

return (
<div>
hello
</div>
)
}
}

const mapState = state => {
return {
users: state.users
}
}

const mapDispatch = dispatch => {
return {
fetchAllUsers: () => dispatch(fetchAllUsers())
}
}

export default connect(mapState, mapDispatch)(AdminPage)
121 changes: 121 additions & 0 deletions client/components/AllPizzas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import React, {useState, useEffect} from 'react'
import PizzaCard from './PizzaCard'
import FilterPizzas from './FilterPizzas'
import axios from 'axios'



const AllPizzas = () => {
// const [loading, setLoading] = useState(true)
const [pizzas, setPizzas] = useState([])
const [typeFilter, setTypeFilter] = useState('')

useEffect(() => {
async function getPizzas() {
try {
const res = await axios.get('/api/pizzas')
const info = res.data
setPizzas(info)
} catch (error) {
console.log('there was a problem')
}
}
getPizzas()
}, [])

const pizzaCities = Array.from(new Set(pizzas.map((el) => {
return el.cityOfPizza
})))

const pizzasToShow = pizzas.filter((pizza) => {
if(typeFilter && typeFilter !== 'All') {
return pizza.cityOfPizza === typeFilter
}
return true
})

return (
<div>
<FilterPizzas pizzaCities={pizzaCities} setSelected={setTypeFilter} />
<div className="allpizzas">
{pizzasToShow.map(pizza => {
return <PizzaCard key={pizza.id} pizza={pizza} />
})}
</div>
</div>
)
}

export default AllPizzas



// import React, {useState, useEffect} from 'react'
// import {connect, useDispatch, useSelector } from 'react-redux'
// import {fetchPizzas} from '../store/pizzas'
// import PizzaCard from './PizzaCard'
// import FilterPizzas from './FilterPizzas'


// Notice that we're exporting the AllPizzas component twice. The named export
// (below) is not connected to Redux, while the default export (at the very
// bottom) is connected to Redux. Our tests should cover _both_ cases.
//useDispatch, useSelector


// export class AllPizzas extends React.Component {
// constructor(props) {
// super(props)

// this.loading = true;

// }


// componentDidMount() {

// this.loading = false
// this.props.fetchPizzas()
// }
// componentDidUpdate(prevprops) {
// if (prevprops.pizzas !== this.props.pizzas) {
// console.log('updated AllPizzas');
// }
// }
// render() {

// const pizzas = this.props.pizzas
// const pizzaCities = Array.from(new Set(pizzas.map((el) => {
// return el.cityOfPizza
// })))



// return this.loading ? (
// <img src="https://fullstackacademy.slack.com/files/U02CSK206LS/F034UU5EYAJ/image.png" />
// ) : (
// <div>
// <FilterPizzas pizzaCities={pizzaCities} />
// <div className="allpizzas">
// {pizzas.map(pizza => {
// return <PizzaCard key={pizza.id} pizza={pizza} />
// })}
// </div>
// </div>
// )
// }
// }

// const mapState = state => {
// return {
// pizzas: state.pizzas
// }
// }

// const mapDispatch = dispatch => {
// return {
// fetchPizzas: () => dispatch(fetchPizzas())
// }
// }

// export default connect(mapState, mapDispatch)(AllPizzas)
37 changes: 37 additions & 0 deletions client/components/Carousel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React, {useState, useEffect } from 'react'
import Carousel from 'react-bootstrap/Carousel'
import { useDispatch, useSelector} from 'react-redux'
import { Link, useHistory } from 'react-router-dom'


const CarouselSlide = props => {
const {pizzas} = props
const history = useHistory()
return (
<div className="carousel">
<Carousel fade controls={false}>
{pizzas.map(pizza => {
return (
<Carousel.Item
interval={1000}
className="carosuelImage"
key={pizza.id}
>

<img className="carouselslide" src={pizza.imageUrl} />

</Carousel.Item>
)
})}
</Carousel>
</div>
)
}

export default CarouselSlide






118 changes: 118 additions & 0 deletions client/components/Cart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import React from 'react'
import {connect} from 'react-redux'
import {Link} from 'react-router-dom'
import Table from 'react-bootstrap/Table'
import Button from 'react-bootstrap/Button';
import {updateOrderItem, deletePizza} from '../store/cart'


class Cart extends React.Component {
constructor(props) {
super(props)
this.loading = true
this.state = {
cart: this.props.cart,
}
this.changeQuantity = this.changeQuantity.bind(this)
this.deletePizza = this.deletePizza.bind(this)
}

changeQuantity(event) {
const pizzaId = Number(event.target.name)
const targetPizza = this.props.cart.filter(pizza => {
return pizza.id === pizzaId
})[0]
targetPizza.quantity = event.target.value
this.props.updateOrderItem(targetPizza)
}

deletePizza(id) {
this.props.deletePizza(id)
}

componentDidMount() {
this.loading = false
this.setState({
cart: this.props.cart
})
}

componentDidUpdate(prevProps) {
if (prevProps.cart !== this.props.cart) {
this.setState({cart: this.props.cart})
}
}

render() {
const pizzas = this.state.cart.length > 0 ? this.state.cart : []
return this.loading ? (
<img src="https://assets.pokemon.com/assets/cms2/img/pokedex/full/004.png" />
) : (
<div id="cart-page">
<div className="cart">
<h1>Cart</h1>
<Table striped border hover>
<thead>
<tr>
<th>Item</th>
<th>Quantity</th>
<th>Subtotal</th>
<th />
</tr>
</thead>
<tbody>
{pizzas.map(pizza => {
return (
<tr key={pizza.id}>
<td>{pizza.name}</td>
<td>
<input
type="number"
name={pizza.id}
className="cart-item-quantity"
value={pizza.quantity}
min="1"
onChange={this.changeQuantity}
/>
</td>
<td>${Math.round(pizza.quantity * pizza.price * 100) / 100}</td>
<td className="delete-pizza" onClick={() => this.deletePizza(pizza.id)}>delete</td>
</tr>
)
})}
<tr><td>Total: </td><td/><td>$
{pizzas.length > 0
? Math.round(
pizzas.reduce((prev, pizza) => {
return prev + pizza.quantity * pizza.price
}, 0) * 100
) / 100
: 0}</td><td/></tr>
</tbody>
</Table>
</div>
<div id="checkout-section">
<div />
<Link to="/checkout" >
<Button variant="success">Checkout!</Button>
</Link>
</div>
</div>
)
}
}

const mapStateToProps = state => {
return {
cart: state.cart
}
}

const mapDispatchToProps = dispatch => {
return {
updateOrderItem: pizza => dispatch(updateOrderItem(pizza)),
deletePizza: id => dispatch(deletePizza(id))
}
}

export default connect(mapStateToProps, mapDispatchToProps)(Cart)
Loading