diff options
| author | Michael Foiani <mfoiani2019@communiyschoolnaples.org> | 2018-08-13 16:22:44 -0400 |
|---|---|---|
| committer | Michael Foiani <mfoiani2019@communiyschoolnaples.org> | 2018-08-13 16:22:44 -0400 |
| commit | f14bf1edb18b02359fefb61f6d5f342892f7056c (patch) | |
| tree | ffb354db6491f40620bf36f555fbb8f844958935 /src/actions | |
| parent | 6e8b40c5d78eb6d6cfb3c4d8f2d84b53e55523d0 (diff) | |
Trying to find ways to get img in firebase storage to show in admin panel when viewing requests.
Diffstat (limited to 'src/actions')
| -rw-r--r-- | src/actions/firebaseAdmin.js | 2 | ||||
| -rw-r--r-- | src/actions/firebaseFirestore.js | 12 | ||||
| -rw-r--r-- | src/actions/firebaseStorage.js | 2 |
3 files changed, 13 insertions, 3 deletions
diff --git a/src/actions/firebaseAdmin.js b/src/actions/firebaseAdmin.js index 4a00833..4b64cbf 100644 --- a/src/actions/firebaseAdmin.js +++ b/src/actions/firebaseAdmin.js @@ -76,7 +76,7 @@ export const adminRejectHours = (_id) => (dispatch) => { export const adminDeleteRequest = (_id) => (dispatch) => { var docRef = firestore.collection('requests').doc(_id); docRef.delete().then(() => { - console.log('Deleted request with id ' + _id); + //Delete associated picture }); } diff --git a/src/actions/firebaseFirestore.js b/src/actions/firebaseFirestore.js index 3efeb6a..789d9d3 100644 --- a/src/actions/firebaseFirestore.js +++ b/src/actions/firebaseFirestore.js @@ -1,4 +1,4 @@ -import { firestore } from '../firebase.js'; +import { firestore, storage } from '../firebase.js'; export const UPDATE_DIVISON = 'UPDATE_DIVISON'; export const UPDATE_HOURS = 'UPDATE_HOURS'; @@ -104,13 +104,21 @@ export const requestHours = (_time, _trainee, _location, _subject, _date, _pictu var docRef = firestore.collection('requests'); const _uid = getState().firebaseAuth.uid; const _email = getState().firebaseAuth.userEmail; + var _imgPath = ""; + + var storageRef = storage.ref().child('requests/' + _uid + '/' + _pictureName); + storageRef.getDownloadURL().then((url) => { + _imgPath = url; + }); + + docRef.add({ time: _time, trainee: _trainee, location: _location, subject: _subject, day: _date, - picture: _pictureName, + imgPath: _imgPath, uid: _uid, email: _email }); diff --git a/src/actions/firebaseStorage.js b/src/actions/firebaseStorage.js index 0367a38..d6a2192 100644 --- a/src/actions/firebaseStorage.js +++ b/src/actions/firebaseStorage.js @@ -14,6 +14,8 @@ export const uploadPicture = (file, uploader) => (dispatch, getState) => { console.log(percentage); uploader.value = percentage; }); + + dispatch(updatePicture(file.name)); } } |
