fix ajax requests
Signed-off-by: dartcafe <github@dartcafe.de>
This commit is contained in:
Родитель
d2b00a1e2c
Коммит
55f56794f8
|
@ -30,7 +30,7 @@ return [
|
|||
['name' => 'public#get_options', 'url' => '/s/{token}/options', 'verb' => 'GET'],
|
||||
['name' => 'public#get_votes', 'url' => '/s/{token}/votes', 'verb' => 'GET'],
|
||||
['name' => 'public#get_subscription', 'url' => '/s/{token}/subscription', 'verb' => 'GET'],
|
||||
['name' => 'public#set_email_address', 'url' => '/s/{token}/email', 'verb' => 'PUT'],
|
||||
['name' => 'public#set_email_address', 'url' => '/s/{token}/email/{emailAddress}', 'verb' => 'PUT'],
|
||||
['name' => 'public#set_display_name', 'url' => '/s/{token}/name/{displayName}', 'verb' => 'PUT'],
|
||||
['name' => 'public#delete_email_address', 'url' => '/s/{token}/email', 'verb' => 'DELETE'],
|
||||
|
||||
|
@ -65,7 +65,7 @@ return [
|
|||
['name' => 'poll#delete', 'url' => '/poll/{pollId}', 'verb' => 'DELETE'],
|
||||
|
||||
['name' => 'poll#toggleArchive', 'url' => '/poll/{pollId}/toggleArchive', 'verb' => 'PUT'],
|
||||
['name' => 'poll#clone', 'url' => '/poll/{pollId}/clone', 'verb' => 'GET'],
|
||||
['name' => 'poll#clone', 'url' => '/poll/{pollId}/clone', 'verb' => 'POST'],
|
||||
['name' => 'poll#getParticipantsEmailAddresses', 'url' => '/poll/{pollId}/addresses', 'verb' => 'GET'],
|
||||
['name' => 'poll#sendConfirmation', 'url' => '/poll/{pollId}/confirmation', 'verb' => 'POST'],
|
||||
['name' => 'poll#transfer_polls', 'url' => '/polls/transfer/{sourceUser}/{destinationUser}', 'verb' => 'PUT'],
|
||||
|
|
|
@ -28,9 +28,9 @@ const defaultActivities = () => ({
|
|||
list: [],
|
||||
})
|
||||
|
||||
const state = defaultActivities()
|
||||
|
||||
const namespaced = true
|
||||
const state = defaultActivities()
|
||||
const axiosDefaultConfig = { headers: { Accept: 'application/json' } }
|
||||
|
||||
const mutations = {
|
||||
set(state, payload) {
|
||||
|
@ -55,9 +55,10 @@ const actions = {
|
|||
params.append('limit', 50)
|
||||
params.append('object_type', 'poll')
|
||||
params.append('object_id', context.rootState.route.params.id)
|
||||
const endPoint = generateOcsUrl('apps/activity/api/v2/activity/filter?') + params
|
||||
|
||||
try {
|
||||
const response = await axios.get(generateOcsUrl('apps/activity/api/v2/activity/filter?') + params)
|
||||
const response = await axios.get(endPoint, axiosDefaultConfig)
|
||||
context.commit('set', response.data.ocs.data)
|
||||
} catch {
|
||||
context.commit('reset')
|
||||
|
|
|
@ -53,8 +53,9 @@ const defaultAppSettings = () => ({
|
|||
showMailAddressesGroups: [],
|
||||
})
|
||||
|
||||
const state = defaultAppSettings()
|
||||
const namespaced = true
|
||||
const state = defaultAppSettings()
|
||||
const axiosDefaultConfig = { headers: { Accept: 'application/json' } }
|
||||
|
||||
const mutations = {
|
||||
reset(state) {
|
||||
|
@ -73,7 +74,7 @@ const actions = {
|
|||
const endPoint = 'apps/polls/settings/app'
|
||||
try {
|
||||
const response = await axios.get(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
...axiosDefaultConfig,
|
||||
params: { time: +new Date() },
|
||||
})
|
||||
context.commit('set', response.data.appSettings)
|
||||
|
@ -86,9 +87,8 @@ const actions = {
|
|||
const endPoint = 'apps/polls/settings/app'
|
||||
try {
|
||||
const response = await axios.post(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
appSettings: context.state,
|
||||
})
|
||||
}, axiosDefaultConfig)
|
||||
context.commit('set', response.data.appSettings)
|
||||
} catch (e) {
|
||||
console.error('Error writing appSettings', { error: e.response }, { appSettings: state })
|
||||
|
|
|
@ -34,9 +34,9 @@ const defaultCombo = () => ({
|
|||
votes: [],
|
||||
})
|
||||
|
||||
const state = defaultCombo()
|
||||
|
||||
const namespaced = true
|
||||
const state = defaultCombo()
|
||||
const axiosDefaultConfig = { headers: { Accept: 'application/json' } }
|
||||
|
||||
const mutations = {
|
||||
set(state, payload) {
|
||||
|
@ -146,7 +146,7 @@ const actions = {
|
|||
const endPoint = `apps/polls/poll/${payload.pollId}/poll`
|
||||
try {
|
||||
const response = await axios.get(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
...axiosDefaultConfig,
|
||||
params: { time: +new Date() },
|
||||
})
|
||||
context.commit('addPoll', response.data)
|
||||
|
@ -160,7 +160,7 @@ const actions = {
|
|||
|
||||
try {
|
||||
const response = await axios.get(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
...axiosDefaultConfig,
|
||||
params: { time: +new Date() },
|
||||
})
|
||||
context.commit('addOptions', response.data)
|
||||
|
@ -174,7 +174,7 @@ const actions = {
|
|||
|
||||
try {
|
||||
const response = await axios.get(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
...axiosDefaultConfig,
|
||||
params: { time: +new Date() },
|
||||
})
|
||||
context.commit('addVotes', response.data)
|
||||
|
|
|
@ -28,9 +28,9 @@ const defaultComments = () => ({
|
|||
list: [],
|
||||
})
|
||||
|
||||
const state = defaultComments()
|
||||
|
||||
const namespaced = true
|
||||
const state = defaultComments()
|
||||
const axiosDefaultConfig = { headers: { Accept: 'application/json' } }
|
||||
|
||||
const mutations = {
|
||||
|
||||
|
@ -72,7 +72,7 @@ const actions = {
|
|||
|
||||
try {
|
||||
const response = await axios.get(generateUrl(`${endPoint}/comments`), {
|
||||
headers: { Accept: 'application/json' },
|
||||
...axiosDefaultConfig,
|
||||
params: { time: +new Date() },
|
||||
})
|
||||
context.commit('set', response.data)
|
||||
|
@ -97,9 +97,8 @@ const actions = {
|
|||
|
||||
try {
|
||||
await axios.post(generateUrl(`${endPoint}/comment`), {
|
||||
headers: { Accept: 'application/json' },
|
||||
message: payload.message,
|
||||
})
|
||||
}, axiosDefaultConfig)
|
||||
context.dispatch('list')
|
||||
// context.commit('add', { comment: response.data.comment })
|
||||
} catch (e) {
|
||||
|
@ -114,11 +113,10 @@ const actions = {
|
|||
if (context.rootState.route.name === 'publicVote') {
|
||||
endPoint = `${endPoint}/s/${context.rootState.route.params.token}`
|
||||
}
|
||||
endPoint = `${endPoint}/comment/${payload.comment.id}`
|
||||
|
||||
try {
|
||||
await axios.delete(generateUrl(`${endPoint}/comment/${payload.comment.id}`), {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
await axios.delete(generateUrl(endPoint), axiosDefaultConfig)
|
||||
context.commit('delete', { comment: payload.comment })
|
||||
} catch (e) {
|
||||
console.error('Error deleting comment', { error: e.response }, { payload })
|
||||
|
|
|
@ -31,9 +31,9 @@ const defaultOptions = () => ({
|
|||
ranked: false,
|
||||
})
|
||||
|
||||
const state = defaultOptions()
|
||||
|
||||
const namespaced = true
|
||||
const state = defaultOptions()
|
||||
const axiosDefaultConfig = { headers: { Accept: 'application/json' } }
|
||||
|
||||
const mutations = {
|
||||
set(state, payload) {
|
||||
|
@ -151,7 +151,7 @@ const actions = {
|
|||
|
||||
try {
|
||||
const response = await axios.get(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
...axiosDefaultConfig,
|
||||
params: { time: +new Date() },
|
||||
})
|
||||
context.commit('set', { options: response.data.options })
|
||||
|
@ -171,12 +171,11 @@ const actions = {
|
|||
|
||||
try {
|
||||
const response = await axios.post(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
pollId: context.rootState.route.params.id,
|
||||
timestamp: payload.timestamp,
|
||||
text: payload.text,
|
||||
duration: payload.duration,
|
||||
})
|
||||
}, axiosDefaultConfig)
|
||||
context.commit('setItem', { option: response.data.option })
|
||||
} catch (e) {
|
||||
console.error(`Error adding option: ${e.response.data}`, { error: e.response }, { payload })
|
||||
|
@ -190,10 +189,9 @@ const actions = {
|
|||
|
||||
try {
|
||||
const response = await axios.post(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
pollId: context.rootState.route.params.id,
|
||||
text: payload.text,
|
||||
})
|
||||
}, axiosDefaultConfig)
|
||||
context.commit('set', { options: response.data.options })
|
||||
} catch (e) {
|
||||
console.error(`Error adding option: ${e.response.data}`, { error: e.response }, { payload })
|
||||
|
@ -207,11 +205,10 @@ const actions = {
|
|||
|
||||
try {
|
||||
const response = await axios.put(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
timestamp: payload.option.timestamp,
|
||||
text: payload.option.timeStamp,
|
||||
duration: payload.option.duration,
|
||||
})
|
||||
}, axiosDefaultConfig)
|
||||
context.commit('setItem', { option: response.data.option })
|
||||
} catch (e) {
|
||||
console.error('Error updating option', { error: e.response }, { payload })
|
||||
|
@ -230,9 +227,7 @@ const actions = {
|
|||
}
|
||||
|
||||
try {
|
||||
await axios.delete(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
await axios.delete(generateUrl(endPoint), axiosDefaultConfig)
|
||||
context.commit('delete', { option: payload.option })
|
||||
} catch (e) {
|
||||
console.error('Error deleting option', { error: e.response }, { payload })
|
||||
|
@ -247,9 +242,7 @@ const actions = {
|
|||
context.commit('confirm', { option: payload.option })
|
||||
|
||||
try {
|
||||
const response = await axios.put(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
const response = await axios.put(generateUrl(endPoint), null, axiosDefaultConfig)
|
||||
context.commit('setItem', { option: response.data.option })
|
||||
} catch (e) {
|
||||
console.error('Error confirming option', { error: e.response }, { payload })
|
||||
|
@ -265,9 +258,8 @@ const actions = {
|
|||
|
||||
try {
|
||||
const response = await axios.post(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
options: payload,
|
||||
})
|
||||
}, axiosDefaultConfig)
|
||||
context.commit('set', { options: response.data.options })
|
||||
} catch (e) {
|
||||
console.error('Error reordering option', { error: e.response }, { payload })
|
||||
|
@ -281,11 +273,10 @@ const actions = {
|
|||
|
||||
try {
|
||||
const response = await axios.post(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
step: payload.sequence.step,
|
||||
unit: payload.sequence.unit.value,
|
||||
amount: payload.sequence.amount,
|
||||
})
|
||||
}, axiosDefaultConfig)
|
||||
context.commit('set', { options: response.data.options })
|
||||
} catch (e) {
|
||||
console.error('Error creating sequence', { error: e.response }, { payload })
|
||||
|
@ -299,10 +290,9 @@ const actions = {
|
|||
|
||||
try {
|
||||
const response = await axios.post(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
step: payload.shift.step,
|
||||
unit: payload.shift.unit.value,
|
||||
})
|
||||
}, axiosDefaultConfig)
|
||||
context.commit('set', { options: response.data.options })
|
||||
} catch (e) {
|
||||
console.error('Error shifting dates', { error: e.response }, { payload })
|
||||
|
@ -316,7 +306,7 @@ const actions = {
|
|||
|
||||
try {
|
||||
return await axios.get(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
...axiosDefaultConfig,
|
||||
params: { tz: Intl.DateTimeFormat().resolvedOptions().timeZone },
|
||||
})
|
||||
} catch (e) {
|
||||
|
|
|
@ -57,12 +57,10 @@ const defaultPoll = () => ({
|
|||
},
|
||||
})
|
||||
|
||||
const state = defaultPoll()
|
||||
|
||||
const namespaced = true
|
||||
const modules = {
|
||||
acl,
|
||||
}
|
||||
const modules = { acl }
|
||||
const state = defaultPoll()
|
||||
const axiosDefaultConfig = { headers: { Accept: 'application/json' } }
|
||||
|
||||
const mutations = {
|
||||
set(state, payload) {
|
||||
|
@ -188,7 +186,7 @@ const actions = {
|
|||
}
|
||||
try {
|
||||
const response = await axios.get(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
...axiosDefaultConfig,
|
||||
params: { time: +new Date() },
|
||||
})
|
||||
context.commit('set', response.data)
|
||||
|
@ -203,10 +201,9 @@ const actions = {
|
|||
const endPoint = 'apps/polls/poll/add'
|
||||
try {
|
||||
return await axios.post(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
title: payload.title,
|
||||
type: payload.type,
|
||||
})
|
||||
}, axiosDefaultConfig)
|
||||
} catch (e) {
|
||||
console.error('Error adding poll:', { error: e.response }, { state: context.state })
|
||||
throw e
|
||||
|
@ -216,7 +213,7 @@ const actions = {
|
|||
async clone(context, payload) {
|
||||
const endPoint = `apps/polls/poll/${payload.pollId}/clone`
|
||||
try {
|
||||
return await axios.get(generateUrl(endPoint))
|
||||
return await axios.post(generateUrl(endPoint), null, axiosDefaultConfig)
|
||||
} catch (e) {
|
||||
console.error('Error cloning poll', { error: e.response }, { payload })
|
||||
}
|
||||
|
@ -226,9 +223,9 @@ const actions = {
|
|||
const endPoint = `apps/polls/poll/${context.state.id}`
|
||||
try {
|
||||
const response = await axios.put(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
poll: context.state,
|
||||
})
|
||||
}, axiosDefaultConfig)
|
||||
|
||||
context.commit('set', response.data)
|
||||
context.commit('acl/set', response.data)
|
||||
context.dispatch('options/list', null, { root: true })
|
||||
|
@ -241,7 +238,7 @@ const actions = {
|
|||
async toggleArchive(context, payload) {
|
||||
const endPoint = `apps/polls/poll/${payload.pollId}/toggleArchive`
|
||||
try {
|
||||
await axios.put(generateUrl(endPoint))
|
||||
await axios.put(generateUrl(endPoint), null, axiosDefaultConfig)
|
||||
} catch (e) {
|
||||
console.error('Error archiving/restoring', { error: e.response }, { payload })
|
||||
}
|
||||
|
@ -250,7 +247,7 @@ const actions = {
|
|||
async sendConfirmation(context, payload) {
|
||||
const endPoint = `apps/polls/poll/${context.rootState.route.params.id}/confirmation`
|
||||
try {
|
||||
const response = await axios.post(generateUrl(endPoint))
|
||||
const response = await axios.post(generateUrl(endPoint), null, axiosDefaultConfig)
|
||||
return response.data.confirmations
|
||||
} catch (e) {
|
||||
console.error('Error sending confirmation', { error: e.response }, { payload })
|
||||
|
@ -260,9 +257,7 @@ const actions = {
|
|||
async delete(context, payload) {
|
||||
const endPoint = `apps/polls/poll/${payload.pollId}`
|
||||
try {
|
||||
await axios.delete(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
await axios.delete(generateUrl(endPoint), axiosDefaultConfig)
|
||||
} catch (e) {
|
||||
console.error('Error deleting poll', { error: e.response }, { payload })
|
||||
}
|
||||
|
@ -271,9 +266,7 @@ const actions = {
|
|||
async getParticipantsEmailAddresses(context) {
|
||||
const endPoint = `apps/polls/poll/${context.state.id}/addresses`
|
||||
try {
|
||||
return await axios.get(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
return await axios.get(generateUrl(endPoint), axiosDefaultConfig)
|
||||
} catch (e) {
|
||||
console.error('Error retrieving email addresses', { error: e.response })
|
||||
}
|
||||
|
|
|
@ -138,6 +138,7 @@ const state = {
|
|||
}
|
||||
|
||||
const namespaced = true
|
||||
const axiosDefaultConfig = { headers: { Accept: 'application/json' } }
|
||||
|
||||
const mutations = {
|
||||
set(state, payload) {
|
||||
|
@ -200,7 +201,7 @@ const actions = {
|
|||
|
||||
try {
|
||||
const response = await axios.get(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
...axiosDefaultConfig,
|
||||
params: { time: +new Date() },
|
||||
})
|
||||
context.commit('set', { list: response.data.list })
|
||||
|
|
|
@ -27,11 +27,11 @@ import axios from '@nextcloud/axios'
|
|||
import { getCurrentUser } from '@nextcloud/auth'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
|
||||
const namespaced = true
|
||||
const state = {
|
||||
list: [],
|
||||
}
|
||||
|
||||
const namespaced = true
|
||||
const axiosDefaultConfig = { headers: { Accept: 'application/json' } }
|
||||
|
||||
const mutations = {
|
||||
set(state, payload) {
|
||||
|
@ -52,7 +52,7 @@ const actions = {
|
|||
const endPoint = 'apps/polls/administration/polls'
|
||||
try {
|
||||
const response = await axios.get(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
...axiosDefaultConfig,
|
||||
params: { time: +new Date() },
|
||||
})
|
||||
context.commit('set', { list: response.data })
|
||||
|
@ -67,9 +67,7 @@ const actions = {
|
|||
}
|
||||
|
||||
const endPoint = `apps/polls/administration/poll/${payload.pollId}/takeover`
|
||||
axios.put(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
axios.put(generateUrl(endPoint), null, axiosDefaultConfig)
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -62,8 +62,9 @@ const defaultSettings = () => ({
|
|||
],
|
||||
})
|
||||
|
||||
const state = defaultSettings()
|
||||
const namespaced = true
|
||||
const state = defaultSettings()
|
||||
const axiosDefaultConfig = { headers: { Accept: 'application/json' } }
|
||||
|
||||
const mutations = {
|
||||
reset(state) {
|
||||
|
@ -209,7 +210,10 @@ const actions = {
|
|||
async get(context) {
|
||||
const endPoint = 'apps/polls/preferences'
|
||||
try {
|
||||
const response = await axios.get(generateUrl(endPoint), { params: { time: +new Date() } })
|
||||
const response = await axios.get(generateUrl(endPoint), {
|
||||
...axiosDefaultConfig,
|
||||
params: { time: +new Date() },
|
||||
})
|
||||
if (response.data.preferences.defaultViewTextPoll === 'desktop') {
|
||||
response.data.preferences.defaultViewTextPoll = 'table-view'
|
||||
}
|
||||
|
@ -241,9 +245,8 @@ const actions = {
|
|||
const endPoint = 'apps/polls/preferences'
|
||||
try {
|
||||
const response = await axios.post(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
settings: context.state.user,
|
||||
})
|
||||
}, axiosDefaultConfig)
|
||||
context.commit('setPreference', response.data.preferences)
|
||||
} catch (e) {
|
||||
console.error('Error writing preferences', { error: e.response }, { preferences: state.user })
|
||||
|
@ -253,9 +256,7 @@ const actions = {
|
|||
|
||||
async getCalendars(context) {
|
||||
const endPoint = 'apps/polls/calendars'
|
||||
const response = await axios.get(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
const response = await axios.get(generateUrl(endPoint), axiosDefaultConfig)
|
||||
context.commit('setCalendars', { calendars: response.data.calendars })
|
||||
return response
|
||||
},
|
||||
|
|
|
@ -37,9 +37,9 @@ const defaultShares = () => ({
|
|||
publicPollEmail: 'optional',
|
||||
})
|
||||
|
||||
const state = defaultShares()
|
||||
|
||||
const namespaced = true
|
||||
const state = defaultShares()
|
||||
const axiosDefaultConfig = { headers: { Accept: 'application/json' } }
|
||||
|
||||
const mutations = {
|
||||
set(state, payload) {
|
||||
|
@ -66,7 +66,7 @@ const actions = {
|
|||
|
||||
try {
|
||||
const response = await axios.get(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
...axiosDefaultConfig,
|
||||
params: { time: +new Date() },
|
||||
})
|
||||
context.commit('set', { share: response.data.share })
|
||||
|
@ -86,11 +86,10 @@ const actions = {
|
|||
|
||||
try {
|
||||
const response = await axios.post(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
userName: payload.userName,
|
||||
emailAddress: payload.emailAddress,
|
||||
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||
})
|
||||
}, axiosDefaultConfig)
|
||||
|
||||
if (payload.saveCookie && context.state.type === 'public') {
|
||||
const cookieExpiration = (30 * 24 * 60 * 1000)
|
||||
|
@ -110,13 +109,10 @@ const actions = {
|
|||
return
|
||||
}
|
||||
|
||||
const endPoint = `apps/polls/s/${context.rootState.route.params.token}/email`
|
||||
const endPoint = `apps/polls/s/${context.rootState.route.params.token}/email/${payload.emailAddress}`
|
||||
|
||||
try {
|
||||
const response = await axios.put(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
emailAddress: payload.emailAddress,
|
||||
})
|
||||
const response = await axios.put(generateUrl(endPoint), null, axiosDefaultConfig)
|
||||
context.commit('set', { share: response.data.share })
|
||||
context.dispatch('poll/get', null, { root: true })
|
||||
} catch (e) {
|
||||
|
@ -133,9 +129,7 @@ const actions = {
|
|||
const endPoint = `apps/polls/s/${context.rootState.route.params.token}/name/${payload.displayName}`
|
||||
|
||||
try {
|
||||
const response = await axios.put(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
const response = await axios.put(generateUrl(endPoint), null, axiosDefaultConfig)
|
||||
context.commit('set', { share: response.data.share })
|
||||
context.dispatch('poll/get', null, { root: true })
|
||||
context.dispatch('comments/list', null, { root: true })
|
||||
|
@ -155,9 +149,7 @@ const actions = {
|
|||
const endPoint = `apps/polls/s/${context.rootState.route.params.token}/email`
|
||||
|
||||
try {
|
||||
const response = await axios.delete(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
const response = await axios.delete(generateUrl(endPoint), axiosDefaultConfig)
|
||||
context.commit('set', { share: response.data.share })
|
||||
context.dispatch('subscription/update', false, { root: true })
|
||||
context.dispatch('poll/get', null, { root: true })
|
||||
|
@ -175,9 +167,7 @@ const actions = {
|
|||
const endPoint = `apps/polls/s/${context.rootState.route.params.token}/resend`
|
||||
|
||||
try {
|
||||
return await axios.put(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
return await axios.put(generateUrl(endPoint), null, axiosDefaultConfig)
|
||||
} catch (e) {
|
||||
console.error('Error sending invitation', { error: e.response }, { payload })
|
||||
throw e
|
||||
|
|
|
@ -28,9 +28,9 @@ const defaultShares = () => ({
|
|||
list: [],
|
||||
})
|
||||
|
||||
const state = defaultShares()
|
||||
|
||||
const namespaced = true
|
||||
const state = defaultShares()
|
||||
const axiosDefaultConfig = { headers: { Accept: 'application/json' } }
|
||||
|
||||
const mutations = {
|
||||
set(state, payload) {
|
||||
|
@ -76,7 +76,7 @@ const actions = {
|
|||
|
||||
try {
|
||||
const response = await axios.get(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
...axiosDefaultConfig,
|
||||
params: { time: +new Date() },
|
||||
})
|
||||
context.commit('set', response.data)
|
||||
|
@ -90,10 +90,7 @@ const actions = {
|
|||
const endPoint = `apps/polls/poll/${context.rootState.route.params.id}/share`
|
||||
|
||||
try {
|
||||
await axios.post(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
...payload.share,
|
||||
})
|
||||
await axios.post(generateUrl(endPoint), payload.share, axiosDefaultConfig)
|
||||
} catch (e) {
|
||||
console.error('Error writing share', { error: e.response }, { payload })
|
||||
throw e
|
||||
|
@ -108,9 +105,7 @@ const actions = {
|
|||
context.commit('delete', { share: payload.share })
|
||||
|
||||
try {
|
||||
await axios.delete(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
await axios.delete(generateUrl(endPoint), axiosDefaultConfig)
|
||||
} catch (e) {
|
||||
console.error('Error removing share', { error: e.response }, { payload })
|
||||
throw e
|
||||
|
@ -129,9 +124,7 @@ const actions = {
|
|||
}
|
||||
|
||||
try {
|
||||
await axios.put(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
await axios.put(generateUrl(endPoint), null, axiosDefaultConfig)
|
||||
} catch (e) {
|
||||
console.error('Error switching type', { error: e.response }, { payload })
|
||||
throw e
|
||||
|
@ -144,9 +137,7 @@ const actions = {
|
|||
const endPoint = `apps/polls/share/${payload.share.token}/publicpollemail/${payload.value}`
|
||||
|
||||
try {
|
||||
await axios.put(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
await axios.put(generateUrl(endPoint), null, axiosDefaultConfig)
|
||||
} catch (e) {
|
||||
console.error('Error changing email register setting', { error: e.response }, { payload })
|
||||
throw e
|
||||
|
@ -159,9 +150,7 @@ const actions = {
|
|||
const endPoint = `apps/polls/share/${payload.share.token}/invite`
|
||||
|
||||
try {
|
||||
return await axios.post(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
return await axios.post(generateUrl(endPoint), null, axiosDefaultConfig)
|
||||
} catch (e) {
|
||||
console.error('Error sending invitation', { error: e.response }, { payload })
|
||||
throw e
|
||||
|
@ -174,9 +163,7 @@ const actions = {
|
|||
const endPoint = `apps/polls/share/${payload.share.token}/resolve`
|
||||
|
||||
try {
|
||||
await axios.get(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
await axios.get(generateUrl(endPoint), axiosDefaultConfig)
|
||||
} catch (e) {
|
||||
console.error('Error exploding group', e.response.data, { error: e.response }, { payload })
|
||||
throw e
|
||||
|
|
|
@ -52,9 +52,8 @@ const defaultAcl = () => ({
|
|||
pollExpire: 0,
|
||||
})
|
||||
|
||||
const state = defaultAcl()
|
||||
|
||||
const namespaced = true
|
||||
const state = defaultAcl()
|
||||
|
||||
const mutations = {
|
||||
|
||||
|
|
|
@ -28,9 +28,9 @@ const defaultSubscription = () => ({
|
|||
subscribed: false,
|
||||
})
|
||||
|
||||
const state = defaultSubscription()
|
||||
|
||||
const namespaced = true
|
||||
const state = defaultSubscription()
|
||||
const axiosDefaultConfig = { headers: { Accept: 'application/json' } }
|
||||
|
||||
const mutations = {
|
||||
|
||||
|
@ -60,7 +60,7 @@ const actions = {
|
|||
|
||||
try {
|
||||
const response = await axios.get(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
...axiosDefaultConfig,
|
||||
params: { time: +new Date() },
|
||||
})
|
||||
context.commit('set', response.data)
|
||||
|
@ -82,9 +82,7 @@ const actions = {
|
|||
}
|
||||
|
||||
try {
|
||||
const response = await axios.put(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
const response = await axios.put(generateUrl(endPoint), null, axiosDefaultConfig)
|
||||
context.commit('set', response.data)
|
||||
} catch (e) {
|
||||
console.error(e.response)
|
||||
|
|
|
@ -28,9 +28,9 @@ const defaultVotes = () => ({
|
|||
list: [],
|
||||
})
|
||||
|
||||
const state = defaultVotes()
|
||||
|
||||
const namespaced = true
|
||||
const state = defaultVotes()
|
||||
const axiosDefaultConfig = { headers: { Accept: 'application/json' } }
|
||||
|
||||
const mutations = {
|
||||
set(state, payload) {
|
||||
|
@ -93,7 +93,7 @@ const actions = {
|
|||
}
|
||||
try {
|
||||
const response = await axios.get(generateUrl(`${endPoint}/votes`), {
|
||||
headers: { Accept: 'application/json' },
|
||||
...axiosDefaultConfig,
|
||||
params: { time: +new Date() },
|
||||
})
|
||||
const votes = []
|
||||
|
@ -125,10 +125,9 @@ const actions = {
|
|||
|
||||
try {
|
||||
const response = await axios.put(generateUrl(`${endPoint}/vote`), {
|
||||
headers: { Accept: 'application/json' },
|
||||
optionId: payload.option.id,
|
||||
setTo: payload.setTo,
|
||||
})
|
||||
}, axiosDefaultConfig)
|
||||
context.commit('setItem', { option: payload.option, pollId: context.rootState.poll.id, vote: response.data.vote })
|
||||
context.dispatch('options/list', null, { root: true })
|
||||
context.dispatch('poll/get', null, { root: true })
|
||||
|
@ -154,9 +153,7 @@ const actions = {
|
|||
}
|
||||
|
||||
try {
|
||||
const response = await axios.delete(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
const response = await axios.delete(generateUrl(endPoint), axiosDefaultConfig)
|
||||
context.commit('deleteVotes', { userId: response.data.deleted })
|
||||
} catch (e) {
|
||||
console.error('Error deleting votes', { error: e.response })
|
||||
|
@ -167,9 +164,7 @@ const actions = {
|
|||
async deleteUser(context, payload) {
|
||||
const endPoint = `apps/polls/poll/${context.rootState.route.params.id}/user/${payload.userId}`
|
||||
try {
|
||||
await axios.delete(generateUrl(endPoint), {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
await axios.delete(generateUrl(endPoint), axiosDefaultConfig)
|
||||
context.commit('deleteVotes', payload)
|
||||
} catch (e) {
|
||||
console.error('Error deleting votes', { error: e.response }, { payload })
|
||||
|
|
Загрузка…
Ссылка в новой задаче