import { actionOrdersFind, actionOrderFindOne, urlUpload} from "../reducers";
import { connect } from "react-redux";
import { useEffect, useState, useRef } from "react";
import {BrowserRouter as Router, Route, Link, Switch, Redirect, useHistory} from 'react-router-dom';
import {createStore, combineReducers, applyMiddleware, bindActionCreators} from 'redux';



const OrderUpdate = ({orderFind, state, match:{params:{_id}}}) => {
    useEffect(() => orderFind(_id), [])
    console.log(state)

    return (
        <>
        </>
    )
}


const mapStateToProps = state => ({
    state: state,

    orders: state.promiseRed && state.promiseRed.ordersFind &&
    state.promiseRed.ordersFind.payload && state.promiseRed.ordersFind.payload.data &&
    state.promiseRed.ordersFind.payload.data.OrderFind,
    
    token: state.auth && state.auth.token,

    status: state.promiseRed && state.promiseRed.ordersFind &&
    state.promiseRed.ordersFind.payload && state.promiseRed.ordersFind &&
    state.promiseRed.ordersFind.status,

    isUserAdmin: state.promiseRed && state.promiseRed.user &&
    state.promiseRed.user.payload && state.promiseRed.user.payload.data &&
    state.promiseRed.user.payload.data.UserFindOne && 
    state.promiseRed.user.payload.data.UserFindOne.acl &&
    state.promiseRed.user.payload.data.UserFindOne.acl.indexOf("admin") > -1,

    owner: state.auth && state.auth.payload && state.auth.payload.sub &&
    state.auth.payload.sub,

    isAdmin: state.auth && state.auth.payload && state.auth.payload.sub &&
    state.auth.payload.sub.acl && state.auth.payload.sub.acl.indexOf("admin") > -1,

    
 });


 
 const mapDispatchToProps = dispatch => bindActionCreators({

   orderFind: actionOrderFindOne
 }, dispatch);


 const COrderUpdate = connect(mapStateToProps, mapDispatchToProps)(OrderUpdate);


 export default COrderUpdate;

