From c3a46daba1da54a4585a90c755cb97855ae33d21 Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Sun, 5 Aug 2018 21:03:47 -0500 Subject: [PATCH] Snooze snoozes The API call works, and it doesn't appear in the journal; just need to write the page to view snoozed requests, so they can unsnoozed if required --- src/app/src/api/index.js | 7 ++ src/app/src/components/Journal.vue | 6 +- .../src/components/request/RequestCard.vue | 2 +- .../src/components/request/SnoozeRequest.vue | 72 +++++++++++++++++++ src/app/src/store/action-types.js | 4 +- src/app/src/store/index.js | 11 +++ 6 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 src/app/src/components/request/SnoozeRequest.vue diff --git a/src/app/src/api/index.js b/src/app/src/api/index.js index d51e1ea..5d24c4d 100644 --- a/src/app/src/api/index.js +++ b/src/app/src/api/index.js @@ -66,6 +66,13 @@ export default { */ journal: () => http.get('journal'), + /** + * Snooze a request until the given time + * @param requestId {string} The ID of the prayer request to be snoozed + * @param until {number} The ticks until which the request should be snoozed + */ + snoozeRequest: (requestId, until) => http.post(`request/${requestId}/snooze`, { until }), + /** * Update a prayer request * @param request The request (should have requestId, status, and updateText properties) diff --git a/src/app/src/components/Journal.vue b/src/app/src/components/Journal.vue index 6ca64e0..1b65c13 100644 --- a/src/app/src/components/Journal.vue +++ b/src/app/src/components/Journal.vue @@ -18,6 +18,8 @@ article notes-edit(:events='eventBus' :toast='toast') full-request(:events='eventBus') + snooze-request(:events='eventBus' + :toast='toast') diff --git a/src/app/src/store/action-types.js b/src/app/src/store/action-types.js index 2c2a2a3..b671bab 100644 --- a/src/app/src/store/action-types.js +++ b/src/app/src/store/action-types.js @@ -6,5 +6,7 @@ export default { /** Action to load the user's prayer journal */ LOAD_JOURNAL: 'load-journal', /** Action to update a request */ - UPDATE_REQUEST: 'update-request' + UPDATE_REQUEST: 'update-request', + /** Action to snooze a request */ + SNOOZE_REQUEST: 'snooze-request' } diff --git a/src/app/src/store/index.js b/src/app/src/store/index.js index 739a2ec..8eb0753 100644 --- a/src/app/src/store/index.js +++ b/src/app/src/store/index.js @@ -109,6 +109,17 @@ export default new Vuex.Store({ logError(err) progress.fail() } + }, + async [actions.SNOOZE_REQUEST] ({ commit }, { progress, requestId, until }) { + progress.start() + try { + await api.snoozeRequest(requestId, until) + const request = await api.getRequest(requestId) + commit(mutations.REQUEST_UPDATED, request.data) + } catch (err) { + logError(err) + progress.fail() + } } }, getters: {},