ItemFound.jsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import React from 'react';
  2. import {useState} from "react";
  3. import {Button} from "@mui/material";
  4. import Box from "@mui/material/Box";
  5. import {backURL} from "../../../actions/PathDB";
  6. import imgNotFound from "../../../img/catalog/imgNotFound.png";
  7. import Typography from "@mui/material/Typography";
  8. import {CGoodEdit} from "./GoodEdit";
  9. export const ItemFound = ({item:{_id, name, price, images, description, categories}}) => {
  10. let [state, setState] = useState(false)
  11. return (
  12. !state ?
  13. <Button
  14. fullWidth
  15. sx={{
  16. display: 'flex',
  17. justifyContent:'flex-start'
  18. }}
  19. onClick={() => setState(true)}
  20. >
  21. <Box
  22. style={{
  23. display: 'flex',
  24. alignItems: 'center',
  25. marginBottom: '30px'
  26. }}
  27. >
  28. <Box
  29. width='60px'
  30. height='60px'
  31. borderRadius='10px'
  32. overflow='hidden'
  33. marginRight='60px'
  34. position='relative'
  35. >
  36. <img
  37. style={{
  38. position: 'absolute',
  39. top: '0',
  40. left: '0',
  41. width: '100%',
  42. height: '100%',
  43. objectFit: 'cover'
  44. }}
  45. src={images && Array.isArray(images) && images[0]?.url ?
  46. backURL + '/' + images[0].url : imgNotFound
  47. }
  48. alt={name}
  49. />
  50. </Box>
  51. <Box sx={{
  52. display: 'flex',
  53. flexDirection: 'column',
  54. justifyContent: 'space-between',
  55. alignItems: 'flex-start'
  56. }}>
  57. <Typography
  58. color='#000'
  59. letterSpacing='1px'
  60. fontFamily='sarif'
  61. fontWeight='600'
  62. variant='h6'
  63. >
  64. {name || 'no name'}
  65. </Typography>
  66. <Typography
  67. letterSpacing='1px'
  68. variant='body1'
  69. fontWeight='300'
  70. color='#616161'
  71. margin='10px 0'
  72. sx={{textTransform: 'capitalize'}}
  73. >
  74. {description?.length > 60 ?
  75. 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.'
  76. :
  77. description
  78. }
  79. </Typography>
  80. <Typography
  81. color='#000'
  82. letterSpacing='1px'
  83. variant='body1'
  84. fontWeight='600'
  85. >
  86. ${parseFloat(price).toFixed(2)}
  87. </Typography>
  88. </Box>
  89. </Box>
  90. </Button>
  91. :
  92. <Box
  93. sx={{
  94. marginBottom: '30px',
  95. border: '1px solid #616161',
  96. borderRadius: '10px',
  97. padding: '30px 20px'
  98. }}
  99. >
  100. <CGoodEdit
  101. entity={{_id, name, price, images, description, categories}}
  102. />
  103. <Button
  104. variant='outlined'
  105. sx={{marginTop: '30px'}}
  106. fullWidth
  107. onClick={() => setState(false)}
  108. >
  109. Cansel
  110. </Button>
  111. </Box>
  112. )
  113. }