ContactPage.jsx 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. import * as React from 'react';
  2. import PropTypes from 'prop-types';
  3. import Tabs from '@mui/material/Tabs';
  4. import Tab from '@mui/material/Tab';
  5. import Typography from '@mui/material/Typography';
  6. import Box from '@mui/material/Box';
  7. import Breadcrumbs from "../components/Breadcrumbs";
  8. import {useState} from "react";
  9. import {Container, Grid, useMediaQuery} from "@mui/material";
  10. import FacebookIcon from "@mui/icons-material/Facebook";
  11. import InstagramIcon from "@mui/icons-material/Instagram";
  12. import TwitterIcon from "@mui/icons-material/Twitter";
  13. import YouTubeIcon from "@mui/icons-material/YouTube";
  14. import Social from "../components/SocialLink";
  15. import GoogleMap from "../components/GoogleMap";
  16. const defaultAddress = {
  17. 'NEW YORK': {
  18. phones: ['212-371-8500', '212-371-8555'],
  19. address: '9 East 40th Street, 3rd Floor, New York City',
  20. email: ['newyork@gmail.com'],
  21. "social networks": [
  22. {icon: FacebookIcon, url: 'https://www.facebook.com/'},
  23. {icon: InstagramIcon, url: 'https://www.instagram.com/'},
  24. {icon: TwitterIcon, url: 'https://twitter.com/home'},
  25. {icon: YouTubeIcon, url: 'https://www.youtube.com/'},
  26. ],
  27. coordinates: {
  28. lat: 40.751936,
  29. lng: -73.981081
  30. }
  31. },
  32. 'TOKYO':{
  33. phones: ['212-371-8500', '212-371-8555'],
  34. address: 'Япония, 〒162-0044 Tokyo, Shinjuku City, Kikuicho, 20−110 エヌエフ喜久井町',
  35. email: ['tokyo@gmail.com'],
  36. "social networks": [
  37. {icon: FacebookIcon, url: 'https://www.facebook.com/'},
  38. {icon: InstagramIcon, url: 'https://www.instagram.com/'},
  39. {icon: TwitterIcon, url: 'https://twitter.com/home'},
  40. {icon: YouTubeIcon, url: 'https://www.youtube.com/'},
  41. ],
  42. coordinates: {
  43. lat: 35.704015,
  44. lng: 139.721445
  45. }
  46. },
  47. 'LONDON':{
  48. phones: ['212-371-8500', '212-371-8555'],
  49. address: 'Randolph St, London NW1 0TL, Great Britain',
  50. email: ['london@gmail.com'],
  51. "social networks": [
  52. {icon: FacebookIcon, url: 'https://www.facebook.com/'},
  53. {icon: InstagramIcon, url: 'https://www.instagram.com/'},
  54. {icon: TwitterIcon, url: 'https://twitter.com/home'},
  55. {icon: YouTubeIcon, url: 'https://www.youtube.com/'},
  56. ],
  57. coordinates: {
  58. lat: 51.541663,
  59. lng: -0.136698
  60. }
  61. },
  62. 'PARIS':{
  63. phones: ['212-371-8500', '212-371-8555'],
  64. address: '22 Pass. Hébrard, 75010 Paris, France',
  65. email: ['paris@gmail.com'],
  66. "social networks": [
  67. {icon: FacebookIcon, url: 'https://www.facebook.com/'},
  68. {icon: InstagramIcon, url: 'https://www.instagram.com/'},
  69. {icon: TwitterIcon, url: 'https://twitter.com/home'},
  70. {icon: YouTubeIcon, url: 'https://www.youtube.com/'},
  71. ],
  72. coordinates: {
  73. lat: 48.873213,
  74. lng: 2.373185
  75. }
  76. },
  77. }
  78. function TabPanel(props) {
  79. const { children, value, index, ...other } = props;
  80. return (
  81. <div
  82. role="tabpanel"
  83. hidden={value !== index}
  84. id={`simple-tabpanel-${index}`}
  85. aria-labelledby={`simple-tab-${index}`}
  86. {...other}
  87. >
  88. {value === index && (
  89. <Box sx={{ p: 3 }}>
  90. <Typography>{children}</Typography>
  91. </Box>
  92. )}
  93. </div>
  94. );
  95. }
  96. TabPanel.propTypes = {
  97. children: PropTypes.node,
  98. index: PropTypes.number.isRequired,
  99. value: PropTypes.number.isRequired,
  100. };
  101. function a11yProps(index) {
  102. return {
  103. id: `simple-tab-${index}`,
  104. 'aria-controls': `simple-tabpanel-${index}`,
  105. };
  106. }
  107. const AddressItem = ({item}) => {
  108. return (
  109. <>
  110. <Grid padding='50px 40px !important' item xs={12} md={6}>
  111. <Typography
  112. variant="h5"
  113. letterSpacing="2px"
  114. marginBottom='40px'
  115. >
  116. {item[0].toString()}
  117. </Typography>
  118. <Grid color="#616161" container spacing={2}>
  119. <Grid marginBottom='30px' item xs={12} sm={6}>
  120. <Typography
  121. fontSize='13px'
  122. fontWeight='300'
  123. marginBottom='15px'
  124. >
  125. PHONES
  126. </Typography>
  127. {item[1].phones.map(i => <Typography lineHeight='1.7em' fontWeight='400' variant="body1">{i.toString()}</Typography>)}
  128. </Grid>
  129. <Grid marginBottom='30px' item xs={12} sm={6}>
  130. <Typography
  131. fontSize='13px'
  132. fontWeight='300'
  133. marginBottom='15px'
  134. >
  135. ADDRESS
  136. </Typography>
  137. <Typography lineHeight='1.7em' fontWeight='400' variant="body1">{item[1].address}</Typography>
  138. </Grid>
  139. <Grid marginBottom='30px' item xs={12} sm={6}>
  140. <Typography
  141. fontSize='13px'
  142. fontWeight='300'
  143. marginBottom='15px'
  144. >
  145. EMAIL
  146. </Typography>
  147. {item[1].email.map(i => <Typography lineHeight='1.7em' fontWeight='400' variant="body1">{i.toString()}</Typography>)}
  148. </Grid>
  149. <Grid marginBottom='30px' item xs={12} sm={6}>
  150. <Typography
  151. fontSize='13px'
  152. fontWeight='300'
  153. marginBottom='15px'
  154. >
  155. SOCIAL NETWORKS
  156. </Typography>
  157. {(item[1]["social networks"] || []).map(item =>
  158. <Social Icon={item.icon} link={item.url}/>
  159. )}
  160. </Grid>
  161. </Grid>
  162. </Grid>
  163. </>
  164. )
  165. }
  166. const Contact = ({address=defaultAddress}) => {
  167. const matches = useMediaQuery('(max-width:768px)');
  168. const matches2 = useMediaQuery('(max-width:420px)');
  169. const [value, setValue] = useState(0);
  170. const handleChange = (event, newValue) => {
  171. setValue(newValue);
  172. };
  173. return (
  174. <>
  175. <Breadcrumbs links={['contact']}/>
  176. <main style={{backgroundColor: "#f3f3f3", padding: matches ? "20px 0" : "50px 0"}}>
  177. <Container maxWidth="lg">
  178. <Box sx={{ width: '100%' }}>
  179. <Box sx={{ color: "#616161" }}>
  180. <Tabs
  181. value={value}
  182. onChange={handleChange}
  183. aria-label="contact"
  184. textColor="inherit"
  185. variant={matches2 ? "scrollable" : "standard"}
  186. TabIndicatorProps={{style: {background:'#616161', height: '1px'}}}
  187. sx={{fontWeight: 300, marginBottom: '30px'}}
  188. centered
  189. >
  190. {Object.keys(address).map((value, index) => {
  191. return <Tab sx={{borderBottom: '1px solid #dedede'}} label={value.toString()} {...a11yProps(index)} />
  192. })}
  193. </Tabs>
  194. </Box>
  195. {Object.entries(address).map((item, index) => {
  196. return (
  197. <TabPanel value={value} index={index}>
  198. <Grid sx={{backgroundColor: '#fff', padding: '0px 0px', marginLeft: '-10px'}} container spacing={2}>
  199. <AddressItem key={index} item={item} />
  200. <Grid sx={{padding: '0px 0px !important', position: 'relative', height: matches ? '300px': '500px'}} item xs={12} md={6}>
  201. <GoogleMap lat={item[1].coordinates.lat} lng={item[1].coordinates.lng} key={index} />
  202. </Grid>
  203. </Grid>
  204. </TabPanel>
  205. )
  206. })}
  207. </Box>
  208. </Container>
  209. </main>
  210. </>
  211. )
  212. }
  213. export default Contact