import { Provider, connect } from 'react-redux';
import { useEffect, useState } from 'react'
import { Header, Footer, MainImg, Links } from "./index"
import thunk from 'redux-thunk';
import { bindActionCreators } from 'redux';
import actionCatalogCard from './../reducers/reducerCat';
const CatalogSubLink = ({name, arr}) => {
const [show, changeValue] = useState(false);
return(
changeValue(!show)}>{name} {{ show && arr.map(key =>
)}
}
)
}
const Catalog = ({ state, categories = [], getData = () => console.log("no") }) => {
useEffect(() => categories.length == 0 && getData(), []);
return (
<>
{categories.map(category =>
category.subCategories == null ?
:
// - changeValue(!show)}>{category.name} { show &&
{category.subCategories.map(subCategory =>
// )}
}
)}
>
)
}
const getCategories = state => {
// console.log("state", state)
if (state.promiseRed.categories && state.promiseRed.categories.payload) {
return state.promiseRed.categories.payload.data.CategoryFind
}
return [];
};
const mapStateToProps = state => ({
state: state,
categories: getCategories(state)
});
const mapDispatchToProps = dispatch => bindActionCreators({
getData: actionCatalogCard
}, dispatch);
export default connect(mapStateToProps, mapDispatchToProps)(Catalog);