Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

OrderSummaryCard.jsx 2.3KB

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