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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import { Button, Grid, Tab, Tabs, Typography } from '@mui/material';
  2. import { Box } from '@mui/system';
  3. import { useTranslation } from 'next-i18next';
  4. import { useState } from 'react';
  5. import TabPanel from '../tab-panel/TabPanel';
  6. const TabContent = ({
  7. description,
  8. inCart,
  9. price,
  10. category,
  11. addProductToCart,
  12. }) => {
  13. const [value, setValue] = useState(0);
  14. const { t } = useTranslation('products');
  15. const handleChange = (event, newValue) => {
  16. setValue(newValue);
  17. };
  18. function a11yProps(index) {
  19. return {
  20. id: `simple-tab-${index}`,
  21. 'aria-controls': `simple-tabpanel-${index}`,
  22. };
  23. }
  24. return (
  25. <Grid item xs={12} md={6}>
  26. <Tabs
  27. sx={{
  28. '& button:focus': {
  29. borderTop: '1px solid black',
  30. borderLeft: '1px solid black',
  31. borderRight: '1px solid black',
  32. borderRadius: '5px 5px 0 0',
  33. borderBottom: 'none',
  34. },
  35. }}
  36. value={value}
  37. onChange={handleChange}
  38. aria-label="basic tabs example"
  39. >
  40. <Tab
  41. sx={{
  42. width: '50%',
  43. }}
  44. label={t('products:purchase')}
  45. {...a11yProps(0)}
  46. />
  47. <Tab
  48. sx={{ width: '50%' }}
  49. label={t('products:category')}
  50. {...a11yProps(1)}
  51. />
  52. </Tabs>
  53. <TabPanel value={value} index={0}>
  54. <Box flexGrow={2} sx={{ pb: { xs: '70px' } }}>
  55. <Typography>{description}</Typography>
  56. </Box>
  57. <Box
  58. sx={{
  59. display: { xs: 'flex' },
  60. flexDirection: { xs: 'column' },
  61. justifyContent: { xs: 'center' },
  62. alignItems: { xs: 'center', md: 'flex-end' },
  63. }}
  64. >
  65. <Typography mb={2}>${price}</Typography>
  66. <Button
  67. disabled={inCart}
  68. onClick={() => addProductToCart(1)}
  69. sx={{
  70. backgroundColor: '#CBA213',
  71. height: 50,
  72. width: { xs: '300px', md: '150px' },
  73. color: 'white',
  74. }}
  75. >
  76. {inCart ? t('products:in') : t('products:add')}
  77. </Button>
  78. </Box>
  79. </TabPanel>
  80. <TabPanel value={value} index={1}>
  81. <Box sx={{ mb: { xs: '60px' } }}>{category}</Box>
  82. </TabPanel>{' '}
  83. </Grid>
  84. );
  85. };
  86. export default TabContent;