import React, { useState, useEffect, useContext } from 'react';

import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';

/**
 * Module Routes is for resources
 *
 * @param {*} param
 *
 */


const ModuleRoutes = ({ model, history, match, menu,...props }) => {

    const { path } = match;

    console.log(match);

    return (
        <Router>
            <Switch>
                <Route exact path={`${path}`} render={(...routeParams) => <model.ListComponent {...routeParams} model={model} {...props}/>} />

                <Route exact path={`${path}/:id`} render={(routeParams) => <model.DetailComponent {...routeParams} model={model} {...props} />} />

                <Route exact path={`${path}/create`} render={(routeParams) => <model.AddComponent {...routeParams} model={model} {...props}/>} />


                <Route path={`${path}/:id/e/`} render={(routeParams) => <model.EditComponent {...routeParams} model={model} {...props}/>} />

                <Route exact path={`/upload/file`} render={(...routeParams) => <model.UploadComponent {...routeParams} model={model} {...props} />} />
            </Switch>
        </Router>
    );
};

export default ModuleRoutes;
