generated from Arquisoft/dede_0
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from Arquisoft/Jorge_Carrito
Jorge carrito
- Loading branch information
Showing
18 changed files
with
734 additions
and
184 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Typography } from '@material-ui/core'; | ||
import Button from '@material-ui/core/Button'; | ||
import { Card, CardContent, CardMedia } from '@mui/material'; | ||
import { Rock } from '../shared/shareddtypes'; | ||
import '../css/CartItem.css'; | ||
|
||
type Props = { | ||
item: Rock; | ||
handleAddToCart: (selectedItem: Rock) => void; | ||
handleRemoveFromCart: (id: string) => void; | ||
} | ||
|
||
|
||
const CartItem: React.FC<Props> = ({item, handleAddToCart, handleRemoveFromCart}) => { | ||
|
||
return ( | ||
<Card className="cartItem-ci" sx={{ maxWidth: 500 } }> | ||
<CardContent> | ||
<Typography variant="h5"> | ||
{item.name} | ||
</Typography> | ||
<div className="quantityController-ci"> | ||
<Button | ||
size="small" | ||
disableElevation | ||
variant="contained" | ||
onClick={() => handleRemoveFromCart(item.name)} | ||
>-</Button> | ||
<Typography id="quantity-ci"> | ||
{item.quantityCart + " uds " } | ||
</Typography> | ||
<Button | ||
size="small" | ||
disableElevation | ||
variant="contained" | ||
onClick={() => handleAddToCart(item)} | ||
>+</Button> | ||
</div> | ||
<Typography id="quantity-ci"> | ||
{(item.price * item.quantityCart).toFixed(2) + " €"} | ||
</Typography> | ||
</CardContent> | ||
<CardMedia | ||
className = "img-ci" | ||
component="img" | ||
sx={{ width: 120, maxWidth: 120 }} | ||
image={item.img} | ||
alt={item.name} | ||
/> | ||
</Card> | ||
|
||
|
||
) | ||
}; | ||
|
||
|
||
export default CartItem; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
|
||
import List from '@mui/material/List'; | ||
import ListItemText from '@mui/material/ListItemText'; | ||
import Grid from '@mui/material/Grid'; | ||
|
||
import Button from '@mui/material/Button'; | ||
import '../css/PaymentPage.css' | ||
import { CardContent, Typography } from '@mui/material'; | ||
import { North } from '@mui/icons-material'; | ||
import { useState } from 'react'; | ||
import { Rock } from '../shared/shareddtypes'; | ||
|
||
|
||
type Props = { | ||
cartContent: Rock[]; | ||
setNewCart: (isNewCart: boolean) => void; | ||
}; | ||
|
||
const PaymentPage: React.FC<Props> = ({cartContent, setNewCart}) => { | ||
|
||
const [isPaid, setPaid] = useState(false); | ||
const getTotalPrice = () => cartContent.reduce((sum: number, item) => sum + item.quantityCart * item.price, 0); | ||
|
||
const handlePay = () => { | ||
if(!isPaid) | ||
return; | ||
|
||
setNewCart(true); | ||
setPaid(false); | ||
} | ||
|
||
return ( | ||
<div> | ||
<h1 id='title-payment' >Your BUY</h1> | ||
<div className='paymentpage-payment' > | ||
|
||
<div | ||
id='info-payment' | ||
> | ||
<div id='articles-payment'> | ||
<h1>Articles</h1> | ||
<div> | ||
{ cartContent.map(Rock => ( | ||
<div id="items-payment"> | ||
<h2 id='items-name-payment'>{Rock.name}</h2> | ||
<h2 id='items-quantity-payment'>x{Rock.quantityCart}</h2> | ||
<h2 id='items-total-payment'>{Rock.quantityCart*Rock.price}€</h2> | ||
</div> | ||
)) | ||
} | ||
</div> | ||
</div> | ||
|
||
<div id='bill-payment'> | ||
<h1>Payment summary</h1> | ||
<h2>Cost (no iva): { (getTotalPrice() - (getTotalPrice()*0.21)).toFixed(2) }€</h2> | ||
<h2>Cost: {getTotalPrice().toFixed(2)}€</h2> | ||
|
||
<h2>Cost (shipping costs): {(getTotalPrice()+ 12).toFixed(2)}€</h2> | ||
{/* Aqui cogemos la dir de los pods y sacamos los costes envio */} | ||
</div> | ||
</div> | ||
|
||
{isPaid ? <h1>Purchase made</h1> : null} | ||
|
||
<div id='actionButtons-payment'> | ||
<Button | ||
size="medium" | ||
disableElevation | ||
variant="contained" | ||
disabled={false} | ||
onClick = {() =>{handlePay(); window.location.href = '/home';} | ||
} | ||
> | ||
Home | ||
</Button> | ||
<Button | ||
size="medium" | ||
disableElevation | ||
variant="contained" | ||
disabled={false} | ||
onClick={() => { | ||
setPaid(true); | ||
}} | ||
> | ||
Checkout | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
}; | ||
|
||
export default PaymentPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.