Fix: remove useless state

This commit is contained in:
Bertrand Benjamin 2021-08-09 09:17:11 +02:00
parent 791aa12d2d
commit 6188337140

View File

@ -102,11 +102,11 @@ const travail = {
getMonth: (state) => (date) => { getMonth: (state) => (date) => {
return state.months[date] return state.months[date]
}, },
count: (state, getters) => { count: (getters) => {
// Amount of mounts // Amount of mounts
return Object.keys(getters.months).length return Object.keys(getters.months).length
}, },
ca: (state, getters) => { ca: (getters) => {
// Total CA (ca_react if sets, ca_retro otherwise) // Total CA (ca_react if sets, ca_retro otherwise)
return Object.values(getters.months).map(a => monthCA(a)).reduce( return Object.values(getters.months).map(a => monthCA(a)).reduce(
(acc, v) => acc + v, (acc, v) => acc + v,
@ -120,28 +120,28 @@ const travail = {
0 0
) / getters.count) ) / getters.count)
}, },
caTheo: (state, getters) => { caTheo: (getters) => {
// Total theorical CA // Total theorical CA
return Object.values(getters.months).map(a => a.ca_theo).reduce( return Object.values(getters.months).map(a => a.ca_theo).reduce(
(acc, v) => acc + v, (acc, v) => acc + v,
0 0
) )
}, },
remuneration: (state, getters) => { remuneration: (getters) => {
// Total remuneration // Total remuneration
return Object.values(getters.months).map(a => a.remuneration).reduce( return Object.values(getters.months).map(a => a.remuneration).reduce(
(acc, v) => acc + v, (acc, v) => acc + v,
0 0
) )
}, },
remunerationMean: (state, getters) => { remunerationMean: (getters) => {
// Mean of remuneration // Mean of remuneration
return Math.floor(Object.values(getters.months).map(a => a.remuneration).reduce( return Math.floor(Object.values(getters.months).map(a => a.remuneration).reduce(
(acc, v) => acc + v, (acc, v) => acc + v,
0 0
) / getters.count) ) / getters.count)
}, },
retrocession: (state, getters) => { retrocession: (getters) => {
// Total retrocession // Total retrocession
return Object.values(getters.months) return Object.values(getters.months)
.map(a => a.retro) .map(a => a.retro)
@ -150,7 +150,7 @@ const travail = {
0 0
) )
}, },
retrocessionMean: (state, getters) => { retrocessionMean: (getters) => {
// Mean of retrocession // Mean of retrocession
return Math.floor( return Math.floor(
Object.values(getters.months) Object.values(getters.months)
@ -185,9 +185,7 @@ const travail = {
createMonth(context, { date, month }) { createMonth(context, { date, month }) {
// Create a new month // Create a new month
if (!(date in context.state.months)) { if (!(date in context.state.months)) {
console.log(date)
context.commit('createMonth', { date, month }) context.commit('createMonth', { date, month })
console.log(context.state.months)
} else { } else {
console.log("This month already exists") console.log("This month already exists")
} }