diff --git a/package-lock.json b/package-lock.json index 14029b1a..af402f03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "formik": "^2.4.5", "leaflet": "^1.9.4", "normalize-scss": "7.0.1", + "qs": "^6.12.1", "react": "18.2.0", "react-dom": "18.2.0", "react-input-mask": "^2.0.4", @@ -9351,6 +9352,21 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, + "node_modules/body-parser/node_modules/qs": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dev": true, + "dependencies": { + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/bonjour-service": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/bonjour-service/-/bonjour-service-1.1.1.tgz", @@ -11932,6 +11948,21 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, + "node_modules/express/node_modules/qs": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dev": true, + "dependencies": { + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -17076,11 +17107,11 @@ } }, "node_modules/qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "version": "6.12.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.12.1.tgz", + "integrity": "sha512-zWmv4RSuB9r2mYQw3zxQuHWeU+42aKi1wWig/j4ele4ygELZ7PEO6MM7rim9oAQH2A5MWfsAVf/jPvTPgCbvUQ==", "dependencies": { - "side-channel": "^1.0.4" + "side-channel": "^1.0.6" }, "engines": { "node": ">=0.6" @@ -20132,21 +20163,6 @@ "integrity": "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==", "dev": true }, - "node_modules/url/node_modules/qs": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.12.0.tgz", - "integrity": "sha512-trVZiI6RMOkO476zLGaBIzszOdFPnCCXHPG9kn0yuS1uz6xdVxPfZdB3vUig9pxPFDM9BRAgz/YUIVQ1/vuiUg==", - "dev": true, - "dependencies": { - "side-channel": "^1.0.6" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/use-callback-ref": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/use-callback-ref/-/use-callback-ref-1.3.1.tgz", @@ -27477,6 +27493,15 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true + }, + "qs": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dev": true, + "requires": { + "side-channel": "^1.0.4" + } } } }, @@ -29429,6 +29454,15 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true + }, + "qs": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dev": true, + "requires": { + "side-channel": "^1.0.4" + } } } }, @@ -33168,11 +33202,11 @@ } }, "qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "version": "6.12.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.12.1.tgz", + "integrity": "sha512-zWmv4RSuB9r2mYQw3zxQuHWeU+42aKi1wWig/j4ele4ygELZ7PEO6MM7rim9oAQH2A5MWfsAVf/jPvTPgCbvUQ==", "requires": { - "side-channel": "^1.0.4" + "side-channel": "^1.0.6" } }, "queue-microtask": { @@ -35419,15 +35453,6 @@ "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", "integrity": "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==", "dev": true - }, - "qs": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.12.0.tgz", - "integrity": "sha512-trVZiI6RMOkO476zLGaBIzszOdFPnCCXHPG9kn0yuS1uz6xdVxPfZdB3vUig9pxPFDM9BRAgz/YUIVQ1/vuiUg==", - "dev": true, - "requires": { - "side-channel": "^1.0.6" - } } } }, diff --git a/package.json b/package.json index 9b34efbf..c20acf9c 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "formik": "^2.4.5", "leaflet": "^1.9.4", "normalize-scss": "7.0.1", + "qs": "^6.12.1", "react": "18.2.0", "react-dom": "18.2.0", "react-input-mask": "^2.0.4", diff --git a/src/app/providers/StoreProvider/config/StateSchema.ts b/src/app/providers/StoreProvider/config/StateSchema.ts index 6ea38170..c32743ec 100644 --- a/src/app/providers/StoreProvider/config/StateSchema.ts +++ b/src/app/providers/StoreProvider/config/StateSchema.ts @@ -19,6 +19,7 @@ import { IAboutUsSchema } from '@/pages/AboutUsPage/model/types/types' import { ICartSchema } from '@/pages/CartPage/model/types' import { IProductAmountStateSchema } from '@/features/CartEdit/model/types' import { IFeedbackSchema } from '@/features/Reviews/model/types/types' +import { TNumberOfPageSchema } from '@/components/Pagination/types/types' export interface StateSchema { aboutUs: IAboutUsSchema @@ -44,6 +45,7 @@ export interface StateSchema { categoryFilters: ICategoryFiltersSchema productAmount: IProductAmountStateSchema feedbacks: IFeedbackSchema + pagination: TNumberOfPageSchema } export interface ThunkExtraArg { diff --git a/src/app/providers/StoreProvider/config/store.ts b/src/app/providers/StoreProvider/config/store.ts index c7b915e4..537d13c5 100644 --- a/src/app/providers/StoreProvider/config/store.ts +++ b/src/app/providers/StoreProvider/config/store.ts @@ -24,6 +24,7 @@ import { cartReducer } from '@/pages/CartPage/model/slice' import { cartEntityReducer } from '@/entities/CartEntity/model/slice/cartEntitySlice' import { productAmountReducer } from '@/features/CartEdit/model/slice/productAmountSlice' import { feedbacksReducer } from '@/features/Reviews/model/slice/feedbacksSlice' +import { paginationSliceReducer } from '@/components/Pagination/slice/paginationSlice' export type RootState = StateSchema @@ -50,7 +51,8 @@ const rootReducer: ReducersMapObject = { cartEntity: cartEntityReducer, cart: cartReducer, categoryFilters: categoryFiltersSliceReducer, - productAmount: productAmountReducer + productAmount: productAmountReducer, + pagination: paginationSliceReducer } export function createReduxStore(initialState: RootState) { diff --git a/src/components/Dropdown/Dropdown.tsx b/src/components/Dropdown/Dropdown.tsx index 1101be7b..b55b2937 100644 --- a/src/components/Dropdown/Dropdown.tsx +++ b/src/components/Dropdown/Dropdown.tsx @@ -8,6 +8,7 @@ interface DropdownProps extends React.HTMLProps { items: TSortOptions[] defaultItem?: string onSelect: React.ChangeEventHandler + changeValue?: string } /** @@ -15,8 +16,15 @@ interface DropdownProps extends React.HTMLProps { * @param {array} items - список элементов выпадающего списка для выбора; * @param {string} defaultItem - выбранный по умолчанию элемент списка; * @param {function} onSelect - функция, применяющая выбранное из списка значение; + * @param {string} changeValue - выбранное название фильтра; */ -export const Dropdown: React.FC = ({ items, defaultItem, onSelect, ...props }) => { +export const Dropdown: React.FC = ({ + items, + defaultItem, + onSelect, + changeValue, + ...props +}) => { const [selectedItem, setSelectedItem] = useState(defaultItem || '') const handleSelect = (e: ChangeEvent) => { @@ -26,7 +34,11 @@ export const Dropdown: React.FC = ({ items, defaultItem, onSelect } return ( - {items.map(item => (