Skip to content

Commit b28f0ee

Browse files
committed
Merge branch 'feature/interface' of https://github.com/CreateThrive/react-firebase-admin into feature/interface
2 parents 95690de + acba346 commit b28f0ee

File tree

13 files changed

+26
-24
lines changed

13 files changed

+26
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ React Firebase Admin is our in-house admin dashboard boilerplate, used in many o
6464
- PWA ready thanks to CRA and Firebase
6565
- Multi-tenancy
6666
- Internationalization (English/Spanish)
67-
- Interface to choose between Real Time Database and Firestore
67+
- Ability to choose between Firebase Realtime Database or Firestore
6868

6969
## Tech Stack
7070

firestore.rules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ service cloud.firestore {
1313

1414
match /users/{userId} {
1515

16-
function isUser() {
16+
function isIdentified() {
1717
return request.auth.uid == userId;
1818
}
1919

20-
allow read: if isAuthenticated() && (isAdmin() || isUser());
20+
allow read: if isAuthenticated() && (isAdmin() || isIdentified());
2121

2222
allow write: if isAuthenticated() && isAdmin();
2323

24-
allow update: if isAuthenticated() && (isAdmin() || isUser());
24+
allow update: if isAuthenticated() && (isAdmin() || isIdentified());
2525

2626
allow delete: if isAuthenticated() && isAdmin();
2727
}

functions/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

functions/setupProject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const questions = [
3333
type: 'list',
3434
name: 'database',
3535
message: 'Select the database of your choice:',
36-
choices: ['Real Time Database', 'Firestore'],
36+
choices: ['Realtime Database', 'Firestore'],
3737
},
3838
];
3939

functions/test/db/users/onDelete.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'mocha';
66

77
chai.use(chaiAsPromised);
88

9-
describe('onDelete Real Time Database', () => {
9+
describe('onDelete Realtime Database', () => {
1010
let userRecord: any;
1111

1212
it('should delete the user from the authentication section', async () => {

functions/test/db/users/onUpdate.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as chai from 'chai';
33
import onUpdate from '../../../src/db/users/onUpdate.function';
44
import 'mocha';
55

6-
describe('onUpdate Real Time Database', () => {
6+
describe('onUpdate Realtime Database', () => {
77
let userRecord: any;
88

99
before(async () => {

src/components/UserForm/index.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@ import './UserForm.scss';
1212
import DatePicker from '../DatePicker';
1313

1414
const UserForm = ({ isEditing, isProfile, user, setUser, action }) => {
15-
const { loading } = useSelector(
15+
const { loading, success } = useSelector(
1616
(state) => ({
1717
loading: state.users.loading,
18+
success: state.users.success,
1819
}),
1920
shallowEqual
2021
);
2122

2223
const dispatch = useDispatch();
2324

2425
useEffect(() => {
26+
if (success) {
27+
setUser((prevState) => ({ ...prevState, file: null }));
28+
}
2529
return () => dispatch(usersCleanUp());
26-
}, [dispatch]);
30+
}, [dispatch, success]);
2731

2832
const onChangeHandler = useChangeHandler(setUser);
2933

@@ -242,7 +246,7 @@ const UserForm = ({ isEditing, isProfile, user, setUser, action }) => {
242246
/>
243247
<span className="file-cta">
244248
<span className="file-icon">
245-
<i className="fas fa-upload" />
249+
<i className="mdi mdi-upload" />
246250
</span>
247251
<span className="file-label">
248252
{user.file

src/firebase.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'firebase/database';
33
import 'firebase/auth';
44
import 'firebase/storage';
55
import 'firebase/functions';
6+
import 'firebase/firestore';
67

78
const config = {
89
apiKey: process.env.REACT_APP_FIRE_BASE_KEY,
@@ -12,7 +13,7 @@ const config = {
1213
storageBucket: process.env.REACT_APP_FIRE_BASE_STORAGE_BUCKET,
1314
messagingSenderId: process.env.REACT_APP_FIRE_BASE_MESSAGING_SENDER_ID,
1415
appId: process.env.REACT_APP_FIRE_BASE_APP_ID,
15-
measurementId: process.env.REACT_APP_FIRE_BASE_MEASURMENT_ID
16+
measurementId: process.env.REACT_APP_FIRE_BASE_MEASURMENT_ID,
1617
};
1718

1819
firebase.initializeApp(config);

src/pages/Users/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const Users = () => {
3030

3131
const dispatch = useDispatch();
3232

33-
const [search, setSearch] = useState();
33+
const [search, setSearch] = useState('');
3434

3535
useEffect(() => {
3636
if (isAdmin) {

src/state/actions/users.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
fetchDocument,
1010
createDocument,
1111
deleteDocument,
12-
modifyDocument,
12+
updateDocument,
1313
} from '../api';
1414

1515
export const USERS_FETCH_DATA_INIT = createAction('USERS_FETCH_DATA_INIT');
@@ -256,7 +256,7 @@ export const modifyUser = ({
256256
isAdmin,
257257
logoUrl: logoUrl || newLogoUrl,
258258
};
259-
const updateUserDbTask = modifyDocument('users', id, userData);
259+
const updateUserDbTask = updateDocument('users', id, userData);
260260

261261
try {
262262
await Promise.all([deleteLogoTask, uploadLogoTask, updateUserDbTask]);

0 commit comments

Comments
 (0)