Amber Shopify Project created using ReactJS+React-Redux with GraphQL API integration. Storefront Shopify API: https://github.com/Shopify/shopify-app-js/tree/main/packages/api-clients/storefront-api-client#readme
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NewsLetter.jsx 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import { useState } from 'react';
  2. import bgImage from "../../assets/images/newsletterwallpaper.webp"
  3. import { Box, Button, TextField, InputAdornment, Typography } from '@mui/material';
  4. import customerService from '../../services/CustomerService';
  5. const NewsLetter = () => {
  6. const [email, setEmail] = useState("")
  7. return (
  8. <Box
  9. sx={{
  10. position: 'relative',
  11. width: '100%',
  12. height: 0,
  13. paddingTop: '600px', // This sets the height based on top padding
  14. backgroundImage: `url(${bgImage})`,
  15. backgroundSize: "cover",
  16. backgroundPosition: 'center center',
  17. overflow: 'hidden',
  18. display: "flex",
  19. }}
  20. >
  21. <Box
  22. sx={{
  23. position: 'absolute',
  24. top: 0,
  25. left: 0,
  26. width: '100%',
  27. height: '100%',
  28. display: 'flex',
  29. backgroundColor: 'rgba(50, 50, 50, 0.1)', // Filter overlay
  30. flexDirection: 'column',
  31. justifyContent: 'center',
  32. alignItems: 'center',
  33. color: '#fff', // Text and button color for visibility
  34. }}
  35. >
  36. <Box sx={{
  37. width: { xs: "80%", md: "40%" },
  38. backgroundColor: "rgba(255,255,255, 0.8)",
  39. px: 14,
  40. py: 8,
  41. textAlign: "center",
  42. color: "black"
  43. }}>
  44. <Typography variant='h5' sx={{fontWeight:"500", fontSize:"1.8rem !important", pb:2}}>
  45. Let's stay in touch
  46. </Typography>
  47. <Typography variant='body1' sx={{fontSize:{xs:"0.875rem", sm:"0.875rem", md:"1rem" }}}>
  48. Enjoy 15% off your first order when you join our mailing list.
  49. </Typography>
  50. <TextField
  51. label="Enter your email address"
  52. variant="outlined"
  53. fullWidth
  54. value={email}
  55. type='email'
  56. onChange={(e) => { setEmail(e.target.value) }}
  57. sx={{
  58. backgroundColor: "white",
  59. overflow:"hidden",
  60. borderRadius:"4px",
  61. my: 4,
  62. '& .MuiInputLabel-root': {
  63. fontSize: {
  64. xs: "12px",
  65. sm: "12px",
  66. md: "16px"
  67. },
  68. },
  69. }}
  70. InputProps={{
  71. endAdornment: (
  72. <InputAdornment position="end">
  73. <Button
  74. variant="contained"
  75. color="primary"
  76. sx={{
  77. height: "100%",
  78. borderTopLeftRadius: 0,
  79. borderBottomLeftRadius: 0,
  80. position: "absolute",
  81. right: 0
  82. }}
  83. onClick={() => {
  84. const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
  85. if (!email || email.trim() === "") {
  86. alert("Email is required");
  87. return;
  88. }
  89. if (!emailRegex.test(email)) {
  90. alert("Invalid Email");
  91. return;
  92. }
  93. if(customerService.createCustomer({
  94. "email": email,
  95. "firstName": email,
  96. "lastName": "customer",
  97. "password": "securePassword123"
  98. })){
  99. alert(`SUCCESS ADD: ${email}`)
  100. setEmail('')
  101. }else{
  102. alert("ALREADY ADDED");
  103. }
  104. }}
  105. >
  106. Subscribe
  107. </Button>
  108. </InputAdornment>
  109. )
  110. }}
  111. />
  112. <Typography variant='body1' sx={{fontSize:{xs:"0.875rem", sm:"0.875rem", md:"1rem" }}}>
  113. We respect your privacy, so we never share your info.
  114. </Typography>
  115. </Box>
  116. </Box>
  117. </Box>
  118. );
  119. };
  120. export default NewsLetter;