|
@@ -1,5 +1,5 @@
|
|
|
import { connect } from "react-redux";
|
|
|
-import {gql, urlUpload, actionPromise} from "../reducers";
|
|
|
+import {gql, urlUpload, actionPromise, actionGoodCard, getGoods} from "../reducers";
|
|
|
import {createStore, combineReducers, applyMiddleware, bindActionCreators} from 'redux';
|
|
|
import { useEffect, useState } from 'react';
|
|
|
import {BrowserRouter as Router, Route, Link, Switch, Redirect, useHistory} from 'react-router-dom';
|
|
@@ -8,28 +8,9 @@ import {BrowserRouter as Router, Route, Link, Switch, Redirect, useHistory} from
|
|
|
|
|
|
|
|
|
|
|
|
-const actionGoodCard = (_id) => {
|
|
|
- const queryJson = JSON.stringify([{
|
|
|
- "_id": `${_id}`
|
|
|
- }]);
|
|
|
- return (actionPromise(`goodCard`, gql (
|
|
|
- `query oneGood($query: String) {
|
|
|
- GoodFindOne(query: $query) {
|
|
|
- _id
|
|
|
- createdAt
|
|
|
- name
|
|
|
- description
|
|
|
- price
|
|
|
- images{url}
|
|
|
- }
|
|
|
- }
|
|
|
- ` ,{ query: queryJson})))
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
const mapStateToProps = state => ({
|
|
|
state: state,
|
|
|
- goodCard: getGood(state, "goodCard")
|
|
|
+ goodCard: getGoods(state, "goodCard", "GoodFindOne")
|
|
|
});
|
|
|
|
|
|
const mapDispatchToProps = dispatch => bindActionCreators({
|
|
@@ -38,14 +19,6 @@ const actionGoodCard = (_id) => {
|
|
|
|
|
|
|
|
|
|
|
|
- const getGood = (state, key) => {
|
|
|
-
|
|
|
- if(state.promiseRed[key] && state.promiseRed[key].payload) {
|
|
|
- return state.promiseRed[key].payload.data.GoodFindOne
|
|
|
- }
|
|
|
-
|
|
|
- return null;
|
|
|
- };
|
|
|
|
|
|
|
|
|
|
|
@@ -71,9 +44,6 @@ const actionGoodCard = (_id) => {
|
|
|
|
|
|
width > 900 ? setFinallyWidth(true) : setFinallyWidth(false);
|
|
|
|
|
|
- // startWidth !== finallyWidth && history.push("./catalog")
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|