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 }) => {

    const { path } = match;

    console.log(match);

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

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

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


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

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

export default ModuleRoutes;
