AdminPage.jsx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. import {
  2. Avatar,
  3. BottomNavigationAction,
  4. Button, Card, CardContent, CardHeader, Checkbox, CircularProgress, Collapse,
  5. Container, Divider,
  6. FormControl,
  7. Grid,
  8. InputLabel, MenuItem, Pagination, Select, Switch,
  9. TextField,
  10. useMediaQuery
  11. } from "@mui/material";
  12. import Breadcrumb from "../../components/Breadcrumbs";
  13. import PropTypes from 'prop-types';
  14. import SwipeableViews from 'react-swipeable-views';
  15. import { useTheme } from '@mui/material/styles';
  16. import AppBar from '@mui/material/AppBar';
  17. import Tabs from '@mui/material/Tabs';
  18. import Tab from '@mui/material/Tab';
  19. import Typography from '@mui/material/Typography';
  20. import Box from '@mui/material/Box';
  21. import {useState} from "react";
  22. import PersonIcon from '@mui/icons-material/Person';
  23. import CategoryIcon from '@mui/icons-material/Category';
  24. import AutoAwesomeIcon from '@mui/icons-material/AutoAwesome';
  25. import BottomNavigation from '@mui/material/BottomNavigation';
  26. import AddCircleOutlineIcon from '@mui/icons-material/AddCircleOutline';
  27. import EditIcon from '@mui/icons-material/Edit';
  28. import {CategoryAside} from "../CatalogPage";
  29. import {CFindGoodEdit, CGoodEdit, CSearchPage, FindGoodEdit} from "./GoodTab";
  30. import MyOrdersPage from "../MyOrdersPage";
  31. import {Route} from "react-router-dom";
  32. import {CClients} from "./ClientsTab";
  33. import {CCategoryEdit} from "./CateforyTab";
  34. const defaultTabs = [{icon: PersonIcon, text: 'clients'}, {icon: CategoryIcon, text: 'categories'}, {icon: AutoAwesomeIcon, text: 'products'}]
  35. const IconHeader = ({Icon}) => {
  36. return <Icon style={{marginRight: '10px'}} />
  37. }
  38. function TabPanel(props) {
  39. const { children, value, index, ...other } = props;
  40. return (
  41. <div
  42. role="tabpanel"
  43. hidden={value !== index}
  44. id={`full-width-tabpanel-${index}`}
  45. aria-labelledby={`full-width-tab-${index}`}
  46. {...other}
  47. >
  48. {value === index && (
  49. <Box sx={{ p: 3 }}>
  50. <Typography>{children}</Typography>
  51. </Box>
  52. )}
  53. </div>
  54. );
  55. }
  56. TabPanel.propTypes = {
  57. children: PropTypes.node,
  58. index: PropTypes.number.isRequired,
  59. value: PropTypes.number.isRequired,
  60. };
  61. function a11yProps(index) {
  62. return {
  63. id: `full-width-tab-${index}`,
  64. 'aria-controls': `full-width-tabpanel-${index}`,
  65. };
  66. }
  67. const SelectBlock = ({Block, FindBlock}) => {
  68. const [value, setValue] = useState('create');
  69. return (
  70. <>
  71. <Box sx={{width: '100%', display:'flex', justifyContent: 'center', alignItems: 'center', marginBottom: '20px'}}>
  72. <BottomNavigation
  73. showLabels
  74. sx={{width: '100%'}}
  75. value={value}
  76. onChange={(event, newValue) => {
  77. setValue(newValue);
  78. }}
  79. >
  80. <BottomNavigationAction value={'create'} label="Create" icon={<AddCircleOutlineIcon />} />
  81. <BottomNavigationAction value={'edit'} label="Edit" icon={<EditIcon />} />
  82. </BottomNavigation>
  83. </Box>
  84. {value === 'create' ?
  85. <Block/> : <FindBlock/>
  86. }
  87. </>
  88. )
  89. }
  90. const FullWidthTabs = () => {
  91. const theme = useTheme();
  92. const [value, setValue] = useState(0);
  93. const handleChange = (event, newValue) => {
  94. setValue(newValue);
  95. };
  96. const handleChangeIndex = (index) => {
  97. setValue(index);
  98. };
  99. return (
  100. <Box sx={{ bgcolor: '#fff', width: '100%', borderRadius: '20px', borderTopLeftRadius: '20px', borderTopRightRadius: '20px', overflow: 'hidden'}}>
  101. <AppBar position="static" sx={{boxShadow: 'none'}}>
  102. <Tabs
  103. value={value}
  104. onChange={handleChange}
  105. TabIndicatorProps={{style: {background:'#616161', height: '1px'}}}
  106. textColor="inherit"
  107. sx={{backgroundColor:'#fff', color: '#000'}}
  108. variant="fullWidth"
  109. aria-label="full width tabs example"
  110. >
  111. {defaultTabs.map((item, index) =>
  112. <Tab key={index} icon={<IconHeader Icon={item.icon}/>} iconPosition="start" label={item.text} sx={{borderBottom: '1px solid #dedede'}} {...a11yProps(index)}/>
  113. )}
  114. </Tabs>
  115. </AppBar>
  116. <SwipeableViews
  117. axis={theme.direction === 'rtl' ? 'x-reverse' : 'x'}
  118. index={value}
  119. onChangeIndex={handleChangeIndex}
  120. >
  121. <TabPanel value={value} index={0} dir={theme.direction}>
  122. <CClients/>
  123. </TabPanel>
  124. <TabPanel value={value} index={1} dir={theme.direction}>
  125. <SelectBlock Block={CCategoryEdit} FindBlock={CFindGoodEdit}/>
  126. </TabPanel>
  127. <TabPanel value={value} index={2} dir={theme.direction}>
  128. <SelectBlock Block={CGoodEdit} FindBlock={CFindGoodEdit}/>
  129. </TabPanel>
  130. </SwipeableViews>
  131. </Box>
  132. );
  133. }
  134. const AdminPage = () => {
  135. const matches = useMediaQuery('(max-width:768px)')
  136. return(
  137. <>
  138. <Breadcrumb links={['admin']} title={'Dashboard'}/>
  139. <main style={{backgroundColor: "#f3f3f3", padding: matches ? "20px 0" : "50px 0", minHeight:'300px'}}>
  140. <Container maxWidth="lg">
  141. <FullWidthTabs/>
  142. </Container>
  143. </main>
  144. </>
  145. )
  146. }
  147. export default AdminPage