Admin Page
+
diff --git a/src/config.js b/src/config.js
index 2782a0b..161087f 100644
--- a/src/config.js
+++ b/src/config.js
@@ -1,12 +1,12 @@
import firebase from 'firebase'
-export const appName = 'advreact-1610'
+export const appName = 'react-course-f262b'
firebase.initializeApp({
- apiKey: "AIzaSyB31xpTtp4Jln_hb2kAbE4PGf6Mi8EgLyA",
authDomain: `${appName}.firebaseapp.com`,
databaseURL: `https://${appName}.firebaseio.com`,
projectId: appName,
- storageBucket: "",
- messagingSenderId: "397157634637"
+ apiKey: "AIzaSyAt-smU_1tqNdkj9pmSpVLxqaOjhDwf4dk",
+ storageBucket: "react-course-f262b.appspot.com",
+ messagingSenderId: "447165438476"
})
\ No newline at end of file
diff --git a/src/ducks/events.js b/src/ducks/events.js
index dd75bae..f3e2af7 100644
--- a/src/ducks/events.js
+++ b/src/ducks/events.js
@@ -18,6 +18,10 @@ export const FETCH_LAZY_REQUEST = `${prefix}/FETCH_LAZY_REQUEST`
export const FETCH_LAZY_START = `${prefix}/FETCH_LAZY_START`
export const FETCH_LAZY_SUCCESS = `${prefix}/FETCH_LAZY_SUCCESS`
+export const DELETE_EVENT_REQUEST = `${prefix}/DELETE_EVENT_REQUEST`
+export const DELETE_EVENT_START = `${prefix}/DELETE_EVENT_START`
+export const DELETE_EVENT_SUCCESS = `${prefix}/DELETE_EVENT_SUCCESS`
+
export const SELECT_EVENT = `${prefix}/SELECT_EVENT`
@@ -63,6 +67,9 @@ export default function reducer(state = new ReducerRecord(), action) {
case SELECT_EVENT:
return state.update('selected', selected => selected.add(payload.uid))
+ case DELETE_EVENT_SUCCESS:
+ return state
+ .deleteIn(['entities', action.payload.uid]);
default:
return state
@@ -82,6 +89,8 @@ export const eventListSelector = createSelector(entitiesSelector, entities => en
export const selectedEventsSelector = createSelector(entitiesSelector, selectionSelector, (entities, selection) =>
selection.map(uid => entities.get(uid))
)
+export const idSelector = (state, props) => props.id
+export const eventSelector = createSelector(entitiesSelector, idSelector, (entities, id) => entities.get(id))
/**
* Action Creators
@@ -106,6 +115,13 @@ export function fetchLazy() {
}
}
+export function deleteEvent(uid) {
+ return {
+ type: DELETE_EVENT_REQUEST,
+ payload: { uid }
+ }
+}
+
/**
* Sagas
* */
@@ -154,6 +170,21 @@ export const fetchLazySaga = function * () {
}
}
+export const deleteEventSaga = function * ({payload}) {
+ const ref = firebase.database().ref(`events/${payload.uid}`);
+
+ yield put({
+ type: DELETE_EVENT_START
+ });
+
+ yield call([ref, ref.remove]);
+
+ yield put({
+ type: DELETE_EVENT_SUCCESS,
+ payload
+ })
+};
+
//lazy fetch FB
/*
firebase.database().ref('events')
@@ -165,6 +196,7 @@ firebase.database().ref('events')
export function* saga() {
yield all([
takeEvery(FETCH_ALL_REQUEST, fetchAllSaga),
+ takeEvery(DELETE_EVENT_REQUEST, deleteEventSaga),
fetchLazySaga()
])
}
\ No newline at end of file