Skip to content

Commit

Permalink
Updates modules to AUG 31 2024, fixes a lot of vulnerabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
samilabud committed Sep 2, 2024
1 parent f5af71a commit 553fca8
Show file tree
Hide file tree
Showing 19 changed files with 7,479 additions and 11,979 deletions.
18,564 changes: 7,024 additions & 11,540 deletions client/package-lock.json

Large diffs are not rendered by default.

69 changes: 34 additions & 35 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,43 @@
"private": true,
"dependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/plugin-transform-private-property-in-object": "^7.23.4",
"@reduxjs/toolkit": "^2.2.1",
"@stripe/react-stripe-js": "^1.7.0",
"@stripe/stripe-js": "^1.25.0",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"axios": "^1.6.7",
"firebase": "^10.8.1",
"@babel/plugin-transform-private-property-in-object": "^7.24.7",
"@reduxjs/toolkit": "^2.2.7",
"@stripe/react-stripe-js": "^2.8.0",
"@stripe/stripe-js": "^4.4.0",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"axios": "^1.7.6",
"firebase": "^10.13.1",
"lodash.memoize": "^4.1.2",
"node-sass": "^9.0.0",
"postcss": "^8.4.41",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-redux": "^7.2.2",
"react-router-dom": "^5.2.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-redux": "^9.1.2",
"react-router-dom": "^6.26.1",
"react-scripts": "5.0.1",
"react-stripe-checkout": "^2.6.3",
"redux": "^4.0.5",
"redux": "^5.0.1",
"redux-logger": "^3.0.6",
"redux-persist": "^6.0.0",
"redux-saga": "^1.1.3",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"styled-components": "^5.2.3",
"web-vitals": "^0.2.4",
"workbox-background-sync": "^5.1.3",
"workbox-broadcast-update": "^5.1.3",
"workbox-cacheable-response": "^5.1.3",
"workbox-core": "^5.1.3",
"workbox-expiration": "^5.1.3",
"workbox-google-analytics": "^5.1.3",
"workbox-navigation-preload": "^5.1.3",
"workbox-precaching": "^5.1.3",
"workbox-range-requests": "^5.1.3",
"workbox-routing": "^5.1.3",
"workbox-strategies": "^5.1.3",
"workbox-streams": "^5.1.3"
"redux-saga": "^1.3.0",
"redux-thunk": "^3.1.0",
"reselect": "^5.1.1",
"styled-components": "^6.1.13",
"web-vitals": "^4.2.3",
"workbox-background-sync": "^7.1.0",
"workbox-broadcast-update": "^7.1.0",
"workbox-cacheable-response": "^7.1.0",
"workbox-core": "^7.1.0",
"workbox-expiration": "^7.1.0",
"workbox-google-analytics": "^7.1.0",
"workbox-navigation-preload": "^7.1.0",
"workbox-precaching": "^7.1.0",
"workbox-range-requests": "^7.1.0",
"workbox-routing": "^7.1.0",
"workbox-strategies": "^7.1.0",
"workbox-streams": "^7.1.0"
},
"scripts": {
"start": "react-scripts --max_old_space_size=400 start",
Expand All @@ -68,8 +67,8 @@
]
},
"devDependencies": {
"sass": "^1.71.1",
"sass-loader": "^14.1.1",
"webpack": "^5.90.3"
"sass": "^1.77.8",
"sass-loader": "^16.0.1",
"webpack": "^5.94.0"
}
}
113 changes: 54 additions & 59 deletions client/src/App.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,57 @@
import React, {useEffect, lazy, Suspense } from 'react';

import { Route,Switch, Redirect } from 'react-router-dom';
import {connect} from 'react-redux';
import { createStructuredSelector } from 'reselect';

import GlobalStyle from './global.styles';


import { selectCurrentUser } from './redux/user/user.selectors';
import { checkUserSession } from './redux/user/user.actions';

import Header from './components/header/header.component';
import Spinner from './components/spinner/spinner.component';
import ErrorBoundary from './components/error-boundary/error-boundary.component';

//Lazy loading //Incrementing Performance of chunks files
const HomePage = lazy(()=>import('./pages/homepage/homepage.component'));
const ShopPage = lazy(()=>import('./pages/shop/shop.component'));
const CheckoutPage = lazy(()=>import('./pages/checkout/checkout.component'));
const SignInAndSignUp = lazy(()=>import('./pages/signin-and-singup/signin-and-singup.component'));

const App=({checkUserSession,currentUser})=>{
useEffect(()=>{
checkUserSession();
},[checkUserSession])

return(
<div>
import React, { useEffect, lazy, Suspense } from "react";
import { Route, Routes, Navigate } from "react-router-dom";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";

import GlobalStyle from "./global.styles";

import { selectCurrentUser } from "./redux/user/user.selectors";
import { checkUserSession } from "./redux/user/user.actions";

import Header from "./components/header/header.component";
import Spinner from "./components/spinner/spinner.component";
import ErrorBoundary from "./components/error-boundary/error-boundary.component";

// Lazy loading components
const HomePage = lazy(() => import("./pages/homepage/homepage.component"));
const ShopPage = lazy(() => import("./pages/shop/shop.component"));
const CheckoutPage = lazy(() => import("./pages/checkout/checkout.component"));
const SignInAndSignUp = lazy(() =>
import("./pages/signin-and-singup/signin-and-singup.component")
);

const App = ({ checkUserSession, currentUser }) => {
useEffect(() => {
checkUserSession();
}, [checkUserSession]);

return (
<>
<GlobalStyle />

<Switch>
<Header />
<ErrorBoundary>
<Suspense fallback={<Spinner />}>
<Header/>
<Route exact path="/" component={HomePage} />
<Route path="/shop" component={ShopPage} />
<Route exact path="/checkout" component={CheckoutPage} />
<Route exact path="/signin"
render={()=>
currentUser?(
<Redirect to='/' />
):(
<SignInAndSignUp/>
)
}
<Suspense fallback={<Spinner />}>
<Routes>
<Route path="/" element={<HomePage />} />
<Route path="/shop/*" element={<ShopPage />} />
<Route path="/checkout" element={<CheckoutPage />} />
<Route
path="/signin"
element={currentUser ? <Navigate to="/" /> : <SignInAndSignUp />}
/>
</Suspense>
</ErrorBoundary>
</Switch>
</div>
);
}
const mapStateToProps = createStructuredSelector ({
currentUser: selectCurrentUser
})

const mapDispatchToProps = dispatch => ({
checkUserSession: () => dispatch(checkUserSession())
})

export default connect(mapStateToProps,mapDispatchToProps)(App);
</Routes>
</Suspense>
</ErrorBoundary>
</>
);
};

const mapStateToProps = createStructuredSelector({
currentUser: selectCurrentUser,
});

const mapDispatchToProps = (dispatch) => ({
checkUserSession: () => dispatch(checkUserSession()),
});

export default connect(mapStateToProps, mapDispatchToProps)(App);
64 changes: 36 additions & 28 deletions client/src/components/cart-dropdown/cart-dropdown.component.jsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
import React from 'react';
import { connect } from 'react-redux';
import React from "react";
import { connect, useDispatch } from "react-redux";

import CustomButton from '../custom-button/custom-button.component';
import CartItem from '../cart-item/cart-item-component';
import { selectCartItems } from '../../redux/cart/cart.selector';
import { createStructuredSelector } from 'reselect';
import { withRouter } from 'react-router-dom'
import { toggleCartHidden } from '../../redux/cart/cart.actions'
import CustomButton from "../custom-button/custom-button.component";
import CartItem from "../cart-item/cart-item-component";
import { selectCartItems } from "../../redux/cart/cart.selector";
import { createStructuredSelector } from "reselect";
import { toggleCartHidden } from "../../redux/cart/cart.actions";
import { useNavigate } from "react-router-dom";

import './cart-dropdown.styles.scss';
import "./cart-dropdown.styles.scss";

const CartDropDown = ({cartItems, history, dispatch}) => (
<div className='cart-dropdown'>
<div className='cart-items'>
{
cartItems.length ?
cartItems.map(cartItem=>(
<CartItem key={cartItem.id} item={cartItem} />
)
)
:
<span className='empty-message'>Tu carrito esta vacio.</span>
}
</div>
<CustomButton onClick={()=> {history.push('/checkout'); dispatch(toggleCartHidden())}}>GO TO CHECKOUT</CustomButton>
const CartDropDown = ({ cartItems }) => {
const navigate = useNavigate();
const dispatch = useDispatch();

const handleCheckout = () => {
navigate("/checkout");
dispatch(toggleCartHidden());
};

return (
<div className="cart-dropdown">
<div className="cart-items">
{cartItems.length ? (
cartItems.map((cartItem) => (
<CartItem key={cartItem.id} item={cartItem} />
))
) : (
<span className="empty-message">Tu carrito está vacío.</span>
)}
</div>
<CustomButton onClick={handleCheckout}>GO TO CHECKOUT</CustomButton>
</div>
)
);
};

const mapStateToProps = createStructuredSelector ({
cartItems: selectCartItems
})
const mapStateToProps = createStructuredSelector({
cartItems: selectCartItems,
});

export default withRouter(connect(mapStateToProps)(CartDropDown));
export default connect(mapStateToProps)(CartDropDown);
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
import React from 'react';
import React from "react";

import { connect } from 'react-redux';
import { connect } from "react-redux";

import addItem from '../../redux/cart/cart.actions';
import addItem from "../../redux/cart/cart.actions";

import {
CollectionItemContainer,
CollectionFooterContainer,
AddButton,
BackgroundImage,
NameContainer,
PriceContainer
} from './collections-item.styles';
CollectionItemContainer,
CollectionFooterContainer,
AddButton,
BackgroundImage,
NameContainer,
PriceContainer,
} from "./collections-item.styles";

const CollectionItem = ({ item, addItem }) => {
const { name, price, imageUrl } = item;

return (
<CollectionItemContainer>
<BackgroundImage className='image' imageUrl={imageUrl} />
<CollectionFooterContainer>
<NameContainer>{name}</NameContainer>
<PriceContainer>{price}</PriceContainer>
</CollectionFooterContainer>
<AddButton onClick={() => addItem(item)} inverted>
Add to cart
</AddButton>
</CollectionItemContainer>
);
};

const mapDispatchToProps = dispatch => ({
addItem: item => dispatch(addItem(item))
})
const { name, price, imageUrl } = item;

export default connect(null, mapDispatchToProps)(CollectionItem);
return (
<CollectionItemContainer>
<BackgroundImage className="image" imageurl={imageUrl} />
<CollectionFooterContainer>
<NameContainer>{name}</NameContainer>
<PriceContainer>{price}</PriceContainer>
</CollectionFooterContainer>
<AddButton onClick={() => addItem(item)} inverted="true">
Add to cart
</AddButton>
</CollectionItemContainer>
);
};

const mapDispatchToProps = (dispatch) => ({
addItem: (item) => dispatch(addItem(item)),
});

export default connect(null, mapDispatchToProps)(CollectionItem);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from 'styled-components';
import CustomButton from '../custom-button/custom-button.component';
import styled from "styled-components";
import CustomButton from "../custom-button/custom-button.component";

export const CollectionItemContainer = styled.div`
width: 22vw;
Expand Down Expand Up @@ -50,7 +50,7 @@ export const BackgroundImage = styled.div`
background-size: cover;
background-position: center;
margin-bottom: 5px;
background-image: ${({ imageUrl }) => `url(${imageUrl})`};
background-image: ${({ imageurl }) => `url(${imageurl})`};
`;

export const CollectionFooterContainer = styled.div`
Expand All @@ -69,4 +69,4 @@ export const NameContainer = styled.span`
export const PriceContainer = styled.span`
width: 10%;
text-align: right;
`;
`;
Loading

0 comments on commit 553fca8

Please sign in to comment.