diff options
| author | Max Nanis | 2025-06-06 22:40:41 +0700 |
|---|---|---|
| committer | Max Nanis | 2025-06-06 22:40:41 +0700 |
| commit | 257bc2f85b71a8564e95a8e6ba39ab0b00e022df (patch) | |
| tree | c44ced82b5f5f99e7e7bb9cffcd444a41b8a648c /src/models/answerSlice.ts | |
| parent | 696dee6a6a9506fcf771d0ec4911dcc82a279fda (diff) | |
| download | panel-ui-257bc2f85b71a8564e95a8e6ba39ab0b00e022df.tar.gz panel-ui-257bc2f85b71a8564e95a8e6ba39ab0b00e022df.zip | |
Question.active state (clear naming on getInitialQuestion and getNextQuestion). Explicit use of return null as an option for answerSlice. Saving motion. Questions rolling window. Question count badge to sidebar.
Diffstat (limited to 'src/models/answerSlice.ts')
| -rw-r--r-- | src/models/answerSlice.ts | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/models/answerSlice.ts b/src/models/answerSlice.ts index aada48c..cd20dbc 100644 --- a/src/models/answerSlice.ts +++ b/src/models/answerSlice.ts @@ -1,4 +1,6 @@ import {createSelector, createSlice, PayloadAction} from '@reduxjs/toolkit' +import {Selector} from 'react-redux' + // import {Answer} from "@/models/answer.ts"; // import {stringify} from "querystring"; import {RootState} from '@/store'; // your root state type @@ -183,24 +185,13 @@ export const { } = answerSlice.actions; export default answerSlice.reducer -export const answerForQuestion = (state: RootState, question: ProfileQuestion) => state.answers[question.question_id] ?? { - values: [], - error_msg: "", - complete: false, - processing: false -} as Answer; -export const makeSelectChoicesByQuestion = (question: ProfileQuestion) => +export const selectAnswerForQuestion = ( + question: ProfileQuestion +): Selector<RootState, Answer | null> => createSelector( (state: RootState) => state.answers, (answers) => { - // const question = questions.find(q => q.id === questionId); - // return question?.choices ?? []; - return answers[question.question_id] ?? { - values: [], - error_msg: "", - complete: false, - processing: false - } as Answer; + return answers[question.question_id] || null } );
\ No newline at end of file |
