Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

OrderSummaryCard.jsx 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. disableRipple
  35. sx={{
  36. '&.Mui-disabled': {
  37. backgroundColor: '#0066ff',
  38. color: '#fff',
  39. opacity: '0.6',
  40. },
  41. '&:hover': {
  42. backgroundColor: '#0066ff',
  43. color: 'white',
  44. boxShadow: 'none',
  45. },
  46. backgroundColor: '#0066ff',
  47. color: 'white',
  48. textTransform: 'none',
  49. px: 2,
  50. }}
  51. startIcon={
  52. <Image src="/images/lock.svg" alt="lock" width={18} height={18} />
  53. }
  54. disabled={data.totalQuantity > 0 ? false : true}
  55. onClick={() => {
  56. router.push('/checkout');
  57. setCookie(null, 'checkout-session', 'active', {
  58. maxAge: 3600,
  59. expires: new Date(Date.now() + 3600),
  60. path: '/',
  61. });
  62. }}
  63. >
  64. Proceed to Checkout
  65. </Button>
  66. </Box>
  67. <Typography sx={{ mt: 3, fontSize: 13 }}>
  68. Once the checkout process begins you will have an hour to complete your
  69. checkout otherwise you will be returned back to the cart to start over.
  70. </Typography>
  71. </Paper>
  72. );
  73. };
  74. OrderSummaryCard.propTypes = {
  75. data: PropType.shape({
  76. totalPrice: PropType.number,
  77. totalQuantity: PropType.number,
  78. }),
  79. };
  80. export default OrderSummaryCard;