Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
[WOLFPAL-67] Implement pending confirmation alerts (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Henniges authored May 25, 2021
1 parent a6bf8eb commit c4dc77c
Showing 1 changed file with 41 additions and 8 deletions.
49 changes: 41 additions & 8 deletions client/store/goals/weekly.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ export const state = () => ({
success: null,
error: null,
errors: {
title: null,
},
},
title: null
}
}
})

export const actions = {
Expand All @@ -27,13 +27,19 @@ export const actions = {

commit('SET_GOAL_IS_COMPLETE', {
index,
isCompleted: true,
isCompleted: true
})
commit('SET_MESSAGE_ERROR', null)
commit('SET_MESSAGE_SUCCESS', 'Goal has been marked as completed')
} catch (e) {
commit('SET_MESSAGE_SUCCESS', null)
switch (e.response.data.code) {
case 'PENDING_CONFIRMATION':
commit(
'SET_MESSAGE_ERROR',
'Your account must be activated before you can do that. Please check your email you signed up with.'
)
break
case 'NON_EXISTENT':
commit('SET_MESSAGE_ERROR', 'Goal is not found.')
break
Expand All @@ -51,13 +57,19 @@ export const actions = {

commit('SET_GOAL_IS_COMPLETE', {
index,
isCompleted: false,
isCompleted: false
})
commit('SET_MESSAGE_ERROR', null)
commit('SET_MESSAGE_SUCCESS', 'Goal has been marked as not completed')
} catch (e) {
commit('SET_MESSAGE_SUCCESS', null)
switch (e.response.data.code) {
case 'PENDING_CONFIRMATION':
commit(
'SET_MESSAGE_ERROR',
'Your account must be activated before you can do that. Please check your email you signed up with.'
)
break
case 'NON_EXISTENT':
commit('SET_MESSAGE_ERROR', 'Goal is not found.')
break
Expand All @@ -83,6 +95,12 @@ export const actions = {
} catch (e) {
commit('SET_MESSAGE_SUCCESS', null)
switch (e.response.data.code) {
case 'PENDING_CONFIRMATION':
commit(
'SET_MESSAGE_ERROR',
'Your account must be activated before you can do that. Please check your email you signed up with.'
)
break
case 'NON_EXISTENT':
commit('SET_MESSAGE_ERROR', 'Goal is might be already deleted.')
break
Expand All @@ -99,6 +117,21 @@ export const actions = {
commit('PUSH_GOAL', res.goal)
} catch (e) {
commit('SET_MESSAGE_SUCCESS', null)
if (e.response.data.code) {
switch (e.response.data.code) {
case 'PENDING_CONFIRMATION':
commit(
'SET_MESSAGE_ERROR',
'Your account must be activated before you can do that. Please check your email you signed up with.'
)
break

default:
commit('SET_MESSAGE_ERROR', 'Oops.. Something Went Wrong..')
break
}
return
}
if (e.response.data.codes) {
if (e.response.data.codes.title)
switch (e.response.data.codes.title) {
Expand All @@ -111,7 +144,7 @@ export const actions = {
commit('SET_MESSAGE_ERROR', 'Oops.. Something Went Wrong..')
}
}
},
}
}

export const mutations = {
Expand All @@ -136,7 +169,7 @@ export const mutations = {
},
SET_MESSAGE_ERRORS_TITLE: (state, message) => {
return (state.messages.errors.title = message)
},
}
}

export const getters = {
Expand All @@ -151,5 +184,5 @@ export const getters = {
},
MESSAGE_ERRORS_TITLE: (state) => {
return state.messages.errors.title
},
}
}

0 comments on commit c4dc77c

Please sign in to comment.