Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

OrderSummaryCard.jsx 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { Button, Divider, Paper, Typography } from '@mui/material';
  2. import { Box } from '@mui/system';
  3. import Image from 'next/image';
  4. import { useRouter } from 'next/router';
  5. import { setCookie } from 'nookies';
  6. import PropType from 'prop-types';
  7. const OrderSummaryCard = ({ data }) => {
  8. const router = useRouter();
  9. return (
  10. <Paper
  11. sx={{ p: 3, width: '100%', mb: 2, backgroundColor: '#f1f1f1' }}
  12. elevation={3}
  13. >
  14. <Typography
  15. sx={{
  16. fontSize: 26,
  17. color: 'primary.main',
  18. textAlign: 'center',
  19. width: '100%',
  20. }}
  21. >
  22. Order Summary
  23. </Typography>
  24. <Typography sx={{ mt: 4 }}>
  25. Items total:${data.totalPrice.toFixed(2)}
  26. </Typography>
  27. <Typography sx={{ mt: 1.5 }}>Shipping Costs: FREE</Typography>
  28. <Typography sx={{ mt: 1.5, mb: 1.5 }}>
  29. Total: ${data.totalPrice.toFixed(2)}
  30. </Typography>
  31. <Divider />
  32. <Box sx={{ textAlign: 'center', mt: 4, width: '100%' }}>
  33. <Button
  34. sx={{
  35. backgroundColor: '#0066ff',
  36. color: 'white',
  37. textTransform: 'none',
  38. px: 2,
  39. }}
  40. startIcon={
  41. <Image src="/images/lock.svg" alt="lock" width={18} height={18} />
  42. }
  43. disabled={data.totalQuantity > 0 ? false : true}
  44. onClick={() => {
  45. router.push('/checkout');
  46. setCookie(null, 'checkout-session', 'active', {
  47. maxAge: 3600,
  48. expires: new Date(Date.now() + 3600),
  49. path: '/',
  50. });
  51. }}
  52. >
  53. Proceed to Checkout
  54. </Button>
  55. </Box>
  56. <Typography sx={{ mt: 3, fontSize: 13 }}>
  57. Once the checkout process begins you will have an hour to complete your
  58. checkout otherwise you will be returned back to the cart to start over.
  59. </Typography>
  60. </Paper>
  61. );
  62. };
  63. OrderSummaryCard.propTypes = {
  64. data: PropType.shape({
  65. totalPrice: PropType.number,
  66. totalQuantity: PropType.number,
  67. }),
  68. };
  69. export default OrderSummaryCard;