ClientsCart.jsx 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import React from 'react';
  2. import {Avatar, Card, CardContent, CardHeader, Collapse} from "@mui/material";
  3. import {backURL} from "../../../actions/PathDB";
  4. import userDefault from "../../../img/header/userDefault.png";
  5. import {useState} from "react";
  6. import Box from "@mui/material/Box";
  7. import {timeCalc} from "../../ProductPage/timeCalc";
  8. import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
  9. import {ItemAvatar} from "./ItemAvatar";
  10. import {ItemAccordion} from "./ItemAccordion";
  11. export const ClientsCart = ({_id, login, nick, avatar, createdAt, acl}) => {
  12. const [expanded, setExpanded] = useState(false);
  13. const handleExpandClick = () => {
  14. setExpanded(!expanded);
  15. };
  16. return (
  17. <Card
  18. sx={{
  19. boxShadow: 'none',
  20. border: '1px solid #616161',
  21. marginBottom: '20px'
  22. }}
  23. >
  24. <Box
  25. display='flex'
  26. justifyContent='space-between'
  27. alignItems='center'
  28. padding='0 20px 0 10px'
  29. style={{cursor:'pointer'}}
  30. onClick={handleExpandClick}
  31. >
  32. <CardHeader
  33. avatar={
  34. avatar ?
  35. <Avatar
  36. alt="User"
  37. src={avatar?.url && backURL + '/' + avatar.url}
  38. />
  39. :
  40. <Avatar
  41. alt="User"
  42. src={userDefault}
  43. />
  44. }
  45. title={`Login: ${login || 'login'} ${nick ? '| Nick: ' + nick : ''}
  46. ${(acl && Array.isArray(acl) && acl.length > 1) ?
  47. '| Status: ' + acl.slice(1, acl.length).toString() : ''}`
  48. }
  49. subheader={timeCalc(+createdAt || 0)}
  50. />
  51. <ExpandMoreIcon />
  52. </Box>
  53. <Collapse
  54. in={expanded}
  55. timeout="auto"
  56. unmountOnExit
  57. >
  58. <CardContent>
  59. <ItemAvatar avatar={avatar}/>
  60. <ItemAccordion
  61. text={`Login: ${login || 'login'}`}
  62. />
  63. <ItemAccordion
  64. size={'body1'}
  65. text={`${nick ? 'Nick: ' + nick : ''}`}
  66. />
  67. <ItemAccordion
  68. size={'body1'}
  69. text={`${(acl && Array.isArray(acl) && acl.length > 1)
  70. ? 'Status: ' + acl.slice(1, acl.length).toString()
  71. : ''}`
  72. }
  73. />
  74. <ItemAccordion
  75. size={'body1'}
  76. text={'Created at: '+timeCalc(+createdAt || 0)}
  77. />
  78. </CardContent>
  79. </Collapse>
  80. </Card>
  81. )
  82. }