Parcourir la source

rtk_tree_view_cls_trash

Gennadysht il y a 1 an
Parent
commit
de04e6e9f5

+ 1 - 8
src/App.js

@@ -10,18 +10,12 @@ import { CCategory } from './Components/Category';
 import { CCart } from './Components/Cart';
 import { createBrowserHistory } from "history";
 import { PersistGate } from 'redux-persist/integration/react';
-import { Box, Drawer, Paper, Typography } from '@mui/material';
+import { Box, Typography } from '@mui/material';
 import backImage from "./images/theme_main.png"
 
 export const history = createBrowserHistory();
 
 
-//import { cartReducer, actionRestoreCart } from './reducers';
-//store.dispatch(actionAuthLogin(localStorage.authToken));
-//store.dispatch(actionRootCats());
-//store.dispatch(actionRestoreCart());
-
-
 const NotFound = () =>
   <div>
     <h1>404 not found</h1>
@@ -33,7 +27,6 @@ const Main = () =>
     <h1>Main page</h1>
   </Box>
 
-//<EditPost onSave={post => console.log(post)}/>
 function App() {
   return (
     <>

+ 0 - 8
src/App.test.js

@@ -1,8 +0,0 @@
-import { render, screen } from '@testing-library/react';
-import App from './App';
-
-test('renders learn react link', () => {
-  render(<App />);
-  const linkElement = screen.getByText(/learn react/i);
-  expect(linkElement).toBeInTheDocument();
-});

+ 0 - 2
src/Components/AvatarAnimated.js

@@ -17,8 +17,6 @@ export const AvatarAnimated = styled((props) => {
     const { selected, ...other } = props;
     return <AvatarImage {...other} />;
 })(({ theme, selected }) => ({
-    //width: theme.spacing(10),
-    //height: theme.spacing(10),
     transition: theme.transitions.create('transform', {
         duration: theme.transitions.duration.shortest,
     }),

+ 1 - 7
src/Components/Cart.js

@@ -19,13 +19,12 @@ const Cart = () => {
     let goods = useSelector(state => state.cart?.goods) ?? [];
     let { isLoading, data } = useGetGoodsByIdQuery({ goods });
     let goodsData = data?.GoodFind?.map(gd => ({ ...gd, count: mapCountToGood(gd, goods) })) ?? [];
-    let state = useSelector(state => state);
     let order = [];
     for (let good of Object.values(goods)) {
         order.push({ good: { _id: good._id }, count: good.count });
     }
     let currentUser = useSelector(state => getCurrentUser(state));
-    const [addOrderMutation, { isLoading: isOrderAdding, data: orderAddingData }] = useAddOrderMutation();
+    const [addOrderMutation, { isLoading: isOrderAdding }] = useAddOrderMutation();
     return !isLoading && (
         <>
             <Container>
@@ -53,11 +52,6 @@ const Cart = () => {
     )
 }
 const CCart = connect(state => ({
-    /*goods: state.cart.goods,
-    goodsData: state.goods?.goods?.payload,
-    uniqueId: state.cart.uniqueId,*/
-    //...getCart(state)
-    //cart: getCart(state) 
 }),
     {})(Cart);
 

+ 3 - 4
src/Components/Category.js

@@ -1,7 +1,6 @@
 import { List, ListItem, ListItemButton, ListItemText, Button } from "@mui/material"
 import { Typography } from "@mui/material"
 import { Box, Container } from "@mui/system"
-import { useState } from "react"
 import { useEffect } from "react"
 import { connect, useDispatch, useSelector } from "react-redux"
 import { useParams } from "react-router-dom"
@@ -24,7 +23,7 @@ const Category = () => {
     const dispatch = useDispatch();
     let state = useSelector(state => state);
     useEffect(() => {
-        if (getCurrentEntity(frontEndNames.category, state)?._id != _id)
+        if (getCurrentEntity(frontEndNames.category, state)?._id !== _id)
             dispatch(actionSetCurrentEntity(frontEndNames.category, { _id }));
         if (!isLoading)
             dispatch(actionSetCurrentEntity(frontEndNames.category, data.CategoryFindOne));
@@ -57,10 +56,10 @@ const Category = () => {
                                             <ListItemText
                                                 disableTypography
                                                 primary={
-                                                    <Typography paragraph gutterBottom component={'h4'} variant={'h4'} sx={{ marginTop: "1vh", marginLeft: "18vh"}} >
+                                                    <Typography paragraph gutterBottom component={'h4'} variant={'h4'} sx={{ marginTop: "1vh", marginLeft: "18vh" }} >
                                                         {scat.name}
                                                     </Typography>
-                                                } 
+                                                }
                                             />
                                         </MyLink>
                                     </ListItemButton>

+ 2 - 7
src/Components/CategoryList.js

@@ -1,4 +1,4 @@
-import React, { useEffect } from 'react';
+import React from 'react';
 import { Container, Typography, Paper, Avatar, Button } from '@mui/material';
 import { Table, TableBody, TableContainer, TableHead, TableRow } from "@mui/material";
 import { StyledTableCell, StyledTableRow } from './StyledTableElements';
@@ -6,7 +6,7 @@ import { CPagination } from './Pagination';
 import { CSearchInput } from './SearchInput';
 import { MyLink, ReferenceLink } from '.';
 import { useSelector } from 'react-redux';
-import { frontEndNames, getCurrentUser, getEntitiesListShowParams, useGetCategoriesCountQuery, useGetCategoriesQuery, useGetOrdersCountQuery, useGetOrdersQuery } from '../reducers';
+import { frontEndNames, getCurrentUser, getEntitiesListShowParams, useGetCategoriesCountQuery, useGetCategoriesQuery } from '../reducers';
 import { UserEntity } from '../Entities';
 import { getFullImageUrl } from '../utills';
 
@@ -128,11 +128,6 @@ const CCategoriesList = () => {
     const categoriesCountResult = useGetCategoriesCountQuery({ searchStr, owner: currentUser }, { refetchOnMountOrArgChange: true });
     let isLoading = categoriesResult.isLoading || categoriesCountResult.isLoading;
 
-    /*useEffect(() => {
-        categoriesCountResult.refetch();
-    }, [searchStr]);*/
-
-
     let entities = !isLoading && categoriesResult.data?.CategoryFind;
     return !isLoading && <CategoriesList entities={entities} isAdmin={currentUser.isAdminRole} entitiesTypeName={entitiesTypeName} fromPage={fromPage} pageSize={pageSize} />
 }

+ 3 - 17
src/Components/CategoryTree.js

@@ -1,5 +1,4 @@
 import React, { useState } from "react";
-import { Button, Typography } from "@mui/material"
 import { DndProvider } from "react-dnd";
 import {
     Tree,
@@ -37,10 +36,6 @@ export const theme = createTheme({
 });
 
 
-const logTree = (treeData) => {
-    console.log(treeData.map(el => { return { id: el.id, parent: el.parent, text: el.text } }));
-}
-
 const CategoryTree = ({ elements, saveCategory }) => {
     console.log(elements);
     const [treeData, setTreeData] = useState(elements);
@@ -51,14 +46,12 @@ const CategoryTree = ({ elements, saveCategory }) => {
         if (!sourceCat)
             throw new Error("No source");
 
-        if (sourceCat.parent?._id != targetCat?._id) {
+        if (sourceCat.parent?._id !== targetCat?._id) {
             sourceCat.parent = targetCat ? { _id: targetCat._id, name: targetCat.name } : null;
             saveCategory(sourceCat);
             setTreeData(newTree);
-            //logTree(newTree)
         }
     }
-    console.log(styles);
     return (
         <ThemeProvider theme={theme}>
             <CssBaseline />
@@ -98,12 +91,6 @@ const CategoryTree = ({ elements, saveCategory }) => {
     );
 }
 
-/*
-                        /*rootProps={{ style: { listStyleType: 'none' } }}
-                        listComponent="ul"
-                        listItemComponent="li"
-*/
-
 let index = 2;
 function wrapToTreeItems(cats, parentCat = null, catTreeItems = undefined) {
     catTreeItems ??= [];
@@ -137,11 +124,10 @@ const CCategoryTree = () => {
     }
     catTreeItems.push(rootCat);
 
-    const [saveCategoryMutation, { }] = useSaveCategoryMutation(true);
+    const [saveCategoryMutation] = useSaveCategoryMutation(true);
 
     const saveCategory = async (category) => {
-        let res = await saveCategoryMutation({ category });
-        return true;
+        await saveCategoryMutation({ category });
     }
 
     return !isLoading && cats && <CategoryTree elements={wrapToTreeItems(cats, rootCat, catTreeItems)} saveCategory={saveCategory} />

+ 1 - 24
src/Components/CategoryTreeItem.js

@@ -1,5 +1,5 @@
 import React from "react";
-import { Typography, Button, Input, TextField } from "@mui/material";
+import { TextField } from "@mui/material";
 import ArrowRightIcon from "@mui/icons-material/ArrowRight";
 import styles from "./CategoryTreeItem.module.css";
 import ListAltIcon from "@mui/icons-material/ListAlt";
@@ -8,28 +8,11 @@ export const CategoryTreeItem = (props) => {
     const { droppable, data } = props.node;
     const indent = props.depth * 40;
 
-    const classes = {
-        customInput: {
-            fontFamily: '"Comic Sans MS", cursive, sans-serif',
-            fontSize: "0.05em",
-            fontWeight: "bold"
-        },
-    };
-
-
     const handleToggle = (e) => {
         e.stopPropagation();
         props.onToggle(props.node.id);
     };
 
-    /*
-                            <Button sx={{ marginInlineStart: depth * 10 }} label={node.text}>
-                                {node.droppable && (
-                                    <span onClick={onToggle}>{isOpen ? "[-]" : "[+]"}</span>
-                                )}
-                                {node.text}
-                            </Button>
-    */
     return (
         <div
             className={`tree-node ${styles.root}`}
@@ -68,16 +51,10 @@ export const CategoryTreeItem = (props) => {
                         if (e.key === 'Escape') {
                             e.target.value = e.target.defaultValue;
                             console.log('Enter key pressed');
-                            // write your functionality here
-                        }
-                        else if (e.key === 'Enter') {
-                            e.target.focused = false;
                         }
                     }}
                 />
             </div>
         </div>
     );
-    //                <Typography sx={{ fontSize: "larger", fontWeight: "bold" }} size="large" color="primary">{props.node.text}</Typography>
-
 };

+ 0 - 3
src/Components/DropDownList.js

@@ -130,9 +130,6 @@ export const CCategoryDropDownListUnstyled = ({ currentCat, onSetCategory, showC
     let cats = data?.CategoryFind;
     if (!isLoading && cats) {
         cats = wrapToTreeItems(cats);
-        if (cats[10].subCategories?.lenght > 1) {
-            let a = '';
-        }
         let selectedIndex = cats.findIndex(c => c.key == currentCat?._id);
         return <DropDownList elements={cats} selectedIndex={selectedIndex} onSetCategory={onSetCategory} showClearButton={showClearButton} />
     }

+ 1 - 4
src/Components/EditableCategory.js

@@ -1,10 +1,9 @@
 import { useSelector } from "react-redux"
 import { useParams } from "react-router-dom";
 import { Button, Card, CardActions, CardContent, CardMedia, Container, Grid, TextField, Typography } from "@mui/material";
-import { useEffect, useState } from "react";
+import { useState } from "react";
 import { getFullImageUrl, saveImage } from "../utills/utils";
 import { isCurrentUserAdmin, useGetCategoryByIdQuery, useSaveCategoryMutation } from "../reducers";
-import { DeleteOutline, UndoRounded } from "@mui/icons-material";
 import { CCategoryDropDownList } from "./DropDownList";
 
 const EditableCategory = ({ category: categoryExt, maxWidth = 'md', saveCategory }) => {
@@ -29,8 +28,6 @@ const EditableCategory = ({ category: categoryExt, maxWidth = 'md', saveCategory
     const uploadAvatar = async param => {
         let image = await saveImage({ data: param.target.files[0] }, false);
         setCategoryData({ image });
-        /*let categoryToSave = { _id: category._id, name: categoryExt.name || category.name, image: { _id: image._id } };
-        saveCategory({ category: categoryToSave });*/
     }
 
     return category && (

+ 0 - 16
src/Components/EditableGood.js

@@ -177,19 +177,3 @@ const CEditableGood = ({ maxWidth = 'md' }) => {
 
 
 export { CEditableGood }
-
-
-/*-good.categories.map(cat => (
-    <Grid item width="100%">
-        <TextField
-            required
-            id="outlined-required"
-            label="Categories"
-            value={cat.name}
-            onChange={event => setGoodData({ description: event.target.value })}
-            multiline={true}
-            rows={1}
-            fullWidth
-        />
-    </Grid>
-))*/

+ 1 - 1
src/Components/EditableUser.js

@@ -1,5 +1,5 @@
 import { useSelector } from "react-redux"
-import { frontEndNames, getCurrentEntity, getCurrentUser, useSaveUserMutation, useUserFindQuery } from "../reducers";
+import { getCurrentUser, useSaveUserMutation, useUserFindQuery } from "../reducers";
 import { useParams } from "react-router-dom";
 import { Button, Card, CardActions, CardContent, CardMedia, Checkbox, Container, FormControlLabel, FormGroup, Grid, InputAdornment, TextField, Typography } from "@mui/material";
 import { useEffect, useState } from "react";

+ 2 - 46
src/Components/FileDropZone.js

@@ -1,11 +1,10 @@
-import { Paper } from '@mui/material';
 import React, { useCallback, useState } from 'react'
 import { useDropzone } from 'react-dropzone'
 
 function FileDropZone({ onDropFiles }) {
   const [paths, setPaths] = useState([]);
   const onDrop = useCallback(acceptedFiles => {
-    // Do something with the files
+
     acceptedFiles = acceptedFiles.map(f => {
       let url = URL.createObjectURL(f)
       return { _id: null, name: f.path, url, data: f }
@@ -14,7 +13,7 @@ function FileDropZone({ onDropFiles }) {
     setPaths(acceptedFiles);
     onDropFiles(acceptedFiles);
   }, [setPaths])
-  const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop })
+  const { getRootProps, getInputProps } = useDropzone({ onDrop })
   console.log(paths);
   return (
     <>
@@ -23,9 +22,6 @@ function FileDropZone({ onDropFiles }) {
         <div style={{backgroundColor: 'lightgrey', minHeight: '100px', margin:'auto', display: 'inline-block'}} >
           {
             <p>Drop the files here ...</p>
-            /*isDragActive ?
-              <p>Drop the files here ...</p> :
-              <p>Drag 'n' drop some files here, or click to select files</p>*/
         }
         </div>
       </div>
@@ -33,44 +29,4 @@ function FileDropZone({ onDropFiles }) {
   )
 }
 
-const DropZone = ({ isDragActive }) => {
-  <Paper>
-    {
-      isDragActive ?
-        <p>Drop the files here ...</p> :
-        <p>Drag 'n' drop some files here, or click to select files</p>
-    }
-  </Paper>
-
-}
-/*
-              {
-                paths.map(
-                    f => 
-                    <img key={f.name} src={f.url} />
-               )
-            }
-*/
-
-/*export function MyDropzone() {
-  const [paths, setPaths] = useState([]);
-
-  const onDrop = useCallback(acceptedFiles => {
-    setPaths(acceptedFiles.map(file => URL.createObjectURL(file)));
-  }, [setPaths]);
-  const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop });
-
-  return (
-    <div>
-      <div {...getRootProps()}>
-        <input {...getInputProps()} />
-        <p>Drop the files here ...</p>
-      </div>
-      {paths.map(path => 
-        <img key={path} src={path} />
-       )}
-    </div>
-  );
-}*/
-
 export { FileDropZone }

+ 2 - 3
src/Components/Good.js

@@ -5,7 +5,7 @@ import { Container, Typography, Grid, CardActionArea, Card, CardContent, CardMed
 import { getFullImageUrl } from "./../utills";
 import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
 import { AvatarAnimated } from './AvatarAnimated';
-import { actionAddGoodToCart, actionSetCurrentEntity, frontEndNames, getCurrentUser, isCurrentUserAdmin } from '../reducers';
+import { actionAddGoodToCart, isCurrentUserAdmin } from '../reducers';
 import { useDispatch, useSelector } from 'react-redux';
 import { useGetGoodByIdQuery } from '../reducers';
 import { useParams } from 'react-router-dom';
@@ -38,7 +38,7 @@ export const AvatarGroupOriented = styled((props) => {
         marginLeft: 1,
         marginTop: theme.spacing(1),
     },
-    ".MuiAvatar-root": { /*width: 20, height: 20,*/ marginLeft: 1 }
+    ".MuiAvatar-root": { marginLeft: 1 }
 }));
 
 
@@ -157,5 +157,4 @@ const CGood = ({ good, maxWidth = 'md', showAddToCard = true, editable = true })
     let isAdmin = isCurrentUserAdmin(state);
     return isLoading ? <LoadingState /> : <Good good={good} isAdmin={isAdmin} maxWidth={maxWidth} showAddToCard={showAddToCard} editable={editable} actionAddGoodToCart={() => dispatch(actionAddGoodToCart(good))} />
 }
-let a = '';
 export { CGood };

+ 0 - 1
src/Components/LoginForm.js

@@ -1,6 +1,5 @@
 import React, { useState } from 'react';
 import LockOutlinedIcon from '@mui/icons-material/LockOutlined';
-import Button from '@mui/material/Button';
 import { Container, CssBaseline, TextField, Avatar, Typography, FormControlLabel, Checkbox, Grid, Link } from '@mui/material';
 import { Box } from '@mui/system';
 import { connect, useDispatch } from 'react-redux';

+ 2 - 2
src/Components/MainAppBar.js

@@ -17,11 +17,11 @@ import LoginIcon from '@mui/icons-material/Login';
 import CategoryIcon from '@mui/icons-material/Category';
 import SupervisedUserCircleIcon from '@mui/icons-material/SupervisedUserCircle';
 import WorkHistoryIcon from '@mui/icons-material/WorkHistory';
-import { Badge, Paper, Tooltip } from '@mui/material';
+import { Badge, Tooltip } from '@mui/material';
 import logo from '../images/logo.jpg';
 import AccountTreeIcon from '@mui/icons-material/AccountTree';
+
 const MainAppBar = ({ token, openSidebar }) => {
-    const theme = useTheme();
     const cartItemsCount = useSelector(state => getCartItemsCount(state) ?? 0);
     let currentUser = useSelector(state => new UserEntity(state.auth?.currentUser ?? { _id: null }));
     let isAdmin = currentUser?.isAdminRole === true;

+ 1 - 1
src/Components/ModalContainer.js

@@ -33,7 +33,7 @@ const ModalContainer = ({ children, onCloseClick }) =>
   <ModalOverlay>
     <Modal>
       <ModalClose onClick={onCloseClick}>
-        &#10005; {/* HTML code for a multiplication sign */}
+        &#10005; {}
       </ModalClose>
       {children}
     </Modal>

+ 3 - 4
src/Components/Order.js

@@ -1,11 +1,10 @@
-import React, { useEffect } from 'react';
+import React from 'react';
 import { Typography } from "@mui/material"
 import { Box, Container } from "@mui/system"
-import { connect, useDispatch, useSelector } from "react-redux"
-import { actionOrderFindOne, getCurrentOrder, useGetOrderByIdQuery } from "../reducers/ordersReducer"
+import { useSelector } from "react-redux"
+import { useGetOrderByIdQuery } from "../reducers/ordersReducer"
 import { OrderGoodsList } from "./OrderGoodsList"
 import { useParams } from 'react-router-dom/cjs/react-router-dom';
-import { actionSetCurrentEntity, frontEndNames } from '../reducers/frontEndReducer';
 import { MyLink } from './MyLink';
 import { getCurrentUser } from '../reducers';
 import { UserEntity } from '../Entities';

+ 1 - 4
src/Components/OrderGood.js

@@ -1,8 +1,6 @@
-import { Paper, Avatar, Box, Container, Grid, Table, TableBody, TableContainer, TableHead, TableRow, TableCell, tableCellClasses, Typography } from "@mui/material";
-import { Good } from "./Good";
+import { Typography } from "@mui/material";
 import { getFullImageUrl } from "./../utills";
 import { AvatarImage } from "./AvatarAnimated";
-import { styled } from '@mui/material/styles';
 import { StyledTableCell, StyledTableRow } from "./StyledTableElements";
 import "./orderGood.css"
 import { MyLink } from "./MyLink";
@@ -51,7 +49,6 @@ const OrderGood = ({ orderGood, orderGoodNum }) => {
                     </Typography>
                 </StyledTableCell>
             </StyledTableRow>
-            {/*<Good good={{ ...orderGood.good, ...orderGood }} showAddToCard={false} />*/}
         </>
     )
 }

+ 2 - 2
src/Components/OrderList.js

@@ -1,8 +1,8 @@
 import React from 'react';
-import { Container, Typography, Paper, Link } from '@mui/material';
+import { Container, Typography, Paper } from '@mui/material';
 import { Table, TableBody, TableContainer, TableHead, TableRow } from "@mui/material";
 import { StyledTableCell, StyledTableRow } from './StyledTableElements';
-import { COrdersPagination, CPagination } from './Pagination';
+import { CPagination } from './Pagination';
 import { CSearchInput } from './SearchInput';
 import { MyLink, ReferenceLink } from '.';
 import { useSelector } from 'react-redux';

+ 3 - 5
src/Components/RegisterForm.js

@@ -1,15 +1,13 @@
 import React, { useState } from 'react';
 import LockOutlinedIcon from '@mui/icons-material/LockOutlined';
-import { Container, CssBaseline, TextField, Avatar, Typography, FormControlLabel, Checkbox, Grid, Link } from '@mui/material';
+import { Container, CssBaseline, TextField, Avatar, Typography, FormControlLabel, Checkbox } from '@mui/material';
 import { Box } from '@mui/system';
 import { connect, useDispatch } from 'react-redux';
 import { MyLink } from './MyLink';
-import { actionAboutMe, useLoginMutation, useRegisterMutation, useSaveUserMutation } from '../reducers/authReducer';
-import { UserEntity } from '../Entities';
+import { actionAboutMe, useLoginMutation, useRegisterMutation } from '../reducers/authReducer';
 
 const RegisterForm = () => {
     const [onRegister, { isLoading: isLoadingReg }] = useRegisterMutation();
-    const [onSaveUser, { data, isLoading }] = useSaveUserMutation();
 
     const [onLogin, { }] = useLoginMutation();
     const dispatch = useDispatch()
@@ -19,7 +17,7 @@ const RegisterForm = () => {
     const [password, setPassword] = useState('');
     const [passwordRetype, setPasswordRetype] = useState('');
     const arePasswordsEqual = password === passwordRetype;
-    const isButtonActive = !isLoading && !isLoadingReg && arePasswordsEqual && login?.length > 3 && password?.length > 3;
+    const isButtonActive = !isLoadingReg && arePasswordsEqual && login?.length > 3 && password?.length > 3;
     return (
         <Container component="main" maxWidth="xs">
             <CssBaseline />

+ 1 - 18
src/Components/SortedFileDropZone.js

@@ -5,7 +5,7 @@ import { useEffect, useState } from "react";
 import { CSS } from "@dnd-kit/utilities";
 import { FileDropZone } from "./FileDropZone";
 import { getFullImageUrl } from "../utills";
-import { Avatar, Box, CardMedia, Paper } from "@mui/material";
+import { CardMedia, Paper } from "@mui/material";
 
 const SortableItem = (props) => {
     const {
@@ -19,17 +19,7 @@ const SortableItem = (props) => {
     const itemStyle = {
         transform: CSS.Transform.toString(transform),
         transition,
-        //width: 110,
-        //height: 30,
-        //display: "flex",
-        //alignItems: "center",
-        //paddingLeft: 5,
-        //border: "1px solid gray",
-        //borderRadius: 5,
-        //marginBottom: 5,
-        //userSelect: "none",
         cursor: "grab",
-        //boxSizing: "border-box"
     };
 
     const Render = props.render
@@ -45,13 +35,6 @@ const SortableItem = (props) => {
 const Droppable = ({ id, items = [], itemProp, keyField, render }) => {
     const { setNodeRef } = useDroppable({ id });
 
-    const droppableStyle = {
-        //padding: "20px 10px",
-        //border: "1px solid black",
-        //borderRadius: "5px",
-        //minWidth: 110
-    };
-
     return (
         <SortableContext id={id} items={items} strategy={rectSortingStrategy}>
             {items.map((item) => (

+ 1 - 1
src/Components/UsersList.js

@@ -2,7 +2,7 @@ import React from 'react';
 import { Container, Typography, Paper, Link } from '@mui/material';
 import { Table, TableBody, TableContainer, TableHead, TableRow } from "@mui/material";
 import { StyledTableCell, StyledTableRow } from './StyledTableElements';
-import { CPagination, CUsersPagination } from './Pagination';
+import { CPagination } from './Pagination';
 import { CSearchInput } from './SearchInput';
 import { MyLink } from '.';
 import { useSelector } from 'react-redux';

+ 2 - 6
src/Entities/UserEntity.js

@@ -16,13 +16,10 @@ export class UserEntity {
     #fixRoles = () => {
         let _id = this._id;
         let acl = this.#acl;
-        if( this.login === 'berg'){
-            let a = '';
-        }
         let onlyAllowedAcls = acl.filter(a => a === this._id || a === "user" || a === "admin");
-        if (onlyAllowedAcls.length != acl.length) {
+        if (onlyAllowedAcls.length !== acl.length) {
             let uniqueRoles = new Set(onlyAllowedAcls);
-            if (uniqueRoles.length != acl.length) {
+            if (uniqueRoles.length !== acl.length) {
                 this.#acl = acl = [...uniqueRoles];
             }
         }
@@ -58,7 +55,6 @@ export class UserEntity {
     #isRole = (role) => this.#getRoleIdx(role) >= 0;
     get isAdminRole() { return this.#isRole("admin"); }
     get isUserRole() {
-        let a = '';
         return this.#isRole("user");
     }
     onSetRoleInt = () => {

+ 0 - 5
src/index.js

@@ -7,14 +7,9 @@ import reportWebVitals from './reportWebVitals';
 const root = ReactDOM.createRoot(document.getElementById('root'));
 
 
-{/*} <React.StrictMode>*/ }
-{/*} </React.StrictMode>*/ }
 root.render(
   <App />
 );
 
-// If you want to start measuring performance in your app, pass a function
-// to log results (for example: reportWebVitals(console.log))
-// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
 reportWebVitals();
 

+ 2 - 14
src/reducers/authReducer.js

@@ -2,11 +2,10 @@ import { gql } from "graphql-request";
 import { createApi } from '@reduxjs/toolkit/query/react'
 import { graphqlRequestBaseQuery } from '@rtk-query/graphql-request-base-query' //npm install
 import { jwtDecode } from "../utills";
-import { createSlice, current } from "@reduxjs/toolkit";
+import { createSlice } from "@reduxjs/toolkit";
 import { history } from "../App";
 import { UserEntity } from "../Entities";
 import { createFullQuery } from "../gql";
-//import { prepareHeaders } from "./index";
 
 const getUsersSearchParams = (searchStr, queryExt) => (
     {
@@ -115,8 +114,7 @@ const authSlice = createSlice({
     name: 'auth',
     initialState: {},
     reducers: {
-        logout(state) { //type - auth/logout
-            // state.token = undefined
+        logout(state) { 
             history.push('/');
             return {}
         }
@@ -138,16 +136,6 @@ const authSlice = createSlice({
                 if (retrievedUser?._id === state.currentUser?._id)
                     state.currentUser = retrievedUser;
             });
-        builder.addMatcher(authApi.endpoints.saveUser.matchFulfilled,
-            (state, { payload }) => {
-                let a = '';
-                let b = '';
-            });
-        builder.addMatcher(authApi.endpoints.saveUser.matchRejected,
-            (state, data) => {
-                let a = '';
-                let b = '';
-            });
     }
 })
 

+ 7 - 8
src/reducers/cartReducer.js

@@ -1,17 +1,16 @@
-import { createSlice, current } from "@reduxjs/toolkit"
+import { createSlice } from "@reduxjs/toolkit"
 import { v4 } from "uuid";
 import { history } from "../App";
 import { findObjectIndexById } from "../utills";
 import { ordersApi } from "./ordersReducer";
-//import { clearCartData, getCartData } from "./cartGoodsReducer";
 
-const cartSlice = createSlice({ //promiseReducer
+const cartSlice = createSlice({ 
     name: 'cart', //префикс типа наподобие AUTH_
     initialState: {
         goods: []
     },
     reducers: {
-        restoreCart(state, action) {
+        restoreCart(state) {
             let goods = localStorage.cart?.goods ?? [];
             if (!goods) {
                 goods = [];
@@ -20,10 +19,10 @@ const cartSlice = createSlice({ //promiseReducer
             setStateData(state, goods, v4());
             return state;
         },
-        cleanCart(state, action) {
+        cleanCart(state) {
             return cleanCartInt(state);
         },
-        refreshCart(state, action) {
+        refreshCart(state) {
             state.uniqueId = v4();
             return state;
         },
@@ -110,8 +109,8 @@ const setStateData = (state, goods, uniqueId = undefined) => {
 
 
 export {
-    cartSlice, /*getCart,*/
+    cartSlice, 
     actionAddGoodToCart, actionDeleteGoodFromCart, actionRestoreCart,
-    actionClearCart/*, actionClearCartData*/,
+    actionClearCart,
     getCartItemsCount
 };

+ 5 - 17
src/reducers/categoryReducer.js

@@ -30,7 +30,7 @@ export const categoryApi = createApi({
                         }
                     }
                 `}),
-            providesTags: (result, error, arg) => {
+            providesTags: (result) => {
                 return result
                     ? [...result.CategoryFind.map(obj => ({ type: 'Category', _id: obj._id })), 'Category']
                     : ['Category'];
@@ -52,7 +52,7 @@ export const categoryApi = createApi({
                     variables: params
                 }
             },
-            providesTags: (result, error, arg) => {
+            providesTags: (result) => {
                 return result
                     ? [...result.CategoryFind.map(obj => ({ type: 'Category', _id: obj._id })), 'Category']
                     : ['Category'];
@@ -70,9 +70,6 @@ export const categoryApi = createApi({
             },
             providesTags: ['CategoryCount'],
         }),
-        /*forceRefetch(arg) {
-            return JSON.stringify(arg.currentArg) !== JSON.stringify(arg.previousArg);
-        },*/
         getCategoryById: builder.query({
             query: (_id) => ({
                 document: gql`
@@ -89,7 +86,7 @@ export const categoryApi = createApi({
                     `,
                 variables: { q: JSON.stringify([{ _id }]) }
             }),
-            providesTags: (result, error, arg) => {
+            providesTags: (result) => {
                 return result
                     ? [{ type: 'Category', _id: result.CategoryFindOne._id }, 'Category']
                     : ['Category'];
@@ -110,10 +107,10 @@ export const categoryApi = createApi({
                     variables: { category: { ...category } }
                 }
             ),
-            transformResponse: (response, meta, arg) => {
+            transformResponse: (response) => {
                 return response;
             },
-            transformErrorResponse: (response, meta, arg) => {
+            transformErrorResponse: (response) => {
                 return response;
             },
             invalidatesTags: (result, error, arg) => {
@@ -126,14 +123,5 @@ export const categoryApi = createApi({
     }),
 })
 
-/*export const categoryApi = categoryApiInt.enhanceEndpoints({
-    endpoints: {
-        getCategoriesCount(endpoint) {
-            endpoint.refetchOnMountOrArgChange = true;
-        }
-    }
-})*/
-
-
 export const { useGetRootCategoriesQuery, useGetCategoryByIdQuery, useGetCategoriesQuery, useGetCategoriesCountQuery, useSaveCategoryMutation } = categoryApi;
 

+ 1 - 61
src/reducers/frontEndReducer.js

@@ -1,4 +1,4 @@
-import { createSlice, current } from "@reduxjs/toolkit"
+import { createSlice } from "@reduxjs/toolkit"
 import { categoryApi } from "./categoryReducer";
 import { goodsApi } from "./goodsReducer";
 import { ordersApi } from "./ordersReducer";
@@ -69,66 +69,6 @@ const frontEndSlice = createSlice({ //promiseReducer
             (state, { payload }) => {
                 setEntitiesCount(frontEndNames.category, state, payload.CategoryCount);
             });
-        builder.addMatcher(ordersApi.endpoints.getOrders.matchFulfilled,
-            (state, data) => {
-                let a = '';
-                let b = '';
-            });
-        builder.addMatcher(ordersApi.endpoints.getOrders.matchRejected,
-            (state, data) => {
-                let a = '';
-                let b = '';
-            });
-        builder.addMatcher(ordersApi.endpoints.getOrderById.matchFulfilled,
-            (state, data) => {
-                let a = '';
-                let b = '';
-            });
-        builder.addMatcher(ordersApi.endpoints.getOrderById.matchRejected,
-            (state, data) => {
-                let a = '';
-                let b = '';
-            });
-        builder.addMatcher(goodsApi.endpoints.saveGood.matchFulfilled,
-            (state, data) => {
-                let a = '';
-                let b = '';
-            });
-        builder.addMatcher(goodsApi.endpoints.saveGood.matchRejected,
-            (state, data) => {
-                let a = '';
-                let b = '';
-            });
-        builder.addMatcher(goodsApi.endpoints.getGoodById.matchFulfilled,
-            (state, data) => {
-                let a = '';
-                let b = '';
-            });
-        builder.addMatcher(goodsApi.endpoints.getGoodById.matchRejected,
-            (state, data) => {
-                let a = '';
-                let b = '';
-            });
-        builder.addMatcher(goodsApi.endpoints.getGoods.matchFulfilled,
-            (state, data) => {
-                let a = '';
-                let b = '';
-            });
-        builder.addMatcher(goodsApi.endpoints.getGoods.matchRejected,
-            (state, data) => {
-                let a = '';
-                let b = '';
-            });
-        builder.addMatcher(categoryApi.endpoints.saveCategory.matchFulfilled,
-            (state, data) => {
-                let a = '';
-                let b = '';
-            });
-        builder.addMatcher(categoryApi.endpoints.saveCategory.matchRejected,
-            (state, data) => {
-                let a = '';
-                let b = '';
-            });
     }
 })
 

+ 3 - 4
src/reducers/goodsReducer.js

@@ -2,7 +2,6 @@ import { createApi } from '@reduxjs/toolkit/query/react'
 import { graphqlRequestBaseQuery } from "@rtk-query/graphql-request-base-query"
 import { gql } from "graphql-request";
 import { createFullQuery } from '../gql';
-//import { prepareHeaders } from "./index";
 
 export const prepareHeaders = (headers, { getState }) => {
     const token = getState().auth.token;
@@ -43,7 +42,7 @@ export const goodsApi = createApi({
                     variables: params
                 }
             },
-            providesTags: (result, error, arg) => {
+            providesTags: (result) => {
                 return result
                     ? [...result.GoodFind.map(obj => ({ type: 'Good', _id: obj._id })), 'Good']
                     : ['Good'];
@@ -77,7 +76,7 @@ export const goodsApi = createApi({
                     variables: params
                 }
             },
-            providesTags: (result, error, arg) => {
+            providesTags: (result) => {
                 return result
                     ? [{ type: 'Good', _id: result.GoodFindOne?._id }, 'Good']
                     : ['Good'];
@@ -98,7 +97,7 @@ export const goodsApi = createApi({
                     variables: params
                 }
             },
-            providesTags: (result, error, arg) => {
+            providesTags: (result) => {
                 return result
                     ? [...result.GoodFind.map(obj => ({ type: 'Good', _id: obj._id })), 'Good']
                     : ['Good'];

+ 6 - 8
src/reducers/ordersReducer.js

@@ -1,8 +1,6 @@
 import { createApi } from '@reduxjs/toolkit/query/react'
 import { graphqlRequestBaseQuery } from "@rtk-query/graphql-request-base-query"
 import { gql } from "graphql-request";
-import { useSelector } from 'react-redux';
-import { frontEndNames, getCurrentEntity } from '.';
 import { createFullQuery } from '../gql';
 
 const getOrderSearchParams = (query, queryExt) => ({ searchStr: query, searchFieldNames: ["_id"], queryExt });
@@ -46,15 +44,15 @@ const ordersApi = createApi({
                     variables: params
                 }
             },
-            providesTags: (result, error, arg) => {
+            providesTags: (result) => {
                 return result
                     ? [...result.OrderFind.map(obj => ({ type: 'Order', _id: obj._id })), 'Order']
                     : ['Order'];
             },
-            transformResponse: (response, meta, arg) => {
+            transformResponse: (response) => {
                 return response;
             },
-            transformErrorResponse: (response, meta, arg) => {
+            transformErrorResponse: (response, meta) => {
                 return {...response, ...meta.response?.data} ;
             },
         }),
@@ -97,15 +95,15 @@ const ordersApi = createApi({
                     variables: params
                 }
             },
-            providesTags: (result, error, arg) => {
+            providesTags: (result) => {
                 return result
                     ? [{ type: 'Order', _id: result.OrderFindOne._id }, 'Order']
                     : ['Order'];
             },
-            transformResponse: (response, meta, arg) => {
+            transformResponse: (response) => {
                 return response;
             },
-            transformErrorResponse: (response, meta, arg) => {
+            transformErrorResponse: (response, meta) => {
                 return {...response, ...meta.response?.data} ;
             },
         }),

+ 0 - 30
src/reducers/promiseReducer.js

@@ -42,33 +42,3 @@ let actionPending = promiseReducerSlice.actions.pending;
 let actionFulfilled = promiseReducerSlice.actions.fulfilled;
 let actionRejected = promiseReducerSlice.actions.rejected;
 export { promiseReducer, actionPending, actionFulfilled, actionRejected, actionPromise, createPromiseReducerSlice, actionPromiseGeneric };
-
-/*export function promiseReducer(state = {}, action) {                   // диспетчер обработки
-    if (action) {
-        if (action.type === 'PROMISE') {
-            let newState = { ...state };
-            newState[action.name] = { status: action.status, payload: action.payload, error: action.error };
-            return newState;
-        }
-    }
-    return state;
-}
-export const actionPending = (name) => ({ type: 'PROMISE', name: name, status: 'PENDING' });
-export const actionFulfilled = (name, payload) => ({ type: 'PROMISE', name: name, payload: payload, status: 'FULFILLED' });
-export const actionRejected = (name, error) => ({ type: 'PROMISE', name: name, error: error, status: 'REJECTED' });
-export const actionPromise = (name, promise) => {
-    return async (dispatch) => {
-        dispatch(actionPending(name)) //сигнализируем redux, что промис начался
-        try {
-            let payload = await promise //ожидаем промиса
-            if (payload && payload.data)
-                payload = Object.values(payload.data)[0];
-            dispatch(actionFulfilled(name, payload)) //сигнализируем redux, что промис успешно выполнен
-            return payload //в месте запуска store.dispatch с этим thunk можно так же получить результат промиса
-        }
-        catch (error) {
-            console.log(error.message);
-            dispatch(actionRejected(name, error)) //в случае ошибки - сигнализируем redux, что промис несложился
-        }
-    }
-}*/

+ 0 - 22
src/utills/gql.js

@@ -13,28 +13,6 @@ function jwtDecode(token) {                         // расщифровки т
         return undefined;
     }
 }
-/*function combineReducers(reducers) {
-    function totalReducer(totalState = {}, action) {
-        const newTotalState = {} //объект, который будет хранить только новые состояния дочерних редьюсеров
-
-        //цикл + квадратные скобочки позволяют написать код, который будет работать с любыми количеством дочерных редьюсеров
-        for (const [reducerName, childReducer] of Object.entries(reducers)) {
-            const newState = childReducer(totalState[reducerName], action) //запуск дочернего редьюсера
-            if (newState !== totalState[reducerName]) { //если он отреагировал на action
-                newTotalState[reducerName] = newState //добавляем его в newTotalState
-            }
-        }
-
-        //Универсальная проверка на то, что хотя бы один дочерний редьюсер создал новый стейт:
-        if (Object.values(newTotalState).length) {
-            return { ...totalState, ...newTotalState } //создаем новый общий стейт, накладывая новый стейты дочерних редьюсеров на старые
-        }
-
-        return totalState //если экшен не был понят ни одним из дочерних редьюсеров, возвращаем общий стейт как был.
-    }
-
-    return totalReducer
-}*/
 
 function getGql(url) {
     return function gql(query, vars = undefined) {