From 83af205e7e7610144031a29ee7fc5f9450dc63e2 Mon Sep 17 00:00:00 2001 From: MikanD Date: Sun, 1 Jun 2025 16:17:09 +0300 Subject: [PATCH] survey result page --- src/API/common.ts | 2 +- src/pages/SurveyPage.tsx | 4 +--- src/pages/SurveyResultPage.tsx | 28 ++++++++++++++++++++++------ src/types/survey.ts | 5 +++++ 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/API/common.ts b/src/API/common.ts index 22394d2..8931fd6 100644 --- a/src/API/common.ts +++ b/src/API/common.ts @@ -82,7 +82,7 @@ export function useDataPage(application:string, endpoint: string, params:{[ke }) } }, - [data, application, endpoint] + [data, application, endpoint, needLoad] ) // function changePage(pageUrl: string|undefined) { diff --git a/src/pages/SurveyPage.tsx b/src/pages/SurveyPage.tsx index 90d5906..c9bb587 100644 --- a/src/pages/SurveyPage.tsx +++ b/src/pages/SurveyPage.tsx @@ -24,8 +24,6 @@ export function SurveyPage() { const questionsPairs = useDataPage("surveys", "question-pairs", { survey: surveyId || 0 }); const questionsAgreement = useDataPage("surveys", "agreement-questions", { survey: surveyId || 0 }); - // Загрузка score variables - const scoreVariables = useDataPage("surveys", "score-variables"); // Состояние для ответов const [answers, setAnswers] = useState>({}); @@ -63,7 +61,7 @@ export function SurveyPage() { // Вычисление итогового score_variable const calculateResults = () => { - if (!questions || !scoreVariables.items) return; + if (!questions) return; const scoreCounts: Record = {}; diff --git a/src/pages/SurveyResultPage.tsx b/src/pages/SurveyResultPage.tsx index 94b876f..6cee410 100644 --- a/src/pages/SurveyResultPage.tsx +++ b/src/pages/SurveyResultPage.tsx @@ -1,18 +1,27 @@ -import { useParams } from 'react-router-dom'; -import { useData } from '../API/common'; -import { ScoreVariable, Survey } from '../types/survey'; +import { Link, useParams } from 'react-router-dom'; +import { useData, useDataPage } from '../API/common'; +import { Profession, ScoreVariable, Survey } from '../types/survey'; import ReactMarkdown from 'react-markdown'; import { LoadingData } from '../components/LoadingData'; +import { LoadingList } from '../components/LoadingList'; export function SurveyResultPage() { const { scoreVariableId } = useParams<{ scoreVariableId: string }>(); const scoreVariable = useData('surveys', 'score-variables', scoreVariableId || 0); const survey = useData('surveys', 'surveys', scoreVariable?.survey || 0, !!scoreVariable); + const professions = useDataPage( + 'surveys', + 'professions', + { score_variable: scoreVariableId || 0 }, + !!scoreVariable + ); + + return (
- +

{survey?.title}

Ваш результат

@@ -21,9 +30,16 @@ export function SurveyResultPage() {
{scoreVariable?.description}
-
+

Подходящие профессии

-

Здесь будет список профессий.

+ ( + + {(profession as Profession).name} + + )} + />
diff --git a/src/types/survey.ts b/src/types/survey.ts index 00cedd6..c7c549c 100644 --- a/src/types/survey.ts +++ b/src/types/survey.ts @@ -39,4 +39,9 @@ export interface ScoreVariable { title: string; description: string; survey: number; +} + +export interface Profession extends UniqueItem { + name: string; + description: string; } \ No newline at end of file