Browse Source

adminCategories orderBy

ilya_shyian 2 years ago
parent
commit
cef263e03c

+ 2 - 2
src/actions/actionCatAll.js

@@ -2,12 +2,12 @@ import { actionPromise } from '../reducers';
 import { gql } from '../helpers';
 
 export const actionCatAll =
-    ({ limit = 0, skip = 0, promiseName = 'catAll' } = {}) =>
+    ({ limit = 20, skip = 0, promiseName = 'catAll', orderBy = '' } = {}) =>
     async (dispatch, getState) => {
         dispatch(
             actionPromise(
                 promiseName,
-                fetch(`/categories/?limit=${limit}&skip=${skip}`, {
+                fetch(`/categories/?limit=${limit}&skip=${skip}${orderBy && `&orderBy=` + orderBy}`, {
                     method: 'GET',
                     headers: {
                         'Content-Type': 'application/json',

+ 14 - 35
src/actions/actionCatsFind.js

@@ -1,45 +1,24 @@
 import { actionPromise } from '../reducers';
 
 export const actionCatsFind =
-    ({ text = '', limit = 0, skip = 0, promiseName = 'catsFind' }) =>
+    ({ text = '', limit = 7, skip = 0, promiseName = 'catsFind', orderBy = '' }) =>
     async (dispatch, getState) => {
-        await dispatch(
+        dispatch(
             actionPromise(
                 promiseName,
-                new Promise((resolve) => {
-                    setTimeout(
-                        Math.random() > 0.01
-                            ? resolve({
-                                  data: [
-                                      {
-                                          _id: 1,
-                                          name: 'Category 1',
-                                      },
-                                      {
-                                          _id: 2,
-                                          name: 'Category 2',
-                                      },
-                                      {
-                                          _id: 3,
-                                          name: 'Category 3',
-                                      },
-                                      {
-                                          _id: 4,
-                                          name: 'Category 4',
-                                      },
-                                  ],
-                              })
-                            : resolve({
-                                  errors: [{ message: 'Error adsasdadas' }],
-                              }),
-                        400
-                    );
-                }).then((data) => {
-                    console.log(data);
-                    if (data.errors) {
-                        throw new Error(JSON.stringify(data.errors));
-                    } else return data.data;
+                fetch(`/categories/?limit=${limit}&skip=${skip}&text=${text}${orderBy && `&orderBy=` + orderBy}`, {
+                    method: 'GET',
+                    headers: {
+                        'Content-Type': 'application/json',
+                        ...(localStorage.authToken ? { Authorization: 'Bearer ' + localStorage.authToken } : {}),
+                    },
                 })
+                    .then((res) => res.json())
+                    .then((data) => {
+                        if (data.errors) {
+                            throw new Error(JSON.stringify(data.errors));
+                        } else return data.data;
+                    })
             )
         );
     };

+ 2 - 2
src/actions/actionGoodsAll.js

@@ -2,12 +2,12 @@ import { getQuery } from '../helpers';
 import { actionPromise } from '../reducers';
 
 export const actionGoodsAll =
-    ({ limit = 0, skip = 0, promiseName = 'goodsAll' } = {}) =>
+    ({ limit = 20, skip = 0, promiseName = 'goodsAll', orderBy = '' } = {}) =>
     async (dispatch, getState) => {
         dispatch(
             actionPromise(
                 promiseName,
-                fetch(`/goods/?limit=${limit}&skip=${skip}`, {
+                fetch(`/goods/?limit=${limit}&skip=${skip}${orderBy && `&orderBy=` + orderBy}`, {
                     method: 'GET',
                     headers: {
                         'Content-Type': 'application/json',

+ 14 - 112
src/actions/actionGoodsFind.js

@@ -1,122 +1,24 @@
 import { actionPromise } from '../reducers';
 
 export const actionGoodsFind =
-    ({ text = '', limit = 0, skip = 0, promiseName = 'goodsFind' }) =>
+    ({ text = '', limit = 7, skip = 0, promiseName = 'goodsFind', orderBy = '' }) =>
     async (dispatch, getState) => {
-        await dispatch(
+        dispatch(
             actionPromise(
                 promiseName,
-                new Promise((resolve) => {
-                    setTimeout(
-                        Math.random() > 0.01
-                            ? resolve({
-                                  data: [
-                                      {
-                                          _id: 1,
-                                          name: 'Good 1',
-                                          description: 'adaadasda asasd asd asd asd asd ',
-                                          price: '999',
-                                          amount: 9999,
-                                          images: [
-                                              {
-                                                  _id: 1,
-                                                  url: 'https://content2.rozetka.com.ua/goods/images/big/183546719.jpg',
-                                              },
-                                              {
-                                                  _id: 2,
-                                                  url: 'https://content2.rozetka.com.ua/goods/images/big/183546719.jpg',
-                                              },
-                                          ],
-                                      },
-                                      {
-                                          _id: 2,
-                                          name: 'Good 2',
-                                          description: 'adaadasda asasd asd asd asd asd ',
-                                          price: '999',
-                                          amount: 9999,
-                                          images: [
-                                              {
-                                                  _id: 1,
-                                                  url: 'https://content2.rozetka.com.ua/goods/images/big/183546719.jpg',
-                                              },
-                                              {
-                                                  _id: 2,
-                                                  url: 'https://content2.rozetka.com.ua/goods/images/big/183546719.jpg',
-                                              },
-                                          ],
-                                      },
-                                      {
-                                          _id: 3,
-                                          name: 'Good 3',
-                                          description: 'adaadasda asasd asd asd asd asd ',
-                                          price: '999',
-                                          amount: 9999,
-                                          images: null,
-                                      },
-                                      {
-                                          _id: 4,
-                                          name: 'Good 4',
-                                          description: 'adaadasda asasd asd asd asd asd ',
-                                          price: '999',
-                                          amount: 9999,
-                                          images: [
-                                              {
-                                                  _id: 1,
-                                                  url: 'https://content2.rozetka.com.ua/goods/images/big/183546719.jpg',
-                                              },
-                                              {
-                                                  _id: 2,
-                                                  url: 'https://content2.rozetka.com.ua/goods/images/big/183546719.jpg',
-                                              },
-                                          ],
-                                      },
-                                      {
-                                          _id: 5,
-                                          name: 'Good 5',
-                                          description: 'adaadasda asasd asd asd asd asd ',
-                                          price: '999',
-                                          amount: 9999,
-                                          images: [
-                                              {
-                                                  _id: 1,
-                                                  url: 'https://content2.rozetka.com.ua/goods/images/big/183546719.jpg',
-                                              },
-                                              {
-                                                  _id: 2,
-                                                  url: 'https://content2.rozetka.com.ua/goods/images/big/183546719.jpg',
-                                              },
-                                          ],
-                                      },
-                                      {
-                                          _id: 6,
-                                          name: 'Good 6',
-                                          description: 'adaadasda asasd asd asd asd asd ',
-                                          price: '999',
-                                          amount: 9999,
-                                          images: [
-                                              {
-                                                  _id: 1,
-                                                  url: 'https://content2.rozetka.com.ua/goods/images/big/183546719.jpg',
-                                              },
-                                              {
-                                                  _id: 2,
-                                                  url: 'https://content2.rozetka.com.ua/goods/images/big/183546719.jpg',
-                                              },
-                                          ],
-                                      },
-                                  ],
-                              })
-                            : resolve({
-                                  errors: [{ message: 'Error adsasdadas' }],
-                              }),
-                        400
-                    );
-                }).then((data) => {
-                    console.log(data);
-                    if (data.errors) {
-                        throw new Error(JSON.stringify(data.errors));
-                    } else return data.data;
+                fetch(`/goods/?limit=${limit}&skip=${skip}&text=${text}${orderBy && `&orderBy=` + orderBy}`, {
+                    method: 'GET',
+                    headers: {
+                        'Content-Type': 'application/json',
+                        ...(localStorage.authToken ? { Authorization: 'Bearer ' + localStorage.authToken } : {}),
+                    },
                 })
+                    .then((res) => res.json())
+                    .then((data) => {
+                        if (data.errors) {
+                            throw new Error(JSON.stringify(data.errors));
+                        } else return data.data;
+                    })
             )
         );
     };

+ 2 - 2
src/actions/actionOrdersAll.js

@@ -2,12 +2,12 @@ import { actionPromise } from '../reducers';
 import { gql } from '../helpers';
 
 export const actionOrdersAll =
-    ({ limit = 0, skip = 0, promiseName = 'adminOrdersAll' } = {}) =>
+    ({ limit = 0, skip = 0, promiseName = 'adminOrdersAll', orderBy = '' } = {}) =>
     async (dispatch, getState) => {
         dispatch(
             actionPromise(
                 promiseName,
-                fetch(`/orders/?limit=${limit}&skip=${skip}`, {
+                fetch(`/orders/?limit=${limit}&skip=${skip}${orderBy && `&orderBy=` + orderBy}`, {
                     method: 'GET',
                     headers: {
                         'Content-Type': 'application/json',

+ 14 - 134
src/actions/actionOrdersFind.js

@@ -1,144 +1,24 @@
 import { actionPromise } from '../reducers';
 
 export const actionOrdersFind =
-    ({ text = '', limit = 0, skip = 0, promiseName = 'ordersFind' }) =>
+    ({ text = '', limit = 7, skip = 0, promiseName = 'ordersFind', orderBy = '' }) =>
     async (dispatch, getState) => {
-        await dispatch(
+        dispatch(
             actionPromise(
                 promiseName,
-                new Promise((resolve) => {
-                    setTimeout(
-                        Math.random() > 0.01
-                            ? resolve({
-                                  data: [
-                                      {
-                                          _id: 1,
-                                          email: 'example@gmail.com',
-                                          phoneNumber: '0667213260',
-                                          orderGoods: [
-                                              {
-                                                  _id: 1,
-                                                  price: 999,
-                                                  count: 1,
-                                                  good: {
-                                                      _id: 1,
-                                                      name: 'Good 1',
-                                                      price: '999',
-                                                      images: [
-                                                          {
-                                                              _id: 1,
-                                                              url: 'https://content2.rozetka.com.ua/goods/images/big/183546719.jpg',
-                                                          },
-                                                          {
-                                                              _id: 2,
-                                                              url: 'https://content2.rozetka.com.ua/goods/images/big/183546719.jpg',
-                                                          },
-                                                      ],
-                                                  },
-                                              },
-                                          ],
-                                          price: 999,
-                                          status: 1,
-                                      },
-                                      {
-                                          _id: 2,
-                                          email: 'example@gmail.com',
-                                          phoneNumber: '0667213260',
-                                          orderGoods: [
-                                              {
-                                                  _id: 1,
-                                                  price: 999,
-                                                  count: 1,
-                                                  good: {
-                                                      _id: 1,
-                                                      name: 'Good 1',
-                                                      price: '999',
-                                                      images: [
-                                                          {
-                                                              _id: 1,
-                                                              url: 'https://content2.rozetka.com.ua/goods/images/big/183546719.jpg',
-                                                          },
-                                                          {
-                                                              _id: 2,
-                                                              url: 'https://content2.rozetka.com.ua/goods/images/big/183546719.jpg',
-                                                          },
-                                                      ],
-                                                  },
-                                              },
-                                          ],
-                                          price: 999,
-                                          status: 2,
-                                      },
-                                      {
-                                          _id: 3,
-                                          email: 'example@gmail.com',
-                                          phoneNumber: '0667213260',
-                                          orderGoods: [
-                                              {
-                                                  _id: 1,
-                                                  price: 999,
-                                                  count: 1,
-                                                  good: {
-                                                      _id: 1,
-                                                      name: 'Good 1',
-                                                      price: '999',
-                                                      images: [
-                                                          {
-                                                              _id: 1,
-                                                              url: 'https://content2.rozetka.com.ua/goods/images/big/183546719.jpg',
-                                                          },
-                                                          {
-                                                              _id: 2,
-                                                              url: 'https://content2.rozetka.com.ua/goods/images/big/183546719.jpg',
-                                                          },
-                                                      ],
-                                                  },
-                                              },
-                                          ],
-                                          price: 999,
-                                          status: 3,
-                                      },
-                                      {
-                                          _id: 4,
-                                          email: 'example@gmail.com',
-                                          phoneNumber: '0667213260',
-                                          orderGoods: [
-                                              {
-                                                  _id: 1,
-                                                  price: 999,
-                                                  count: 1,
-                                                  good: {
-                                                      _id: 1,
-                                                      name: 'Good 1',
-                                                      price: '999',
-                                                      images: [
-                                                          {
-                                                              _id: 1,
-                                                              url: 'https://content2.rozetka.com.ua/goods/images/big/183546719.jpg',
-                                                          },
-                                                          {
-                                                              _id: 2,
-                                                              url: 'https://content2.rozetka.com.ua/goods/images/big/183546719.jpg',
-                                                          },
-                                                      ],
-                                                  },
-                                              },
-                                          ],
-                                          price: 999,
-                                          status: 4,
-                                      },
-                                  ],
-                              })
-                            : resolve({
-                                  errors: [{ message: 'Error adsasdadas' }],
-                              }),
-                        400
-                    );
-                }).then((data) => {
-                    if (data.errors) {
-                        throw new Error(JSON.stringify(data.errors));
-                    } else return data.data;
+                fetch(`/orders/?limit=${limit}&skip=${skip}&text=${text}${orderBy && `&orderBy=` + orderBy}`, {
+                    method: 'GET',
+                    headers: {
+                        'Content-Type': 'application/json',
+                        ...(localStorage.authToken ? { Authorization: 'Bearer ' + localStorage.authToken } : {}),
+                    },
                 })
+                    .then((res) => res.json())
+                    .then((data) => {
+                        if (data.errors) {
+                            throw new Error(JSON.stringify(data.errors));
+                        } else return data.data;
+                    })
             )
         );
     };

+ 0 - 8
src/actions/actionPageStart.js

@@ -6,12 +6,4 @@ export const actionPageStart = () => async (dispatch, getState) => {
     dispatch(actionRootCats());
     dispatch(actionCatAll());
     dispatch(actionGoodsPopular());
-
-    // const {
-    //     auth: { token },
-    // } = getState();
-
-    // if (token) {
-    //     dispatch(actionAboutMe());
-    // }
 };

+ 5 - 1
src/components/GoodsPage/index.js

@@ -1,4 +1,4 @@
-import { Grid, Stack, Typography } from '@mui/material';
+import { Grid, Stack, Typography, Divider } from '@mui/material';
 import { Box } from '@mui/system';
 import { connect } from 'react-redux';
 import { useParams } from 'react-router-dom';
@@ -11,6 +11,10 @@ const GoodsPage = ({ category = {} }) => {
 
     return (
         <Box className="GoodsPage">
+            <Typography variant="h5" textAlign="center">
+                {name}
+            </Typography>
+            <Divider className="Divider" />
             <Stack>
                 {!!subcategories.length ? (
                     <Box>

+ 1 - 2
src/components/Root/index.js

@@ -9,8 +9,7 @@ import { AuthPage } from '../AuthPage';
 import { LayoutPage } from '../LayoutPage';
 import { CProtectedRoute } from '../common/ProtectedRoute';
 
-const Root = ({ user = {} }) => {
-    const isSignIn = true;
+const Root = () => {
     const dispatch = useDispatch();
     dispatch(actionPageStart());
 

+ 18 - 2
src/components/admin/AdminCategoriesPage/AdminCategoryList.js

@@ -5,6 +5,8 @@ import { actionCatsFind } from '../../../actions/actionCatsFind';
 import { actionPromiseClear } from '../../../reducers';
 import { SearchBar, SearchResults } from '../../common/SearchBar';
 import { Box, Table, TableBody, TableHead } from '@mui/material';
+import { useEffect, useState } from 'react';
+import { createSearchParams, useLocation, useNavigate } from 'react-router-dom';
 
 const CSearchBar = connect(null, {
     onSearch: (text) => actionCatsFind({ promiseName: 'adminCatsFind', text, limit: 5 }),
@@ -13,7 +15,11 @@ const CSearchBar = connect(null, {
 
 const CSearchResults = connect((state) => ({ items: state.promise.adminCatsFind?.payload || [] }))(SearchResults);
 
-const AdminCategoryList = ({ categories }) => {
+const AdminCategoryList = ({ categories, orderBy = '_id' } = {}) => {
+    const navigate = useNavigate();
+    const location = useLocation();
+    console.log(orderBy);
+
     return (
         <Box className="AdminCategoryList">
             <Box className="searchBarWrapper">
@@ -25,7 +31,17 @@ const AdminCategoryList = ({ categories }) => {
             </Box>
             <Table>
                 <TableHead>
-                    <AdminCategoryListHeader />
+                    <AdminCategoryListHeader
+                        sort={orderBy}
+                        onSortChange={(orderBy) => {
+                            navigate({
+                                pathname: location.pathname,
+                                search: createSearchParams({
+                                    orderBy,
+                                }).toString(),
+                            });
+                        }}
+                    />
                 </TableHead>
                 <TableBody>
                     {(categories || []).map((cat) => (

+ 12 - 2
src/components/admin/AdminCategoriesPage/AdminCategoryListHeader.js

@@ -4,11 +4,21 @@ import { AddButton } from '../../common/AddButton';
 import { TableCell, TableRow, TableSortLabel } from '@mui/material';
 import { useNavigate } from 'react-router-dom';
 
-const AdminCategoryListHeader = ({ sort, onSortChange, sortReversed, onSortReverseChange }) => {
+const AdminCategoryListHeader = ({ sort, onSortChange }) => {
     const navigate = useNavigate();
+    console.log(sort);
     return (
         <TableRow className="AdminCategoryListHeader">
-            <TableCell scope="col">#</TableCell>
+            <TableCell scope="col">
+                <TableSortLabel
+                    active={sort === '_id' || sort === '-_id'}
+                    direction={sort === '_id' ? 'asc' : 'desc'}
+                    onClick={() => onSortChange(sort === '_id' ? '-_id' : '_id')}
+                >
+                    NAME
+                </TableSortLabel>
+                #
+            </TableCell>
             <TableCell scope="col">Название</TableCell>
             <TableCell scope="col">Родительская категория</TableCell>
             <TableCell scope="col">

+ 2 - 2
src/components/admin/AdminCategoriesPage/index.js

@@ -1,13 +1,13 @@
 import { Box, Typography } from '@mui/material';
 import { CAdminCategoryList } from './AdminCategoryList';
 
-export const AdminCategoriesPage = () => {
+export const AdminCategoriesPage = ({ orderBy }) => {
     return (
         <Box className="AdminCategoriesPage">
             <Typography variant="h5" sx={{ marginBottom: '10px', marginTop: '10px' }}>
                 Категорії
             </Typography>
-            <CAdminCategoryList />
+            <CAdminCategoryList orderBy={orderBy} />
         </Box>
     );
 };

+ 29 - 9
src/components/admin/AdminLayoutPage/index.js

@@ -1,7 +1,7 @@
 import { Box, Container } from '@mui/material';
 import { useEffect } from 'react';
 import { connect, useDispatch, useSelector } from 'react-redux';
-import { Navigate, Route, Routes, useParams } from 'react-router-dom';
+import { Navigate, Route, Routes, useParams, useSearchParams } from 'react-router-dom';
 import { actionGoodById } from '../../../actions/actionGoodById';
 import { actionCatById } from '../../../actions/actionCatById';
 import { actionPromiseClear, store, actionFeedCats } from '../../../reducers';
@@ -14,10 +14,13 @@ import { CAdminCategoryPage } from '../AdminCategoryPage';
 import { AdminOrdersPage } from '../AdminOrdersPage';
 import { CAdminOrderPage } from '../AdminOrderPage';
 import { actionOrderById } from '../../../actions/actionOrderById';
+import { actionCatAll } from '../../../actions/actionCatAll';
+import { actionGoodsAll } from '../../../actions/actionGoodsAll';
 
 const AdminCategoryPageContainer = ({}) => {
     const dispatch = useDispatch();
     const params = useParams();
+    dispatch(actionGoodsAll());
     useEffect(() => {
         if (params._id) {
             dispatch(actionCatById({ _id: params._id, promiseName: 'adminCatById' }));
@@ -30,8 +33,18 @@ const AdminCategoryPageContainer = ({}) => {
 
 const AdminCategoriesPageContainer = ({ cats }) => {
     const dispatch = useDispatch();
+    const [searchParams] = useSearchParams();
+    const orderBy = searchParams.get('orderBy') || '_id';
+
+    useEffect(() => {
+        dispatch(actionFeedClear());
+        dispatch(actionPromiseClear('feedCatAll'));
+        dispatch(actionPromiseClear('categoryUpsert'));
+        dispatch(actionFeedCats({ skip: 0, orderBy }));
+    }, [orderBy]);
+
     useEffect(() => {
-        dispatch(actionFeedCats(cats?.length || 0));
+        dispatch(actionFeedCats({ skip: cats?.length || 0, orderBy }));
         window.onscroll = (e) => {
             if (window.innerHeight + window.scrollY >= document.body.offsetHeight) {
                 const {
@@ -46,7 +59,6 @@ const AdminCategoriesPageContainer = ({ cats }) => {
         return () => {
             dispatch(actionFeedClear());
             dispatch(actionPromiseClear('feedCatAll'));
-
             dispatch(actionPromiseClear('categoryUpsert'));
             window.onscroll = null;
         };
@@ -55,17 +67,19 @@ const AdminCategoriesPageContainer = ({ cats }) => {
     useEffect(() => {
         if (cats.length) dispatch(actionFeedAdd(cats));
     }, [cats]);
-    return <AdminCategoriesPage />;
+
+    return <AdminCategoriesPage orderBy={orderBy} />;
 };
 
 const AdminGoodPageContainer = () => {
     const params = useParams();
     const dispatch = useDispatch();
+    dispatch(actionCatAll());
     useEffect(() => {
         if (params._id) {
             dispatch(actionGoodById({ _id: params._id, promiseName: 'adminGoodById' }));
         } else {
-            dispatch(actionGoodById('adminGoodById'));
+            dispatch(actionPromiseClear('adminGoodById'));
         }
     }, [params._id]);
     return <CAdminGoodPage />;
@@ -73,8 +87,11 @@ const AdminGoodPageContainer = () => {
 
 const AdminGoodsPageContainer = ({ goods }) => {
     const dispatch = useDispatch();
+    const [searchParams] = useSearchParams();
+    const orderBy = searchParams.get('orderBy') || '_id';
+
     useEffect(() => {
-        dispatch(actionFeedGoods());
+        dispatch(actionFeedGoods({ skip: goods?.length || 0, orderBy }));
         window.onscroll = (e) => {
             if (window.innerHeight + window.scrollY >= document.body.offsetHeight) {
                 const {
@@ -83,7 +100,7 @@ const AdminGoodsPageContainer = ({ goods }) => {
                 } = store.getState();
 
                 if (feedGoodsAll.status !== 'PENDING') {
-                    dispatch(actionFeedGoods(feed.payload?.length || 0));
+                    dispatch(actionFeedGoods({ skip: feed.payload?.length || 0, orderBy }));
                 }
             }
         };
@@ -102,9 +119,12 @@ const AdminGoodsPageContainer = ({ goods }) => {
 };
 
 const AdminOrdersPageContainer = ({ orders }) => {
+    const [searchParams] = useSearchParams();
+    const orderBy = searchParams.get('orderBy') || '_id';
+
     const dispatch = useDispatch();
     useEffect(() => {
-        dispatch(actionFeedOrders());
+        dispatch(actionFeedOrders({ skip: orders?.length || 0, orderBy }));
         window.onscroll = (e) => {
             if (window.innerHeight + window.scrollY >= document.body.offsetHeight) {
                 const {
@@ -113,7 +133,7 @@ const AdminOrdersPageContainer = ({ orders }) => {
                 } = store.getState();
 
                 if (feedOrdersAll.status !== 'PENDING') {
-                    dispatch(actionFeedOrders(feed.payload?.length || 0));
+                    dispatch(actionFeedOrders({ skip: feed.payload?.length || 0, orderBy }));
                 }
             }
         };

+ 3 - 3
src/components/admin/AdminOrderPage/OrderForm.js

@@ -68,8 +68,8 @@ export const OrderForm = ({ serverErrors = [], onSaveClick, onSave, onClose, pro
             orderToSave.surname = formik.values.surname;
             orderToSave.phoneNumber = formik.values.phoneNumber;
             orderToSave.address = formik.values.address;
-            orderToSave.deivery = formik.values.deivery;
-
+            orderToSave.delivery = formik.values.delivery;
+            orderToSave.orderGoods = order.orderGoods;
             onSaveClick && onSaveClick();
             onSave(orderToSave);
         },
@@ -220,7 +220,7 @@ export const OrderForm = ({ serverErrors = [], onSaveClick, onSave, onClose, pro
                         variant="outlined"
                         label="Тип доставкі"
                         size="small"
-                        extAlign="left"
+                        textAlign="left"
                         select
                         error={formik.touched.delivery && Boolean(formik.errors.delivery)}
                         value={formik.values.delivery}

+ 1 - 1
src/components/common/GoodCard/index.js

@@ -16,7 +16,7 @@ const GoodCard = ({ good = {} }) => {
                 />
                 <CardContent>
                     <Typography gutterBottom variant="body1" component="div" color="#1C1B1F" textAlign="left">
-                        Назва: {good.name}
+                        Назва: {good.name?.length > 20 ? `${good.name.slice(0, 20)}...` : good.name}
                     </Typography>
                     <Typography variant="body2" color="text.secondary" textAlign="left">
                         Ціна: {good.price}

+ 2 - 2
src/components/common/SearchBar/SearchGoodResultItem.js

@@ -17,7 +17,7 @@ const SearchGoodResultItem = ({ good, onClick, link = '' } = {}) => {
             <Grid item xs={3}>
                 <Box component="img" src={images ? images[0]?.url : defaultGoodImage} />
             </Grid>
-            <Grid item xs={8}>
+            <Grid item xs={6}>
                 <Box sx={{ p: 1 }}>
                     <Typography variant="body1" sx={{ flexGrow: 1 }}>
                         {name.length > 30 ? `${name.substring(0, 30)}...` : name}
@@ -27,7 +27,7 @@ const SearchGoodResultItem = ({ good, onClick, link = '' } = {}) => {
                     </Typography>
                 </Box>
             </Grid>
-            <Grid item xs={1} sx={{ display: 'flex', alignItems: 'center' }}>
+            <Grid item xs={3} sx={{ display: 'flex', alignItems: 'center', justifyContent: 'flex-end' }}>
                 <Typography variant="body1">{price}</Typography>
             </Grid>
         </Grid>

+ 6 - 18
src/components/common/SearchBar/SearchOrderResultItem.js

@@ -4,31 +4,19 @@ const SearchOrderResultItem = ({ order, onClick, link = '' } = {}) => {
     const { _id = null, email = '', phoneNumber = '' } = order || {};
 
     return (
-        <Grid
-            container
+        <Stack
             component={Link}
             to={`${link}${_id}/`}
             className="SearchOrderResultItem Link"
             onClick={() => onClick && onClick()}
             spacing={1}
         >
-            <Grid item xs={2}>
-                <Box sx={{ p: 1 }}>
-                    <Typography variant="body1">{_id}</Typography>
-                </Box>
-            </Grid>
-            <Grid item xs={5}>
-                <Box sx={{ p: 1 }}>
-                    <Typography>{email.length > 30 ? `${email.substring(0, 30)}...` : email}</Typography>
-                </Box>
-            </Grid>
+            <Typography variant="body1">ID:{_id}</Typography>
 
-            <Grid item xs={5}>
-                <Box sx={{ p: 1 }}>
-                    <Typography>{phoneNumber}</Typography>
-                </Box>
-            </Grid>
-        </Grid>
+            <Typography>Email:{email.length > 30 ? `${email.substring(0, 30)}...` : email}</Typography>
+
+            <Typography>Номер:{phoneNumber}</Typography>
+        </Stack>
     );
 };
 

+ 0 - 5
src/components/layout/Header/index.js

@@ -36,11 +36,6 @@ const Header = () => {
                                 Товари
                             </Typography>
                         </Button>
-                        <Button variant="text" color="inherit">
-                            <Typography variant="body1" component="div">
-                                Зворотній зв'язок
-                            </Typography>
-                        </Button>
                     </Stack>
                     <Box className="SearchBarWrapper">
                         <CSearchBar render={CSearchResults} renderParams={{ itemLink: '/good/' }} />

+ 5 - 1
src/index.scss

@@ -267,7 +267,7 @@
               }
             }
             & .SearchOrderResultItem{
-              text-align: center;
+              text-align:left;
               &:hover{
                 background: #F1F2F4;
               }
@@ -305,6 +305,10 @@
 
     & .GoodsPage{
       padding:10px;
+      & .Divider{
+        margin-top: 10px;
+        margin-bottom: 10px;
+      }
       & .SubCategories{
         padding-top: 10px;
         padding-bottom: 10px;

+ 8 - 8
src/reducers/feedReducer.js

@@ -11,7 +11,7 @@ function feedReducer(state = { payload: [] }, { type, payload = [] }) {
     if (type === 'FEED_ADD') {
         return {
             ...state,
-            payload: [...state['payload'], ...payload],
+            payload: [...new Map([...state['payload'], ...payload].map((item) => [item['_id'], item])).values()],
         };
     }
 
@@ -24,9 +24,9 @@ function feedReducer(state = { payload: [] }, { type, payload = [] }) {
 const actionFeedAdd = (payload) => ({ type: 'FEED_ADD', payload });
 const actionFeedClear = () => ({ type: 'FEED_CLEAR' });
 const actionFeedGoods =
-    (skip = 0) =>
+    ({ skip = 0, orderBy = '_id' }) =>
     async (dispatch, getState) => {
-        await dispatch(actionGoodsAll({ skip, limit: 20, promiseName: 'feedGoodsAll' }));
+        await dispatch(actionGoodsAll({ skip, limit: 20, promiseName: 'feedGoodsAll', orderBy }));
     };
 
 const actionFeedGoodsFind =
@@ -38,19 +38,19 @@ const actionFeedGoodsFind =
 const actionFeedCatsFind =
     ({ skip = 0, text = '' }) =>
     async (dispatch, getState) => {
-        await dispatch(actionCatsFind({ skip, promiseName: 'feedCatsFind', text, limit: 50 }));
+        await dispatch(actionCatsFind({ skip, promiseName: 'feedCatsFind', text, limit: 7 }));
     };
 
 const actionFeedCats =
-    (skip = 0) =>
+    ({ skip = 0, orderBy = '_id' }) =>
     async (dispatch, getState) => {
-        await dispatch(actionCatAll({ promiseName: 'feedCatAll', skip, limit: 20 }));
+        await dispatch(actionCatAll({ promiseName: 'feedCatAll', skip, limit: 20, orderBy }));
     };
 
 const actionFeedOrders =
-    (skip = 0) =>
+    ({ skip = 0, orderBy = '_id' }) =>
     async (dispatch, getState) => {
-        await dispatch(actionOrdersAll({ skip, limit: 20, promiseName: 'feedOrdersAll' }));
+        await dispatch(actionOrdersAll({ skip, limit: 20, promiseName: 'feedOrdersAll', orderBy }));
     };
 
 const actionFeedOrdersFind =