소스 검색

обьеденненый проект, переименовал router в App добавил раздел Admin работает пока только shedule, переписал actionTypes action и reducer на актуальные. !!! теперь URL ведеть на heroku !!! Работаем с ним

Boris K 5 년 전
부모
커밋
1e9c302f95

+ 1 - 1
package-lock.json

@@ -13665,4 +13665,4 @@
       }
     }
   }
-}
+}

+ 17 - 32
src/router.js

@@ -3,16 +3,15 @@ import {connect} from 'react-redux'
 import {Switch, Route} from "react-router-dom";
 
 import {
-    getAll,
+
     getDoctors,
     getServices,
-    setAppointmentDate,
     setAppointmentDoctor,
     setAppointmentTime,
     setAppointmentSpec,
     setAppointmentComment,
     clearAppointment,
-    putOrders,
+
 
 } from "./actions/actions";
 
@@ -24,18 +23,15 @@ import Service from "./components/Service";
 import Appointment from "./components/Appointment";
 import Services from "./components/Services"
 import Auth from './containers/auth'
+import Admin from './components/Admin/Admin'
 
 
 export class App extends React.Component {
 
     componentDidMount() {
-        // this.props.getDoctors();
-        // this.props.getServices()
-        this.props.getAll()
-
         this.props.getDoctors();
-        this.props.getServices( );
-        // this.props.postServices()
+        this.props.getServices();
+
      
         // fetch("https://api-clinics.herokuapp.com/api/v1/doctors", {
         //     method: "GET",
@@ -44,14 +40,14 @@ export class App extends React.Component {
         //     .then(res => res.json())
         //     .then(res => console.log (res))
 
-        fetch("https://api-clinics.herokuapp.com/api/v1/services", {
-            method: "GET",
-            credentials: "include"
-        })
-            .then(res => res.json())
-            .then(res => console.log (res))
+        // fetch("https://api-clinics.herokuapp.com/api/v1/services", {
+        //     method: "GET",
+        //     credentials: "include"
+        // })
+        //     .then(res => res.json())
+        //     .then(res => console.log (res))
 
-        // fetch ("https://api-clinics.herokuapp.com/api/v1/auth/login", { 
+        // fetch ("https://api-clinics.herokuapp.com/api/v1/auth/login", {
         //     method : "POST",
         //     credentials: "include",
         //     headers: {
@@ -74,25 +70,15 @@ export class App extends React.Component {
                     <Switch>
                         <Route exact path="/" component={Main} />
                         <Route exact path="/doctors" render={() => <Doctors data={this.props.app.doctors} /> } />
-                        <Route exact path="/services" render={() => <Services data={Array.from(Object.values(this.props.app.services))} />} />
+                        <Route exact path="/services" render={() => <Services data={this.props.app.services} />} />
                         <Route exact path="/reviews" render={() => <div>Reviews</div>} />
+                        <Route path="/admin/" render={(props) => <Admin />} />
                         <Route exact path="/services/:service" render={(props) => <Service
                             his={props}
                             data={this.props.app.services}
                         />} />
-                        <Route  path="/appointment/:doctor" render={(props) => <Appointment
+                        <Route  path="/appointment/:doctorId" render={(props) => <Appointment
                             his={props}
-                            dataDoctors={this.props.app.doctors}
-                            dataServices={this.props.app.services}
-                            dataOrders={this.props.app.orders}
-                            appointment={this.props.app.appointment}
-                            setAppointmentDate={this.props.setAppointmentDate}
-                            setAppointmentDoctor={this.props.setAppointmentDoctor}
-                            setAppointmentTime={this.props.setAppointmentTime}
-                            setAppointmentSpec={this.props.setAppointmentSpec}
-                            setAppointmentComment={this.props.setAppointmentComment}
-                            clearAppointment={this.props.clearAppointment}
-                            putOrders={this.props.putOrders}
                         />} />
                         <Route exact path="/auth" component={Auth} />
                     </Switch>
@@ -109,16 +95,15 @@ const mapStateToProps = state => {
 };
 
 const mapDispatchToProps = {
-    getAll,
+
     getDoctors,
     getServices,
-    setAppointmentDate,
     setAppointmentDoctor,
     setAppointmentTime,
     setAppointmentSpec,
     setAppointmentComment,
     clearAppointment,
-    putOrders
+
 
 };
 

+ 114 - 64
src/actions/actions.js

@@ -1,11 +1,19 @@
 import * as types from '../actionsTypes/actionsTypes'
 
-const URL = "https://team-app-28f4a.firebaseio.com/";
+const URL = "https://api-clinics.herokuapp.com/api/v1/";
+
+
+// -----------------------------------------------------------------------------------------------------------------
+
+export const changeInputDoctorForm = payload => ({
+    type: types.CHANGE_INPUT_VALUE_DOCTOR_FORM,
+    payload
+});
 
 // -----------------------------------------------------------------------------------------------------------------
 
-export const setAppointmentDate = payload => ({
-    type: types.CHANGE_APPOINTMENT_DATE,
+export const setAppointmentShedule = payload => ({
+    type: types.CHANGE_APPOINTMENT_SHEDULE,
     payload
 });
 
@@ -36,63 +44,37 @@ export const clearAppointment = payload => ({
 
 // -----------------------------------------------------------------------------------------------------------------
 
-
-const putOrdersRequest = payload => ({
-    type: types.PUT_ORDERS_REQUEST,
-    payload
-});
-
-const putOrdersSuccess = payload => ({
-    type: types.PUT_ORDERS_REQUEST_SUCCESS,
+export const setSheduleDoctor = payload => ({
+    type: types.CHANGE_SHEDULE_DOCTOR,
     payload
 });
 
-const putOrdersFail = payload => ({
-    type: types.PUT_ORDERS_REQUEST_FAIL,
-    payload
-});
-
-export const putOrders = (payload) => dispatch => {
-    dispatch(putOrdersRequest());
-    return fetch(`${URL}/orders.json`, {
-        method: "PUT",
-        headers: {
-            'Content-Type': 'application/json'
-        },
-        body: JSON.stringify(payload)
-    })
-        .then(res => res.json())
-        .then(res => dispatch(putOrdersSuccess(res)))
-        .catch(err => dispatch(putOrdersFail(err)));
-
-};
-
-
 // -----------------------------------------------------------------------------------------------------------------
 
-const getAllRequest = payload => ({
-    type: types.GET_ALL_REQUEST,
-    payload
-});
-
-const getAllRequestSuccess = payload => ({
-    type: types.GET_ALL_REQUEST_SUCCESS,
-    payload
-});
-
-const getAllRequestFail = payload => ({
-    type: types.GET_ALL_REQUEST_FAIL,
-    payload
-});
-
-export const getAll = () => dispatch => {
-    dispatch(getAllRequest());
-    return fetch(`${URL}.json`)
-        .then(res => res.json())
-        .then(res => dispatch(getAllRequestSuccess(res)))
-        .catch(err => dispatch(getAllRequestFail(err)));
-};
+// const getAllRequest = payload => ({
+//     type: types.GET_ALL_REQUEST,
+//     payload
+// });
+//
+// const getAllRequestSuccess = payload => ({
+//     type: types.GET_ALL_REQUEST_SUCCESS,
+//     payload
+// });
+//
+// const getAllRequestFail = payload => ({
+//     type: types.GET_ALL_REQUEST_FAIL,
+//     payload
+// });
+//
+// export const getAll = () => dispatch => {
+//     dispatch(getAllRequest());
+//     return fetch(`${URL}.json`)
+//         .then(res => res.json())
+//         .then(res => dispatch(getAllRequestSuccess(res)))
+//         .catch(err => dispatch(getAllRequestFail(err)));
+// };
 
+// -----------------------------------------------------------------------------------------------------------------
 // -----------------------------------------------------------------------------------------------------------------
 
 const getDoctorsRequest = payload => ({
@@ -112,7 +94,9 @@ const getDoctorsRequestFail = payload => ({
 
 export const getDoctors = () => dispatch => {
     dispatch(getDoctorsRequest());
-    return fetch(`${URL}doctors.json`)
+    return fetch(`${URL}doctors`,{
+        credentials:"include"
+    })
         .then(res => res.json())
         .then(res => dispatch(getDoctorsRequestSuccess(res)))
         .catch(err => dispatch(getDoctorsRequestFail(err)));
@@ -136,14 +120,17 @@ const getServicesRequestFail = payload => ({
 
 export const getServices = () => dispatch => {
     dispatch(getServicesRequest());
-    return fetch(`${URL}services.json`)
+    return fetch(`${URL}services`,{
+        credentials:"include"
+    })
         .then(res => res.json())
         .then(res => dispatch(getServicesRequestSuccess(res)))
         .catch(err => dispatch(getServicesRequestFail(err)));
 };
 
-// _____________________________________________________________________________________
-export const postDoctorsRequest = payload => ({
+// -----------------------------------------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------------------------------------------
+const postDoctorsRequest = payload => ({
     type: types.POST_DOCTORS_REQUEST,
     payload
 });
@@ -159,9 +146,8 @@ const postDoctorsRequestFail = payload => ({
 });
 
 export const postDoctors = (payload) => dispatch => {
-    // console.log(payload)
     dispatch(postDoctorsRequest());
-    return fetch("https://api-clinics.herokuapp.com/api/v1/doctors", {
+    return fetch(`${URL}doctors`, {
         method: "POST",
         credentials: "include",
         headers: {
@@ -176,7 +162,7 @@ export const postDoctors = (payload) => dispatch => {
 
 // -----------------------------------------------------------------------------------------------------------------
 
-export const postServicesRequest = payload => ({
+const postServicesRequest = payload => ({
     type: types.POST_SERVICES_REQUEST,
     payload
 });
@@ -192,9 +178,8 @@ const postServicesRequestFail = payload => ({
 });
 
 export const postServices = (payload) => dispatch => {
-    // console.log(payload)
     dispatch(postServicesRequest());
-    return fetch("https://api-clinics.herokuapp.com/api/v1/services", {
+    return fetch(`${URL}services`, {
         method: "POST",
         credentials: "include",
         headers: {
@@ -207,4 +192,69 @@ export const postServices = (payload) => dispatch => {
         .catch(err => dispatch(postServicesRequestFail(err)))
 };
 
-// _____________________________________________________________
+// -----------------------------------------------------------------------------------------------------------------
+
+const postSheduleRequest = payload => ({
+    type: types.POST_SHEDULE_REQUEST,
+    payload
+});
+
+const postSheduleSuccess = payload => ({
+    type: types.POST_SHEDULE_REQUEST_SUCCESS,
+    payload
+});
+
+const postSheduleFail = payload => ({
+    type: types.POST_SHEDULE_REQUEST_FAIL,
+    payload
+});
+
+export const postShedule = (payload) => dispatch => {
+    dispatch(postSheduleRequest());
+    return fetch(`${URL}shedule`, {
+        method: "POST",
+        credentials:"include",
+        headers: {
+            'Content-Type': 'application/json'
+        },
+        body: JSON.stringify(payload)
+    })
+        .then(res => res.json())
+        .then(res => dispatch(postSheduleSuccess(res)))
+        .catch(err => dispatch(postSheduleFail(err)));
+};
+
+// -----------------------------------------------------------------------------------------------------------------
+
+const postOrdersRequest = payload => ({
+    type: types.POST_ORDERS_REQUEST,
+    payload
+});
+
+const postOrdersSuccess = payload => ({
+    type: types.POST_ORDERS_REQUEST_SUCCESS,
+    payload
+});
+
+const postOrdersFail = payload => ({
+    type: types.POST_ORDERS_REQUEST_FAIL,
+    payload
+});
+
+export const postOrders = (payload) => dispatch => {
+    dispatch(postOrdersRequest());
+    return fetch(`${URL}orders`, {
+        method: "POST",
+        credentials:"include",
+        headers: {
+            'Content-Type': 'application/json'
+        },
+        body: JSON.stringify(payload)
+    })
+        .then(res => res.json())
+        .then(res => dispatch(postOrdersSuccess(res)))
+        .catch(err => dispatch(postOrdersFail(err)));
+};
+
+// -----------------------------------------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------------------------------------------

+ 21 - 9
src/actionsTypes/actionsTypes.js

@@ -6,15 +6,11 @@ export const GET_SERVICES_REQUEST = "GET_SERVICES_REQUEST";
 export const GET_SERVICES_REQUEST_SUCCESS = "GET_SERVICES_REQUEST_SUCCESS";
 export const GET_SERVICES_REQUEST_FAIL = "GET_SERVICES_REQUEST_FAIL";
 
-export const GET_ALL_REQUEST = "GET_ALL_REQUEST";
-export const GET_ALL_REQUEST_SUCCESS = "GET_ALL_REQUEST_SUCCESS";
-export const GET_ALL_REQUEST_FAIL = "GET_ALL_REQUEST_FAIL";
+// export const GET_ALL_REQUEST = "GET_ALL_REQUEST";
+// export const GET_ALL_REQUEST_SUCCESS = "GET_ALL_REQUEST_SUCCESS";
+// export const GET_ALL_REQUEST_FAIL = "GET_ALL_REQUEST_FAIL";
 
-export const PUT_ORDERS_REQUEST = "PUT_ORDERS_REQUEST";
-export const PUT_ORDERS_REQUEST_SUCCESS = "PUT_ORDERS_REQUEST_SUCCESS";
-export const PUT_ORDERS_REQUEST_FAIL = "PUT_ORDERS_REQUEST_FAIL";
-
-export const CHANGE_APPOINTMENT_DATE= "CHANGE_APPOINTMENT_DATE";
+export const CHANGE_APPOINTMENT_SHEDULE= "CHANGE_APPOINTMENT_SHEDULE";
 export const CHANGE_APPOINTMENT_DOCTOR= "CHANGE_APPOINTMENT_DOCTOR";
 export const CHANGE_APPOINTMENT_TIME= "CHANGE_APPOINTMENT_TIME";
 export const CHANGE_APPOINTMENT_SPEC= "CHANGE_APPOINTMENT_SPEC";
@@ -35,4 +31,20 @@ export const POST_DOCTORS_REQUEST_FAIL = "POST_DOCTORS_REQUEST_FAIL";
 
 export const POST_SERVICES_REQUEST = "POST_SERVICES_REQUEST";
 export const POST_SERVICES_REQUEST_SUCCESS = "POST_SERVICES_REQUEST_SUCCESS";
-export const POST_SERVICES_REQUEST_FAIL = "POST_SERVICES_REQUEST_FAIL";
+export const POST_SERVICES_REQUEST_FAIL = "POST_SERVICES_REQUEST_FAIL";
+
+export const POST_ORDERS_REQUEST = "POST_ORDERS_REQUEST";
+export const POST_ORDERS_REQUEST_SUCCESS = "POST_ORDERS_REQUEST_SUCCESS";
+export const POST_ORDERS_REQUEST_FAIL = "POST_ORDERS_REQUEST_FAIL";
+
+export const POST_SHEDULE_REQUEST = "POST_SHEDULE_REQUEST";
+export const POST_SHEDULE_REQUEST_SUCCESS = "POST_SHEDULE_REQUEST_SUCCESS";
+export const POST_SHEDULE_REQUEST_FAIL = "POST_SHEDULE_REQUEST_FAIL";
+
+// export const CHANGE_SHEDULE_DATE= "CHANGE_SHEDULE_DATE";
+export const CHANGE_SHEDULE_DOCTOR= "CHANGE_SHEDULE_DOCTOR";
+
+export const CHANGE_INPUT_VALUE_DOCTOR_FORM= "CHANGE_INPUT_VALUE_DOCTOR_FORM";
+
+
+

+ 65 - 0
src/components/Admin/Admin.js

@@ -0,0 +1,65 @@
+import React from 'react';
+import {connect} from 'react-redux'
+import {Link} from 'react-router-dom'
+import {Switch, Route} from "react-router-dom";
+import {
+    setSheduleDoctor,
+    postShedule,
+    changeInputDoctorForm,
+    postDoctors
+} from "../../actions/actions";
+
+import Shedule from './Shedule'
+import ChangeDoctor from './ChangeDoctor'
+
+
+
+export class Admin extends React.Component {
+
+
+    render() {
+        const {doctors,postNewShedule,sheduleMonthArray,postNewDoctor} = this.props.app;
+        const {setSheduleDoctor,postShedule,changeInputDoctorForm,postDoctors} = this.props;
+        return (
+            <div style={{display:'flex',flexDirection:'column', width:'200px', margin:'100px 20px'}}>
+                <div>
+                    <Link to='/admin/change-shedule'>Shedule</Link>
+                    <Link to='/admin/change-doctors'>Doctors</Link>
+                    <Link to='/admin/change-services'>Services</Link>
+                </div>
+                <Switch>
+                    <Route path='/admin/change-shedule' render={() => <Shedule
+                        doctors={doctors}
+                        postNewShedule={postNewShedule}
+                        sheduleMonthArray={sheduleMonthArray}
+                        setSheduleDoctor={setSheduleDoctor}
+                        postShedule={postShedule}
+                    />} />
+                    <Route path='/admin/change-doctors' render={() => <ChangeDoctor
+                        changeInputValues={changeInputDoctorForm}
+                        postDoctors={postDoctors}
+                        postNewDoctor={postNewDoctor}
+                    />} />
+                    <Route path='/admin/change-services' render={() => <div>Services</div>} />
+                </Switch>
+            </div>
+        );
+    }
+}
+
+const mapStateToProps = state => {
+    return {
+        app:state.app,
+    }
+};
+
+const mapDispatchToProps = {
+    setSheduleDoctor,
+    postShedule,
+    changeInputDoctorForm,
+    postDoctors
+
+
+};
+
+export default connect (mapStateToProps,mapDispatchToProps)(Admin)

+ 33 - 0
src/components/Admin/ChangeDoctor.js

@@ -0,0 +1,33 @@
+import React from 'react';
+import Input from './Input'
+
+export default class ChangeDoctor extends React.Component {
+
+
+    render() {
+        const {changeInputValues,postDoctors,postNewDoctor} = this.props;
+        return (
+            <div style={{display:'flex',flexDirection:'column', width:'200px', margin:'10px 20px'}}>
+                <form onSubmit={(e)=>{
+                    e.preventDefault();
+                    console.log(postNewDoctor)
+                }}>
+                {
+                    postNewDoctor.map(el => (
+                        <Input
+                            key={el.id}
+                            id={el.id}
+                            el={el}
+                            changeInputValues={changeInputValues}
+                        />
+                    ))
+                }
+                <input
+                    type='submit'
+                    value='Post new doctor'
+                />
+                </form>
+            </div>
+        );
+    }
+}

+ 20 - 0
src/components/Admin/Input.js

@@ -0,0 +1,20 @@
+import React from 'react';
+
+export default class Input extends React.Component {
+    render(){
+        return (
+            <input
+                id={this.props.el.id}
+                type={this.props.el.type}
+                name={this.props.el.name}
+                value={this.props.el.value}
+                placeholder={this.props.el.placeholder}
+                minLength={this.props.el.minLength}
+                maxLength={this.props.el.maxLength}
+                required={this.props.el.required}
+                pattern={this.props.el.pattern}
+                onChange={(e) => this.props.changeInputValues(e)}
+            />
+        );
+    }
+};

+ 70 - 0
src/components/Admin/Shedule.js

@@ -0,0 +1,70 @@
+import React from 'react';
+
+export default class Shedule extends React.Component {
+    state ={
+        startDate:null,
+        endDate:null,
+    };
+
+    post = () => {
+        let current = new Date(this.state.startDate);
+        let end = new Date (this.state.endDate);
+        while (current.toISOString().split('T')[0] <= end.toISOString().split('T')[0]){
+            this.props.postShedule({
+                ...this.props.postNewShedule,
+                data:current.toISOString().split('T')[0],
+            });
+            current =new Date(+current + 86400000)
+        }
+    };
+
+    render() {
+        const {doctors,postNewShedule,sheduleMonthArray,setSheduleDoctor} = this.props;
+        return (
+            <div style={{display:'flex',flexDirection:'column', width:'200px', margin:'10px 20px'}}>
+
+
+                <select  onChange={(e) => setSheduleDoctor(e.target.value)} defaultValue='choose doctor'>
+                    <option disabled >choose doctor</option>
+                    {
+                        doctors.map(el=> (
+                            <option key={el._id} id={el._id}>{el.name}</option>
+                        ))
+                    }
+                </select>
+
+
+                {postNewShedule.doctor &&
+                    <>
+                        <input type="date" onChange={(e) => this.setState({startDate:e.target.value})}/>
+                        <input type="date" onChange={(e) => this.setState({endDate:e.target.value})}/>
+                    </>
+                }
+
+
+                {(this.state.startDate && this.state.endDate) && <button onClick={this.post}>Post</button>}
+
+
+                {postNewShedule.doctor &&
+                    <div style={{display:'flex', margin:'10px 20px'}}>
+                        <p>{new Date().toLocaleString('ru',{month:'long'})}</p>
+                        {
+                            sheduleMonthArray[new Date().getMonth()].map(el => (
+                                <div key={el._id} style={{margin:'10px 20px'}}>
+                                    <p>{new Date(el.data).toISOString().split('T')[0].split('-')[2]}</p>
+                                    {
+                                        Object.keys(el).map(key=> {
+                                            return [key,el[key]]
+                                        }).map(el => ((typeof el[1]=== 'boolean') ? <p key={el[0]}>{el[0]}-{`${el[1]}`}</p> : null))
+                                    }
+                                </div>
+                            ))
+                        }
+                    </div>
+                }
+
+
+            </div>
+        );
+    }
+}

+ 89 - 40
src/components/Appointment.js

@@ -1,31 +1,48 @@
 import React from 'react';
+import {connect} from "react-redux";
 
 
-export default class Appointment extends React.Component {
+import {
+    setAppointmentSpec,
+    setAppointmentShedule,
+    setAppointmentDoctor,
+    clearAppointment,
+    setAppointmentTime,
+    setAppointmentComment,
+    postOrders
+
+} from "../actions/actions";
+
+
+
+export class Appoint extends React.Component {
 
     componentDidMount() {
-        this.props.setAppointmentDoctor(+this.props.his.match.params.doctor)
+        this.props.setAppointmentDoctor(this.props.his.match.params.doctorId)
     }
 
     componentWillUnmount() {
         this.props.clearAppointment()
     }
 
+
     render() {
-        const {his,dataDoctors,dataServices,dataOrders,appointment,
-            setAppointmentDate,
-            setAppointmentTime,
-            setAppointmentSpec,
-            setAppointmentComment,
-            putOrders
-        } = this.props;
-        const timeArray = [];
-        const doctor = dataDoctors.find(el => el.id === +his.match.params.doctor);
-        if (appointment.date.year){
-            for (let index in doctor.schedule[appointment.date.month][appointment.date.day]){
-                timeArray.push({[`${index}`]:doctor.schedule[appointment.date.month][appointment.date.day][`${index}`]})
+        const {doctors, appointment, timeArray, wrongDate,services} = this.props.app;
+        const {his, setAppointmentSpec, setAppointmentShedule, setAppointmentTime, setAppointmentComment, postOrders} = this.props;
+        const doctor = doctors.find(el => el._id === his.match.params.doctorId);
+        let spec
+        if (appointment.spec){
+            spec = services.find(el => el._id === appointment.spec)
+        }
+        let currentDate
+        let choosedData
+        if (doctor) {
+            if (doctor.shedule && appointment.shedule) {
+                currentDate = new Date().toISOString().split('T')[0]
+                choosedData = doctor.shedule.find(el => el._id === appointment.shedule).data.split('T')[0];
             }
         }
+        console.log(this.props.app)
         return (
             <>
                 {doctor &&
@@ -34,45 +51,59 @@ export default class Appointment extends React.Component {
                     <p>{doctor.name}</p>
                     <p>{doctor.lastName}</p>
                     <p>{doctor.skillsDescription}</p>
-                    <select onChange={(e)=>setAppointmentSpec(e.target.value)} defaultValue='choose spec'>
+
+                    {appointment.spec &&
+                    <div>
+                        <p>{spec.name}</p>
+                        <p>Duration:{spec.duration}h</p>
+                        <p>{spec.description}</p>
+                        <p>Price:{spec.price}$</p>
+                    </div>
+                    }
+                    <select  onChange={(e)=>setAppointmentSpec(e.target.value)} defaultValue='choose spec'>
                         <option disabled >choose spec</option>
                         {
                             doctor.speciality.map(el=> (
-                                <option key={el}>{el}</option>
+                                <option key={el._id}>{el.name}</option>
                             ))
                         }
-
                     </select>
 
-                    {appointment.spec && <input type="date" onChange={(e)=>setAppointmentDate(e.target.value)}/>}
+                    {appointment.spec &&
+                    <input type="date" onChange={(e)=>setAppointmentShedule(doctor.shedule.find(el => el.data === new Date(e.target.value).toISOString())
+                        ? doctor.shedule.find(el => el.data === new Date(e.target.value).toISOString())._id
+                        : null)}/>
+                    }
+
+
+
+                    {!appointment.shedule ?
+                        !wrongDate ?
+                            <p>There is no available time to choose on this date</p>
+                            : null
+                        : <div>
+                            { choosedData >= currentDate ?
+                                <div>
+                                    <select onChange={(e)=>setAppointmentTime(e.target.value)} defaultValue='choose time'>
+                                        <option disabled >choose time</option>
+                                        {
+                                            timeArray.map(el=> (
+                                                Object.values(el)[0] ? <option key={Object.keys(el)[0]} style={{color:'green'}} > {Object.keys(el)[0]} </option> : <option key={Object.keys(el)[0]} style={{color:'red'}} disabled > {Object.keys(el)[0]} </option>
+                                            ))
+                                        }
+
+                                    </select>
+                                </div>
+                                : <p>Choose current or future date</p>
+                            }
+                        </div>
 
-                    {appointment.date.year !== 0 &&
-                    <div>
-                        {
-                            ( +appointment.date.month >= new Date().getMonth()+1 && +appointment.date.day >= new Date().getDate() ) ?
-                                doctor.schedule[appointment.date.month][appointment.date.day] ?
-                                    <div>
-                                        <select onChange={(e)=>setAppointmentTime(e.target.value)} defaultValue='choose time'>
-                                            <option disabled >choose time</option>
-                                            {
-                                                timeArray.map(el=> (
-                                                    <option key={Object.keys(el)[0]}>{Object.values(el)[0] ? Object.keys(el)[0] : null}</option>
-                                                ))
-                                            }
-
-                                        </select>
-                                        <input type="time" readOnly placeholder="Time will be calculated" value={appointment.time ? +appointment.time.split(':')[0] + dataServices[appointment.spec].duration + ':00' : ''}/>
-                                    </div>
-                                    : <p>No work today</p>
-                                : <p>Please choose current or future date</p>
-                        }
-                    </div>
                     }
 
                     {appointment.time &&
                     <div style={{display:"flex",flexDirection:"column"}}>
                         <input type='text' placeholder='Add comments here' onChange={(e)=>setAppointmentComment(e.target.value)}/>
-                        <button onClick={()=>putOrders([...dataOrders,appointment])}>Confirm Appointment</button>
+                        <button onClick={() => postOrders(appointment)}>Confirm Appointment</button>
                     </div>
                     }
 
@@ -82,3 +113,21 @@ export default class Appointment extends React.Component {
         );
     }
 }
+
+const mapStateToProps = state => {
+    return {
+        app:state.app,
+    }
+};
+
+const mapDispatchToProps = {
+    setAppointmentSpec,
+    setAppointmentShedule,
+    setAppointmentDoctor,
+    clearAppointment,
+    setAppointmentTime,
+    setAppointmentComment,
+    postOrders
+};
+
+export default connect (mapStateToProps,mapDispatchToProps)(Appoint)

+ 8 - 7
src/components/Service.js

@@ -7,14 +7,15 @@ export default class Service extends React.Component {
 
     render() {
         const {his,data} = this.props;
-        const path = his.match.params.service;
+        const service = data.find(el => el._id === his.match.params.service)
+        console.log(this.props)
         return (
-            <div style={{display:'flex',flexDirection:'column', width:'200px', margin:'10px 20px'}}>
-                {data[path].name}
-                <p>Duration:{data[path].duration}h</p>
-                <p>{data[path].description}</p>
-                <p>Price:{data[path].price}$</p>
-                <Link to={`/appointment/${path}`}>Make an appointment</Link>
+            <div style={{display:'flex',flexDirection:'column', width:'200px', margin:'100px 20px'}}>
+                {service.name}
+                <p>Duration:{service.duration}h</p>
+                <p>{service.description}</p>
+                <p>Price:{service.price}$</p>
+                <Link to={`/appointment/${service}`}>Make an appointment</Link>
             </div>
         );
     }

+ 3 - 2
src/components/Services.js

@@ -6,17 +6,18 @@ export default class Services extends React.Component {
 
     render() {
         const {data} = this.props;
+
         return (
             <div style={{display:'flex', justifyContent:'center', flexWrap:'wrap'}}>
                 {
                     data.map(el => (
-                        <div key={el.id} style={{display:'flex',flexDirection:'column', width:'200px', margin:'10px 20px'}}>
+                        <div key={el._id} style={{display:'flex',flexDirection:'column', width:'200px', margin:'100px 20px'}}>
                             <p>{el.name}</p>
                             <p>Duration:{el.duration}h</p>
                             <p>{el.description}</p>
                             <p>Price:{el.price}$</p>
                             <div>
-                            <Link to={`/services/service${el.id}`}>More Info</Link>
+                                <Link to={`/services/${el._id}`}>More Info</Link>
                                 <button>Make appointment</button>
                             </div>
                         </div>

+ 2 - 1
src/components/header/navigation.js

@@ -9,7 +9,8 @@ const liArr = [
 	{ path: "/doctors",  id: 2,  text: "Специалисты"  },
 	{ path: "/services", id: 3,  text: "Услуги" },
 	{ path: "/reviews", id: 4, text: "Отзывы"  },
-	{ path: "/auth", id: 5, text: "Войти", hideWhenAuth: true }
+	{ path: "/admin", id: 5, text: "Admin"},
+	{ path: "/auth", id: 6, text: "Войти", hideWhenAuth: true }
 ];
 
 export default ( props ) => (

+ 1 - 1
src/components/main/Main.js

@@ -2,7 +2,7 @@ import React from 'react';
 // import {Link} from 'react-router-dom';
 
 
-import {postDoctors, postServices} from "../../store/app/actions";
+import {postDoctors, postServices} from "../../actions/actions";
 
 import Button from "../buttons/button";
 import About from "./aboutUs";

+ 3 - 3
src/components/main/team.js

@@ -12,12 +12,12 @@ export default class Team extends React.Component {
                 <h2>Наши врачи</h2>
                 <div className = "team-container">
                     {doctorsArr.map  ( el => 
-                         <div className="item"  key = {el.id} >
+                         <div className="item"  key = {el._id} >
                              <div className="photo"><img src= {el.photo} alt= {el.name}/></div>
                             <h3>{el.name}</h3>
                             <div className="desc">
-                                <p className="experience">Опыт работы {el.experience} лет</p>
-                                <p className="rank">{el.rank}</p>
+                                <p className="experience">Опыт работы {new Date().toISOString().split('T')[0].split('-')[0] - el.experience.split('T')[0].split('-')[0]} лет</p>
+                                <p className="rank">{el.profession}</p>
                             </div>
                              <div className="link-box">
                                 <Link to = "/doctors" className = "btn link more">Подробнее ...</Link>

+ 19 - 26
src/components/specialists/doctors.js

@@ -5,34 +5,27 @@ export default class Doctors extends React.Component {
 
 
     render() {
-        const {data, flag} = this.props
+        const {data} = this.props;
         return (
-           
             <div style={{display:'flex', justifyContent:'center', flexWrap:'wrap'}}>
-                {(flag==='doctors') ? data.map(el=>(
-                        <div key={el.id} style={{display:'flex',flexDirection:'column', width:'300px', margin:'10px 20px'}}>
-                            <Link to={`/doctors/${el.id}`} >
-                                <p>{el.photo}</p>
-                                <p>{el.name}</p>
-                                <p>{el.lastName}</p>
-                                <p>{el.age}</p>
-                                <p>{el.skillsDescription}</p>
-                            </Link>
-                            {el.speciality.map(el=>(
-                                <Link to={`/services/${el}`} key={el}>{el}</Link>
-                            ))}
-                            <Link to={`/appointment/${el.id}`}>Make an appointment</Link>
-                        </div>
-                    )) : (flag==='services') ?
-                data.map(el => (
-                   <div key={el.id} style={{width:'300px', margin:'10px 20px'}}>
-                       <p>{el.name}</p>
-                       <p>{el.description}</p>
-                       <p>Price:{el.price}$</p>
-                   </div>
-                )) : <p>null</p>
-                }
-
+                {data.map(el => (
+                    <div
+                        key={el._id}
+                        style={{display: 'flex', flexDirection: 'column', width: '300px', margin: '100px 20px'}}
+                    >
+                        <Link to={`/doctors/${el._id}`}>
+                            <p>{el.photo}</p>
+                            <p>{el.name}</p>
+                            <p>{el.lastName}</p>
+                            <p>{el.age}</p>
+                            <p>{el.skillsDescription}</p>
+                        </Link>
+                        {el.speciality.map(el => (
+                            <Link to={`/services/${el._id}`} key={el._id}>{el.name}</Link>
+                        ))}
+                        <Link to={`/appointment/${el._id}`}>Make an appointment</Link>
+                    </div>
+                ))}
             </div>
         );
     }

+ 1 - 1
src/index.js

@@ -1,6 +1,6 @@
 import React from 'react';
 import ReactDOM from 'react-dom';
-import App from './router'
+import App from './App'
 import * as serviceWorker from './serviceWorker';
 
 import {BrowserRouter} from "react-router-dom";

+ 152 - 95
src/reducers/reducers.js

@@ -1,5 +1,57 @@
 import * as types from '../actionsTypes/actionsTypes'
 
+const doctorForm =[
+    {
+        id:1,
+        type:'text',
+        value:"",
+        name:'name',
+        placeholder:'Enter doctor Name and Last Name',
+        required:true
+    },
+    {
+        id:2,
+        type:'text',
+        value:"",
+        name:'experience',
+        placeholder:'Enter practice start date',
+        required:true
+    },
+    {
+        id:3,
+        type:'text',
+        value:"",
+        name:'photo',
+        placeholder:'Enter path to photo here',
+        required:true
+    },
+    {
+        id:4,
+        type:'text',
+        value:"",
+        name:'profession',
+        placeholder:'Enter profession here',
+        required:true
+    },
+    {
+        id:5,
+        type:'text',
+        value:"",
+        name:'skillsDescription',
+        placeholder:'Enter skills description here',
+        required:true
+    },
+    {
+        id:6,
+        type:'text',
+        value:"",
+        name:'speciality',
+        placeholder:'Enter array of service speciality description here',
+        required:true
+    }
+];
+
+
 const defaultState = {
     currentUser:{
         email:"dead1990bb@gmail.com",
@@ -14,33 +66,25 @@ const defaultState = {
         doctor:false,
     },
     doctors:[],
-    services:{
-        service1:{id:1},
-        service2:{id:2},
-        service3:{id:3},
-        service4:{id:4},
-        service5:{id:5},
-        service6:{id:6},
-        service7:{id:7},
-        service8:{id:8},
-        service9:{id:9},
+    postNewShedule:{
+        data:null,
+        doctor:null
     },
+    postNewDoctor:doctorForm,
+    sheduleMonthArray:null,
+    services:[],
     orders:[],
     users:[],
     reviews: [],
     appointment:{
-        date:{
-            year:0,
-            month:0,
-            day:0
-        },
-        price:null,
+        shedule:null,
         time:null,
-        doctorId:null,
+        doctor:null,
         spec:null,
-        user:null,
         comment:''
     },
+    timeArray:[],
+    wrongDate:true,
     isFetching:false,
     error: null,
 
@@ -51,19 +95,43 @@ const defaultState = {
 export const appReducer = (state = defaultState,action) => {
 
     switch (action.type) {
+
 // -----------------------------------------------------------------------------------------------------------------
 
-        case types.CHANGE_APPOINTMENT_DATE : {
+        case types.CHANGE_INPUT_VALUE_DOCTOR_FORM : {
             return {
                 ...state,
-                appointment:{
-                    ...state.appointment,
-                    date:{
-                        year: action.payload.split('-')[0],
-                        month: action.payload.split('-')[1],
-                        day: action.payload.split('-')[2],
+                postNewDoctor: state.postNewDoctor.map(el => el.id === +action.payload.target.id ? {
+                    ...el,
+                    value:action.payload.target.value
+                } : el)
+            };
+        }
+
+// -----------------------------------------------------------------------------------------------------------------
+
+        case types.CHANGE_APPOINTMENT_SHEDULE : {
+            let timeArray =[];
+            let doctor = state.doctors.find(el => el._id === state.appointment.doctor);
+            let shedule = doctor.shedule.find(el => el._id === action.payload);
+            let duration = state.services.find(el => el._id === state.appointment.spec).duration;
+            for (let index in shedule) {
+                let check = true;
+                for (let x=0;x < duration; x++){
+                    if (shedule[`${+index.split(':')[0]+x < 10 ? '0' +(+index.split(':')[0] + x) + ':00' : +index.split(':')[0]+ x + ':00'}`] !== true){
+                        check = false
                     }
                 }
+                if (check) timeArray.push({[`${index}`]:shedule[`${index}`]});
+            }
+            return {
+                ...state,
+                appointment:{
+                    ...state.appointment,
+                    shedule:action.payload
+                },
+                timeArray:timeArray,
+                wrongDate: action.payload
             };
         }
 
@@ -72,7 +140,7 @@ export const appReducer = (state = defaultState,action) => {
                 ...state,
                 appointment:{
                     ...state.appointment,
-                    doctorId:action.payload
+                    doctor:action.payload
                 }
             };
         }
@@ -92,9 +160,9 @@ export const appReducer = (state = defaultState,action) => {
                 ...state,
                 appointment:{
                     ...state.appointment,
-                    spec:action.payload,
-                    id:state.orders[state.orders.length-1].id+1,
-                    price:+state.services[action.payload].price
+                    spec:state.services.find(el => el.name === action.payload)._id,
+                    shedule:null,
+                    time:null
                 }
             };
         }
@@ -118,24 +186,40 @@ export const appReducer = (state = defaultState,action) => {
 
 // -----------------------------------------------------------------------------------------------------------------
 
+        case types.CHANGE_SHEDULE_DOCTOR : {
+            let doctor = state.doctors.find(el=>el.name === action.payload);
+            let array = [[],[],[],[],[],[],[],[],[],[],[],[]];
+            doctor.shedule.map(el => {
+                array[new Date(el.data).getMonth()].push(el)
+            });
+            return {
+                ...state,
+                postNewShedule: {
+                    ...state.postNewShedule,
+                    doctor:doctor._id
+                },
+                sheduleMonthArray: array
+            };
+        }
 
-        case types.PUT_ORDERS_REQUEST : {
+// -----------------------------------------------------------------------------------------------------------------
+
+        case types.GET_DOCTORS_REQUEST : {
             return {
                 ...state,
                 isFetching: true
             };
         }
 
-        case types.PUT_ORDERS_REQUEST_SUCCESS : {
+        case types.GET_DOCTORS_REQUEST_SUCCESS : {
             return {
                 ...state,
-                appointment: defaultState.appointment,
-                orders:action.payload,
+                doctors:action.payload.doctors,
                 isFetching: false
             }
         }
 
-        case types.PUT_ORDERS_REQUEST_FAIL : {
+        case types.GET_DOCTORS_REQUEST_FAIL : {
             return {
                 ...state,
                 error:action.payload,
@@ -145,27 +229,22 @@ export const appReducer = (state = defaultState,action) => {
 
 // -----------------------------------------------------------------------------------------------------------------
 
-
-        case types.GET_ALL_REQUEST : {
+        case types.GET_SERVICES_REQUEST : {
             return {
                 ...state,
                 isFetching: true
             };
         }
 
-        case types.GET_ALL_REQUEST_SUCCESS : {
+        case types.GET_SERVICES_REQUEST_SUCCESS : {
             return {
                 ...state,
-                doctors: action.payload.doctors,
-                services: action.payload.services,
-                orders: action.payload.orders,
-                users: action.payload.users,
-                reviews: action.payload.reviews,
+                services:action.payload.services,
                 isFetching: false
             }
         }
 
-        case types.GET_ALL_REQUEST_FAIL : {
+        case types.GET_SERVICES_REQUEST_FAIL : {
             return {
                 ...state,
                 error:action.payload,
@@ -175,101 +254,79 @@ export const appReducer = (state = defaultState,action) => {
 
 // -----------------------------------------------------------------------------------------------------------------
 
-        case types.GET_DOCTORS_REQUEST : {
+        case types.POST_DOCTORS_REQUEST : {
             return {
                 ...state,
                 isFetching: true
             };
         }
 
-        case types.GET_DOCTORS_REQUEST_SUCCESS : {
+        case types.POST_DOCTORS_REQUEST_SUCCESS : {
             return {
                 ...state,
-                doctors:action.payload,
                 isFetching: false
             }
         }
 
-        case types.GET_DOCTORS_REQUEST_FAIL : {
+        case types.POST_DOCTORS_REQUEST_FAIL : {
             return {
                 ...state,
-                error:action.payload,
+                error: action.payload,
                 isFetching: false
             }
         }
 
 // -----------------------------------------------------------------------------------------------------------------
 
-        case types.GET_SERVICES_REQUEST : {
+        case types.POST_SERVICES_REQUEST : {
             return {
                 ...state,
                 isFetching: true
             };
         }
 
-        case types.GET_SERVICES_REQUEST_SUCCESS : {
+        case types.POST_SERVICES_REQUEST_SUCCESS : {
             return {
                 ...state,
-                services:action.payload,
                 isFetching: false
             }
         }
 
-        case types.GET_SERVICES_REQUEST_FAIL : {
+        case types.POST_SERVICES_REQUEST_FAIL : {
             return {
                 ...state,
-                error:action.payload,
+                error: action.payload,
                 isFetching: false
             }
         }
 
 // -----------------------------------------------------------------------------------------------------------------
-case types.POST_DOCTORS_REQUEST : {
-    return {
-        ...state,
-        isFetching: true
-    };
-}
-
-case types.POST_DOCTORS_REQUEST_SUCCESS : {
-    return {
-        ...state,
-        isFetching: false
-    }
-}
-
-case types.POST_DOCTORS_REQUEST_FAIL : {
-    return {
-        ...state,
-        error: action.payload,
-        isFetching: false
-    }
-}
-
-// _______________________________________________________________________________
 
-case types.POST_SERVICES_REQUEST : {
-    return {
-        ...state,
-        isFetching: true
-    };
-}
+        case types.POST_ORDERS_REQUEST : {
+            return {
+                ...state,
+                isFetching: true
+            };
+        }
 
-case types.POST_SERVICES_REQUEST_SUCCESS : {
-    return {
-        ...state,
-        isFetching: false
-    }
-}
+        case types.POST_ORDERS_REQUEST_SUCCESS : {
+            return {
+                ...state,
+                appointment: defaultState.appointment,
+                orders:action.payload,
+                isFetching: false
+            }
+        }
 
-case types.POST_SERVICES_REQUEST_FAIL : {
-    return {
-        ...state,
-        error: action.payload,
-        isFetching: false
-    }
-}
+        case types.POST_ORDERS_REQUEST_FAIL : {
+            return {
+                ...state,
+                error:action.payload,
+                isFetching: false
+            }
+        }
 
+// -----------------------------------------------------------------------------------------------------------------
 
         default:
             return state

+ 0 - 38
src/store/app/actionTypes.js

@@ -1,38 +0,0 @@
-export const GET_DOCTORS_REQUEST = "GET_DOCTORS_REQUEST";
-export const GET_DOCTORS_REQUEST_SUCCESS = "GET_DOCTORS_REQUEST_SUCCESS";
-export const GET_DOCTORS_REQUEST_FAIL = "GET_DOCTORS_REQUEST_FAIL";
-
-export const GET_SERVICES_REQUEST = "GET_SERVICES_REQUEST";
-export const GET_SERVICES_REQUEST_SUCCESS = "GET_SERVICES_REQUEST_SUCCESS";
-export const GET_SERVICES_REQUEST_FAIL = "GET_SERVICES_REQUEST_FAIL";
-
-export const GET_ALL_REQUEST = "GET_ALL_REQUEST";
-export const GET_ALL_REQUEST_SUCCESS = "GET_ALL_REQUEST_SUCCESS";
-export const GET_ALL_REQUEST_FAIL = "GET_ALL_REQUEST_FAIL";
-
-export const PUT_ORDERS_REQUEST = "PUT_ORDERS_REQUEST";
-export const PUT_ORDERS_REQUEST_SUCCESS = "PUT_ORDERS_REQUEST_SUCCESS";
-export const PUT_ORDERS_REQUEST_FAIL = "PUT_ORDERS_REQUEST_FAIL";
-
-export const CHANGE_APPOINTMENT_DATE= "CHANGE_APPOINTMENT_DATE";
-export const CHANGE_APPOINTMENT_DOCTOR= "CHANGE_APPOINTMENT_DOCTOR";
-export const CHANGE_APPOINTMENT_TIME= "CHANGE_APPOINTMENT_TIME";
-export const CHANGE_APPOINTMENT_SPEC= "CHANGE_APPOINTMENT_SPEC";
-export const CHANGE_APPOINTMENT_COMMENT= "CHANGE_APPOINTMENT_COMMENT";
-export const CLEAR_APPOINTMENT= "CLEAR_APPOINTMENT";
-
-export const AUTH_REQUEST = "GET_AUTH_REQUEST";
-export const AUTH_REQUEST_SUCCESS = "AUTH_REQUEST_SUCCESS";
-export const AUTH_REQUEST_FAIL = "AUTH_REQUEST_FAIL";
-
-export const REGISTRATION_REQUEST = "REQISTRATION_REQUEST";
-export const REGISTRATION_REQUEST_SUCCESS = "REGISTRATION_REQUEST_SUCCESS";
-export const REGISTRATION_REQUEST_FAIL = "REGISTRATION_REQUEST_FAIL";
-
-export const POST_DOCTORS_REQUEST = "POST_DOCTORS_REQUEST";
-export const POST_DOCTORS_REQUEST_SUCCESS = "POST_DOCTORS_REQUEST_SUCCESS";
-export const POST_DOCTORS_REQUEST_FAIL = "POST_DOCTORS_REQUEST_FAIL";
-
-export const POST_SERVICES_REQUEST = "POST_SERVICES_REQUEST";
-export const POST_SERVICES_REQUEST_SUCCESS = "POST_SERVICES_REQUEST_SUCCESS";
-export const POST_SERVICES_REQUEST_FAIL = "POST_SERVICES_REQUEST_FAIL";

+ 0 - 131
src/store/app/actions.js

@@ -1,131 +0,0 @@
-// import axios from "axios";
-import * as types from "./actionTypes";
-
-
-
-const URL = "https://team-app-28f4a.firebaseio.com/";
-// https://api-clinics.herokuapp.com/api/v1/services"
-
-// -----------------------------------------------------------------------------------------------------------------
-
-export const getDoctorsRequest = payload => ({
-    type: types.GET_DOCTORS_REQUEST,
-    payload
-});
-
-const getDoctorsRequestSuccess = payload => ({
-    type: types.GET_DOCTORS_REQUEST_SUCCESS,
-    payload
-});
-
-const getDoctorsRequestFail = payload => ({
-    type: types.GET_DOCTORS_REQUEST_FAIL,
-    payload
-});
-
-export const getDoctors = () => dispatch => {
-    dispatch(getDoctorsRequest());
-    return fetch(`${URL}doctors.json`, {
-        method: "GET",
-        // credentials: "include"
-    })
-        .then(res => res.json())
-        .then(res => dispatch(getDoctorsRequestSuccess(res)))
-        .catch(err => dispatch(getDoctorsRequestFail(err)));
-};
-// _____________________________________________________________________________________
-
-const getServicesRequest = payload => ({
-    type: types.GET_SERVICES_REQUEST,
-    payload
-});
-
-const getServicesRequestSuccess = payload => ({
-    type: types.GET_SERVICES_REQUEST_SUCCESS,
-    payload
-});
-
-const getServicesRequestFail = payload => ({
-    type: types.GET_SERVICES_REQUEST_FAIL,
-    payload
-});
-
-export const getServices = () => dispatch => {
-    dispatch(getServicesRequest());
-    return fetch(`${URL}services.json`, {
-        method: "GET",
-        // credentials: "include"
-    })
-        .then(res => res.json())
-        .then(res => dispatch(getServicesRequestSuccess(res)))
-        .catch(err => dispatch(getServicesRequestFail(err)));
-};
-
-
-// _____________________________________________________________________________________
-export const postDoctorsRequest = payload => ({
-    type: types.POST_DOCTORS_REQUEST,
-    payload
-});
-
-const postDoctorsRequestSuccess = payload => ({
-    type: types.POST_DOCTORS_REQUEST_SUCCESS,
-    payload
-});
-
-const postDoctorsRequestFail = payload => ({
-    type: types.POST_DOCTORS_REQUEST_FAIL,
-    payload
-});
-
-export const postDoctors = (payload) => dispatch => {
-    console.log(payload)
-    dispatch(postDoctorsRequest());
-    return fetch("https://api-clinics.herokuapp.com/api/v1/doctors", {
-        method: "POST",
-        credentials: "include",
-        headers: {
-            "Content-Type": "application/json"
-        },
-        body: JSON.stringify(payload)
-    })
-        .then(res => res.json())
-        .then(res => dispatch(postDoctorsRequestSuccess(res)))
-        .catch(err => dispatch(postDoctorsRequestFail(err)));
-};
-
-// -----------------------------------------------------------------------------------------------------------------
-
-export const postServicesRequest = payload => ({
-    type: types.POST_SERVICES_REQUEST,
-    payload
-});
-
-const postServicesRequestSuccess = payload => ({
-    type: types.POST_SERVICES_REQUEST_SUCCESS,
-    payload
-});
-
-const postServicesRequestFail = payload => ({
-    type: types.POST_SERVICES_REQUEST_FAIL,
-    payload
-});
-
-export const postServices = (payload) => dispatch => {
-    // console.log(payload)
-    dispatch(postServicesRequest());
-    return fetch("https://api-clinics.herokuapp.com/api/v1/services", {
-        method: "POST",
-        credentials: "include",
-        headers: {
-            "Content-Type": "application/json"
-        },
-        body: JSON.stringify(payload)
-    })
-        .then(res => res.json())
-        .then(res =>  dispatch(postServicesRequestSuccess(res)))
-        .catch(err => dispatch(postServicesRequestFail(err)))
-};
-
-// _____________________________________________________________
-

+ 0 - 128
src/store/app/reducers.js

@@ -1,128 +0,0 @@
-import * as types from './actionTypes'
-
-const defaultState = {
-    doctors:[  ],
-    services:{
-        service1:{id:1},
-        service2:{id:2},
-        service3:{id:3},
-        service4:{id:4},
-        service5:{id:5},
-        service6:{id:6},
-        service7:{id:7},
-        service8:{id:8},
-        service9:{id:9},
-    },
-    isFetching:false,
-    error: null,
-
-};
-
-// -----------------------------------------------------------------------------------------------------------------
-
-export const appReducer = (state = defaultState,action) => {
-
-    switch (action.type) {
-// -----------------------------------------------------------------------------------------------------------------
-
-        case types.GET_DOCTORS_REQUEST : {
-            return {
-                ...state,
-                isFetching: true
-            };
-        }
-
-        case types.GET_DOCTORS_REQUEST_SUCCESS : {
-            return {
-                ...state,
-                doctors:action.payload,
-                isFetching: false
-            }
-        }
-
-        case types.GET_DOCTORS_REQUEST_FAIL : {
-            return {
-                ...state,
-                error:action.payload,
-                isFetching: false
-            }
-        }
-
-// -----------------------------------------------------------------------------------------------------------------
-
-        case types.GET_SERVICES_REQUEST : {
-            return {
-                ...state,
-                isFetching: true
-            };
-        }
-
-        case types.GET_SERVICES_REQUEST_SUCCESS : {
-            return {
-                ...state,
-                services:action.payload,
-                isFetching: false
-            }
-        }
-
-        case types.GET_SERVICES_REQUEST_FAIL : {
-            return {
-                ...state,
-                error:action.payload,
-                isFetching: false
-            }
-        }
-
-// -----------------------------------------------------------------------------------------------------------------
-        case types.POST_DOCTORS_REQUEST : {
-            return {
-                ...state,
-                isFetching: true
-            };
-        }
-
-        case types.POST_DOCTORS_REQUEST_SUCCESS : {
-            return {
-                ...state,
-                isFetching: false
-            }
-        }
-
-        case types.POST_DOCTORS_REQUEST_FAIL : {
-            return {
-                ...state,
-                error: action.payload,
-                isFetching: false
-            }
-        }
-
-// _______________________________________________________________________________
-
-        case types.POST_SERVICES_REQUEST : {
-            return {
-                ...state,
-                isFetching: true
-            };
-        }
-
-        case types.POST_SERVICES_REQUEST_SUCCESS : {
-            return {
-                ...state,
-                isFetching: false
-            }
-        }
-
-        case types.POST_SERVICES_REQUEST_FAIL : {
-            return {
-                ...state,
-                error: action.payload,
-                isFetching: false
-            }
-        }
-
-// _______________________________________________________________________________
-
-        default:
-            return state
-    }
-};