forked from benwinding/react-admin-firebase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
82 lines (73 loc) · 2.13 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import * as React from 'react';
import { PostList, PostShow, PostCreate, PostEdit } from './posts';
import { UserList, UserShow, UserCreate, UserEdit } from './users';
import { Admin, Resource } from 'react-admin';
import {
FirebaseDataProvider,
FirebaseAuthProvider,
} from 'react-admin-firebase';
import firebase from "firebase/compat/app";
import UserIcon from '@material-ui/icons/People';
import CommentIcon from '@material-ui/icons/Comment';
import * as Posts from "./posts";
import * as Users from "./users";
import * as Comments from "./comments";
import CustomLoginPage from './CustomLoginPage';
import EventMonitor from './EventMonitor';
let firebaseConfig;
try {
firebaseConfig = JSON.parse(process.env.REACT_APP_FIREBASE_CONFIG);
} catch (error) {
console.error('Error parsing (maybe quotes aren\'t escaped?): ', {REACT_APP_FIREBASE_CONFIG: process.env.REACT_APP_FIREBASE_CONFIG}, error);
}
const firebaseApp = firebase.initializeApp(firebaseConfig);
export const storage = firebase.storage(firebaseApp)
console.log({firebaseConfig, firebaseApp});
const authProvider = FirebaseAuthProvider(firebaseConfig);
const dataProvider = FirebaseDataProvider(firebaseConfig, {
logging: true,
// rootRef: 'rootrefcollection/QQG2McwjR2Bohi9OwQzP',
app: firebaseApp,
// watch: ['posts'];
// dontwatch: ['comments'];
persistence: 'local',
// disableMeta: true
dontAddIdFieldToDoc: true,
lazyLoading: {
enabled: true,
},
firestoreCostsLogger: {
enabled: true,
},
});
class App extends React.Component {
render() {
return (
<>
<Admin
loginPage={CustomLoginPage}
dataProvider={dataProvider}
authProvider={authProvider}
>
<Resource
name="posts"
list={PostList}
show={PostShow}
create={PostCreate}
edit={PostEdit}
/>
<Resource
name="users"
icon={UserIcon}
list={UserList}
show={UserShow}
create={UserCreate}
edit={UserEdit}
/>
</Admin>
<EventMonitor />
</>
);
}
}
export default App;