Merge pull request #1 from bvn13/feature/add-results

Feature/add results
pull/2/head
Vyacheslav N. Boyko 2024-02-17 00:00:16 +03:00 committed by GitHub
commit 7c3749cf47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 43 additions and 17 deletions

File diff suppressed because one or more lines are too long

View File

@ -291,5 +291,6 @@
}
]
}
]
],
"resultsInfo": "<h1>Оценка результатов</h1><p><strong>личная сфера</strong> — если результат ≤ 8, то это говорит о:</p><ul type=\"square\"><li>усталость</li><li>выгорание</li><li>депрессия</li></ul><p><strong>социальная сфера</strong> — если результат ≤ 8, то это говорит о:</p><ul type=\"square\"><li>отсутствие поддержки от близких</li><li>узкий круг общения (замкнутость)</li></ul><p><strong>корпоративная сфера</strong> — если результат ≤ 8, то это говорит о:</p><ul type=\"square\"><li>тревога, неуверенность в завтрашнем дне</li><li>тяжелые жизненные обстоятельства</li><li>необходимость в профессиональном развитии</li></ul>"
}

View File

@ -489,5 +489,6 @@
}
]
}
]
],
"resultsInfo": "<h1>Оценка результатов</h1>В зависимости от того, сколько баллов вы набрали, можно предположить следующее.<br/><br/>013 — депрессивных симптомов нет. С вашим психическим здоровьем всё в порядке.<br/>1419 — вероятна лёгкая депрессия (субдепрессия).<br/>2028 — умеренная депрессия.<br/>2963 — тяжёлая депрессия. Состояние тем сложнее, чем больше количество баллов."
}

View File

@ -17,5 +17,6 @@
}
]
}
]
],
"resultsInfo": ""
}

View File

@ -17,5 +17,6 @@
}
]
}
]
],
"resultsInfo": null
}

View File

@ -25,7 +25,7 @@
"@emotion/styled": "^11.10.5",
"@emotion/core": "^11.0.0",
"@emotion/react": "^11.10.5",
"lodash": "^4.17.21"
"lodash-es": "^4.17.21"
},
"scripts": {
"start": "react-scripts start",
@ -48,6 +48,7 @@
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.1",
"@types/react-redux": "^7.1.25",
"@types/lodash-es": "^4.17.12",
"typescript": "^4.9.5"
},
"homepage": ".",

View File

@ -291,5 +291,6 @@
}
]
}
]
],
"resultsInfo": "<h1>Оценка результатов</h1><p><strong>личная сфера</strong> — если результат ≤ 8, то это говорит о:</p><ul type=\"square\"><li>усталость</li><li>выгорание</li><li>депрессия</li></ul><p><strong>социальная сфера</strong> — если результат ≤ 8, то это говорит о:</p><ul type=\"square\"><li>отсутствие поддержки от близких</li><li>узкий круг общения (замкнутость)</li></ul><p><strong>корпоративная сфера</strong> — если результат ≤ 8, то это говорит о:</p><ul type=\"square\"><li>тревога, неуверенность в завтрашнем дне</li><li>тяжелые жизненные обстоятельства</li><li>необходимость в профессиональном развитии</li></ul>"
}

View File

@ -489,5 +489,6 @@
}
]
}
]
],
"resultsInfo": "<h1>Оценка результатов</h1>В зависимости от того, сколько баллов вы набрали, можно предположить следующее.<br/><br/>013 — депрессивных симптомов нет. С вашим психическим здоровьем всё в порядке.<br/>1419 — вероятна лёгкая депрессия (субдепрессия).<br/>2028 — умеренная депрессия.<br/>2963 — тяжёлая депрессия. Состояние тем сложнее, чем больше количество баллов."
}

View File

@ -17,5 +17,6 @@
}
]
}
]
],
"resultsInfo": ""
}

View File

@ -20,7 +20,8 @@ export interface SurveyDto {
title: string,
intro: string,
settings: SettingsDto,
questions: QuestionDto[]
questions: QuestionDto[],
resultsInfo: string
}
const Api = {

View File

@ -6,6 +6,7 @@ import {Box, Button, Paper, Step, StepContent, StepLabel, Stepper, Typography} f
import {store} from "../../store/store";
import {addAnswer, setContents} from "../../store/actions/data";
import {ResultByGroup} from "../../store/initialState";
import If from "../utils/If";
interface Props {
survey: SurveyDto | undefined
@ -61,7 +62,8 @@ const Survey: React.FC<Props> = ({survey}) => {
question: q.question,
options: randomizeIfNeeded(survey.settings.randomizeOptions, q.options)
}
})
}),
resultsInfo: survey.resultsInfo
})
}
}, [survey])
@ -140,6 +142,7 @@ const Survey: React.FC<Props> = ({survey}) => {
)}
</ul>
</div>
<div dangerouslySetInnerHTML={{__html: prepare(preparedSurvey?.resultsInfo)}}></div>
<Button onClick={handleReset} sx={{mt: 1, mr: 1}}>
Reset
</Button>

View File

@ -1,5 +1,4 @@
import React, {useEffect} from 'react'
import DateDisplay from '../components/DateDisplay'
import {SnackbarOrigin, useSnackbar} from 'notistack';
import Api, {SurveyDto} from "./../api/Api";
import Survey from "./../components/survey/Survey";

View File

@ -1,10 +1,10 @@
import { createReducer } from '@reduxjs/toolkit'
import {addAnswer, setContents} from '../actions/data'
import initialState, {StoreContent, ResultByGroup} from "../initialState";
import * as _ from "lodash";
import * as _ from "lodash-es";
const reduceState = (array: ResultByGroup[], addon: ResultByGroup) => {
var added = false;
let added = false;
array.forEach((result) => {
if (result.group === addon.group) {
added = true

View File

@ -1,8 +1,6 @@
import { render, screen } from '@testing-library/react'
import DateDisplay from '../../components/DateDisplay'
test('renders current date', () => {
render(<DateDisplay />)
const timeFormat = screen.getByText(/GMT/i)
expect(timeFormat).toBeInTheDocument()
})

View File

@ -2242,6 +2242,18 @@
resolved "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz"
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==
"@types/lodash-es@^4.17.12":
version "4.17.12"
resolved "https://registry.yarnpkg.com/@types/lodash-es/-/lodash-es-4.17.12.tgz#65f6d1e5f80539aa7cfbfc962de5def0cf4f341b"
integrity sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==
dependencies:
"@types/lodash" "*"
"@types/lodash@*":
version "4.14.202"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.202.tgz#f09dbd2fb082d507178b2f2a5c7e74bd72ff98f8"
integrity sha512-OvlIYQK9tNneDlS0VN54LLd5uiPCBOp7gS5Z0f1mjoJYBrtStzgmJBxONW3U6OZqdtNzZPmn9BS/7WI7BFFcFQ==
"@types/mime@*":
version "3.0.1"
resolved "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz"
@ -6560,6 +6572,11 @@ locate-path@^6.0.0:
dependencies:
p-locate "^5.0.0"
lodash-es@^4.17.21:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee"
integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==
lodash.debounce@^4.0.8:
version "4.0.8"
resolved "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz"