Fix bug with determining checklist progress

This commit is contained in:
Andrew Kingston 2021-09-10 08:25:30 +01:00
parent 4da58241b3
commit 2f986bedf1
1 changed files with 3 additions and 9 deletions

View File

@ -25,20 +25,14 @@ export function createAdminStore() {
`/api/global/configs/checklist?tenantId=${tenantId}`
)
const json = await response.json()
const onboardingSteps = Object.keys(json)
const stepsComplete = onboardingSteps.reduce(
(score, step) => (score + step.checked ? 1 : 0),
0
)
const totalSteps = Object.keys(json).length
const completedSteps = Object.values(json).filter(x => x?.checked).length
await getFlags()
admin.update(store => {
store.loaded = true
store.checklist = json
store.onboardingProgress =
(stepsComplete / onboardingSteps.length) * 100
store.onboardingProgress = (completedSteps / totalSteps) * 100
return store
})
} catch (err) {