aboutsummaryrefslogtreecommitdiff
path: root/src/actions
diff options
context:
space:
mode:
Diffstat (limited to 'src/actions')
-rw-r--r--src/actions/firebaseAdmin.js16
-rw-r--r--src/actions/firebaseFirestore.js6
2 files changed, 13 insertions, 9 deletions
diff --git a/src/actions/firebaseAdmin.js b/src/actions/firebaseAdmin.js
index 4b64cbf..5ca0d17 100644
--- a/src/actions/firebaseAdmin.js
+++ b/src/actions/firebaseAdmin.js
@@ -1,4 +1,4 @@
-import { firestore } from '../firebase.js';
+import { firestore, storage } from '../firebase.js';
export const UPDATE_ADMIN = 'UPDATE_ADMIN';
export const UPDATE_ADMIN_REQUESTS = 'UPDATE_ADMIN_REQUESTS';
@@ -69,14 +69,16 @@ export const snapshotAdminCompList = () => (dispatch) => {
});
}
-export const adminRejectHours = (_id) => (dispatch) => {
- dispatch(adminDeleteRequest(_id));
+export const adminRejectHours = (_id, _path) => (dispatch) => {
+ dispatch(adminDeleteRequest(_id, _path));
}
-export const adminDeleteRequest = (_id) => (dispatch) => {
+export const adminDeleteRequest = (_id, _path) => (dispatch) => {
var docRef = firestore.collection('requests').doc(_id);
docRef.delete().then(() => {
- //Delete associated picture
+ var storageRef = storage.ref().child(_path);
+ storageRef.delete().then(() => {
+ });
});
}
@@ -95,7 +97,7 @@ export const adminListener = () => (dispatch) => {
}
}
-export const adminApproveHours = (_uid, _time, _id) => (dispatch) => {
+export const adminApproveHours = (_uid, _time, _id, _path) => (dispatch) => {
var docRef = firestore.collection('users').doc(_uid);
docRef.get().then((doc) => {
if(doc.exists) {
@@ -106,5 +108,5 @@ export const adminApproveHours = (_uid, _time, _id) => (dispatch) => {
});
}
});
- dispatch(adminDeleteRequest(_id));
+ dispatch(adminDeleteRequest(_id, _path));
}
diff --git a/src/actions/firebaseFirestore.js b/src/actions/firebaseFirestore.js
index 6ce8492..a95e0c8 100644
--- a/src/actions/firebaseFirestore.js
+++ b/src/actions/firebaseFirestore.js
@@ -104,8 +104,9 @@ export const requestHours = (_time, _trainee, _location, _subject, _date, _pictu
var docRef = firestore.collection('requests');
const _uid = getState().firebaseAuth.uid;
const _email = getState().firebaseAuth.userEmail;
+ const _path = 'requests/' + _uid + '/' + _pictureName;
- var storageRef = storage.ref().child('requests/' + _uid + '/' + _pictureName);
+ var storageRef = storage.ref().child(_path);
storageRef.getDownloadURL().then((url) => {
docRef.add({
time: _time,
@@ -113,7 +114,8 @@ export const requestHours = (_time, _trainee, _location, _subject, _date, _pictu
location: _location,
subject: _subject,
day: _date,
- imgPath: url,
+ imgUrl: url,
+ path: _path,
uid: _uid,
email: _email
});