Comments (4)
can I see the code?
from react-challenge-amazon-clone.
this one is reducer.js file
export const initialState = {
basket: [],
user : null
};
export const getBasketTotal = (basket) =>
basket?.reduce((amount,item) => item.price+amount,0);
/export const getBasketTotal = (basket) => {
const total = basket
.map((item) => item.price)
.reduce((acc, value) => acc - value, 0);
return total;
};/
const reducer = (state, action) => {
switch (action.type) {
case "ADD_TO_BASKET":
return {
...state,
basket : [...state.basket, action.item],
};
default:
return state;
}
};
export default reducer;
from react-challenge-amazon-clone.
checkout.js >>>> here suybtotall.js file is called.
function Checkout() {
const [{ basket, user }, dispatch] = useStateValue();
return (
<div>
<h3>Hello, { user?.email}</h3>
<h2 className="checkout_title">Your shopping Basket</h2>
{basket.map(item => (
<CheckoutProduct
id={item.id}
title={item.title}
image={item.image}
price={item.price}
rating={item.rating}
/>
))}
</div>
</div>
<div className="checkout_right">
<Subtotall />
</div>
</div>
);
}
export default Checkout;
from react-challenge-amazon-clone.
subtotall.js file >>>>
unction Subtotall() {
const history = useNavigate();
const [{ basket}, dispatch] = useStateValue();
return (
<CurrencyFormat
renderText={(value) => (
<>
Subtotal ({basket.length} items) : value
This order contains a gift
</>
)}
decimalScale={2}
value = {getBasketTotal(basket)} //error exist here
displayType={"text"}
thousandSeparator={true}
prefix={"₹"}
/>
<button onClick={e => history('/payment')}>Proceed to Checkout and Check Total Price </button>
export default Subtotall;
from react-challenge-amazon-clone.
Related Issues (20)
- CardElement is just appearing once on in the from after refreshing or redirecting to tha payment page it gets disappear
- payment is not happening as post request is giving 404 error
- StateProvider.js
- link HOT 1
- Uncaught (in promise) FirebaseError: Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore
- export const getBasketTotal = (basket) => basket?.reduce((amount, item) => item.price + amount, 0); getting an error price is not summing it just add items price which is recently added in basket
- Can anyone tell me how to deploy free on firebase because I'm getting an error Your project clone-8f487 must be on the Blaze (pay-as-you-go) plan to complete this command. Required API cloudbuild.googleapis.com can't be enabled until the upgrade is complete. To upgrade, visit the following URL: HOT 2
- Problem to run Code
- Need a help with connection to basket HOT 3
- react-router-dom only works on reload
- ERROR in ./src/Login.js export 'useHistory' (imported as 'useHistory') was not found in 'react-router-dom' HOT 5
- Linking issue at 1:47:00 HOT 1
- CardElement not showing in ordersPage
- Errors and their solutions and also Updated Amazon Clone according to react-router-dom v6 and new firebase version HOT 3
- Stripe payment HOT 1
- Issue in after processing the card details the stripe details is not shown in the stripe dashboard.
- Firebase hosting site is being deployed
- ERROR in ./src/firebase.js - npm start HOT 6
- Facing issue with reducer.js and it is necessary to add webpack as one of the solution suggest to use webpack
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-challenge-amazon-clone.