Skip to content

Commit 8d14bc5

Browse files
committed
Refactor services code
1 parent 5dd8ad0 commit 8d14bc5

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

src/services/firebase/firebase.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
import app from 'firebase/app';
1+
import firebase from 'firebase/app';
2+
23
import 'firebase/auth';
34
import 'firebase/firestore';
45

56
import firebaseConfig from '../../config/firebaseConfig';
67

78
class Firebase {
89
constructor() {
9-
app.initializeApp(firebaseConfig);
10+
firebase.initializeApp(firebaseConfig);
11+
12+
this.auth = firebase.auth();
13+
this.firestore = firebase.firestore();
1014

11-
this.auth = app.auth();
12-
this.db = app.firestore();
15+
this.usersCollectionRef = this.firestore.collection('users');
1316
}
1417

1518
signUp = (email, password) =>
@@ -29,17 +32,9 @@ class Firebase {
2932

3033
updatePassword = password => this.auth.currentUser.updatePassword(password);
3134

32-
addUser = (uid, userData) =>
33-
this.db
34-
.collection('users')
35-
.doc(uid)
36-
.set(userData);
37-
38-
getUser = uid =>
39-
this.db
40-
.collection('users')
41-
.doc(uid)
42-
.get();
35+
addUser = (uid, userData) => this.usersCollectionRef.doc(uid).set(userData);
36+
37+
getUser = uid => this.usersCollectionRef.doc(uid).get();
4338
}
4439

4540
export default Firebase;

0 commit comments

Comments
 (0)