No Description

index.js 1009B

123456789101112131415161718192021222324252627282930
  1. import firebase from "firebase";
  2. import { USER_STATE_CHANGE } from "../constants";
  3. export function fetchUser() {
  4. return ((dispatch) => {
  5. firebase.firestore()
  6. .collection("Users")
  7. .doc(firebase.auth().currentUser.uid)
  8. .get()
  9. .then((snapshot) => {
  10. if(snapshot.exists){
  11. dispatch({type: USER_STATE_CHANGE, currentUser: snapshot.data()})
  12. }
  13. else{
  14. firebase.firestore().collection("Interpreters")
  15. .doc(firebase.auth().currentUser.uid)
  16. .get()
  17. .then((snapshot) => {
  18. if(snapshot.exists){
  19. dispatch({type: USER_STATE_CHANGE, currentUser: snapshot.data()})
  20. }
  21. else{
  22. console.log("DOES NOT EXIST")
  23. }
  24. })
  25. }
  26. })
  27. })
  28. }