Fakultas Ilmu Komputer UI

actions.tsx 493 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import firebase from "firebase/app";
import { Dispatch } from "react-redux/node_modules/@types/react";

const db = firebase.firestore();

export const getUser = (uid) => {
  return async (dispatch: Dispatch<any>) => {
    try {
      const user = await db.collection("users").doc(uid).get();

      dispatch({ type: "LOGIN", payload: { ...user.data(), id: user.id } });
    } catch (e) {
      console.log(e);
    }
  };
};

//TODO add loginUser

//TODO add logoutUser

//TODO change password