This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { createContext, ReactNode, useEffect, useState } from "react" | |
import { User as FirebaseUser } from "firebase/app" | |
import { Firestore } from "firebaseTypes" | |
import FirebaseApp from "../index" | |
import { User } from "state/users/userTypes" | |
import UserModel from "state/users/userModel" | |
type FirestoreContextType = { | |
firestore: Firestore | null | |
currentUser: User | null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import FirebaseApp from "./index" | |
class AuthManager { | |
async login({ email, password }: { email: string; password: string }) { | |
await FirebaseApp.auth().signInWithEmailAndPassword(email, password) | |
} | |
async logout() { | |
return FirebaseApp.auth().signOut() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { FirebaseModel } from "../firebaseTypes" | |
import { User } from "./userTypes" | |
export default class UserModel extends FirebaseModel { | |
public async getCurrentUser(userId: string): Promise<User> { | |
const currentUser = await this.store | |
.collection(UserModel.userCollection) | |
.doc(userId) | |
.get() | |
return { ...currentUser.data(), id: currentUser.id } as User |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import firebase from 'firebase/app'; | |
import FirebaseApp from '../index'; | |
import { Firestore } from 'firebaseTypes'; | |
export enum Collections { | |
USERS = 'users' | |
} | |
export default class FirebaseModel { | |
public store: Firestore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react" | |
import { render } from "react-dom" | |
import "styles/index.css" | |
import App from "App" | |
import { firebaseConfig } from "config/firebaseConfig" | |
import { initializeApp } from "firebase/app" | |
export default initializeApp(firebaseConfig) | |
render(<App />, document.getElementById("app")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const firebaseConfig = { | |
apiKey: "xxxxxxxxxx", | |
authDomain: "xxxxxxxxxx", | |
databaseURL: "xxxxxxxxxx", | |
projectId: "xxxxxxxxxx", | |
storageBucket: "xxxxxxxxxx", | |
messagingSenderId: "xxxxxxxxxx", | |
appId: "xxxxxxxxxx", | |
measurementId: "xxxxxxxxxx", | |
} |
NewerOlder