text: import firebase from "firebase";
  import {
    EMPLOYEE_UPDATE,
    EMPLOYEE_CREATE,
    EMPLOYEES_FETCH_SUCCESS
  } from "./types";
  import { Actions } from "react-native-router-flux";
  
  export const employeeUpdate = ({ prop, value }) => {
    return {
      type: EMPLOYEE_UPDATE,
      payload: { prop, value }
    };
  };
  
  export const employeeCreate = ({ name, phone, shift }) => {
    // console.log(name, phone, shift);
    const { currentUser } = firebase.auth();
  
    return dispatch => {
      firebase
        .database()
        .ref(`/users/${currentUser.uid}/employees`)
        .push({ name, phone, shift })
        .then(() => {
          dispatch({ type: EMPLOYEE_CREATE }); //Clear the form after insert in fireabse
          Actions.employeeList({ type: "reset" }); // Don't stack the app just add employee and reset to employeeList
        });
    };
  };
  
  export const employeesFetch = () => {
    const { currentUser } = firebase.auth();
    return dispatch => {
      firebase
        .database()
        .ref(`/users/${currentUser.uid}/employees`)
        .on("value", snapshot => {
          dispatch({ type: EMPLOYEES_FETCH_SUCCESS, payload: snapshot.val() });
        });
    };
  };
  