ScreeningResults

mail@pastecode.io avatar
unknown
plain_text
2 years ago
7.3 kB
2
Indexable
Never
import { initializer } from "../helpers/functions";
import { categories } from "../services/londi-constants";

export const screeningResultsReducer = (state = initializer, action) => {
  switch (action.type) {
    case "classOptions":
      return { ...state, options: "classOptions" };
    case "schoolGrade":
      return {
        ...state,
        schoolGrade: action.payload,
        options: "",
      };
    case "testTimeOptions":
      return { ...state, options: "testTimeOptions" };
    case "testTime":
      return {
        ...state,
        testTime: action.payload,
        options: "",
      };
    case "options":
      return {
        ...state,
        options: "",
      };
    case "clearReading":
      return {
        ...state,
        screeningResultReading: undefined,
      };
    case "clearWriting":
      return {
        ...state,
        screeningResultWriting: undefined,
      };
    case "clearCounting":
      return {
        ...state,
        screeningResultCounting: undefined,
      };
    case "germanNativeOptions":
      return { ...state, options: "germanNativeOptions" };
    case "germanSecondaryLanguage":
      return {
        ...state,
        germanSecondaryLanguage: action.payload,
        options: "",
      };
    case "screenResultsEstimated":
      return {
        ...state,
        screenResultsEstimated: action.payload,
        options: "",
      };
    case "educationOptions":
      return { ...state, options: "educationOptions" };
    case "education":
      return {
        ...state,
        education: action.payload,
        options: "",
      };
    case "readingOptions":
      return { ...state, options: "readingOptions" };
    case "readingSecondTestOptions":
      return { ...state, options: "readingSecondTestOptions" };
    case "writingSecondTestOptions":
      return { ...state, options: "writingSecondTestOptions" };
    case "countingSecondTestOptions":
      return { ...state, options: "countingSecondTestOptions" };
    case "reading":
      return {
        ...state,
        screeningResultReading: {
          category: categories.Reading,
          result: action.payload,
        },
        options: "",
      };
    case "writingOptions":
      return { ...state, options: "writingOptions" };
    case "writing":
      return {
        ...state,
        screeningResultWriting: {
          category: categories.Writing,
          result: action.payload,
        },
        options: "",
      };
    case "countingOptions":
      return { ...state, options: "countingOptions" };
    case "counting":
      return {
        ...state,
        screeningResultCounting: {
          category: categories.Math,
          result: action.payload,
        },
        options: "",
      };
    case "ageOptions":
      return { ...state, options: "ageOptions" };
    case "age":
      return {
        ...state,
        age: action.payload,
        options: "",
      };
    case "resultsReadingOptions":
      return {
        ...state,
        options: "resultsReadingOptions",
        selectedReadingValue: action.payload.id,
      };
    case "resultsReading":
      const { keyReading, valueReading } = action.payload;
      return {
        ...state,
        resultsReading: { ...state.resultsReading, [keyReading]: valueReading },
        options: "",
      };
    case "resultsSecondReadingOptions":
      return {
        ...state,
        options: "resultsSecondReadingOptions",
        selectedSecondReadingValue: action.payload.id,
      };
    case "resultsSecondReading":
      const { keySecondReading, valueSecondReading } = action.payload;
      return {
        ...state,
        resultsSecondReading: {
          ...state.resultsSecondReading,
          [keySecondReading]: valueSecondReading,
        },
        options: "",
      };

    case "resultsWritingOptions":
      return {
        ...state,
        options: "resultsWritingOptions",
        selectedWritingValue: action.payload.id,
      };
    case "resultsWriting":
      const { keyWriting, valueWriting } = action.payload;
      return {
        ...state,
        resultsWriting: { ...state.resultsWriting, [keyWriting]: valueWriting },
        options: "",
      };
    case "resultsSecondWritingOptions":
      return {
        ...state,
        options: "resultsSecondWritingOptions",
        selectedSecondWritingValue: action.payload.id,
      };
    case "resultsSecondWriting":
      const { keySecondWriting, valueSecondWriting } = action.payload;
      return {
        ...state,
        resultsSecondWriting: {
          ...state.resultsSecondWriting,
          [keySecondWriting]: valueSecondWriting,
        },
        options: "",
      };

    case "resultsCountingOptions":
      return {
        ...state,
        options: "resultsCountingOptions",
        selectedCountingValue: action.payload.id,
      };
    case "resultsCounting":
      const { keyCounting, valueCounting } = action.payload;
      return {
        ...state,
        resultsCounting: { ...state.resultsCounting, [keyCounting]: valueCounting },
        options: "",
      };
    case "resultsSecondCountingOptions":
      return {
        ...state,
        options: "resultsSecondCountingOptions",
        selectedSecondCountingValue: action.payload.id,
      };
    case "resultsSecondCounting":
      const { keySecondCounting, valueSecondCounting } = action.payload;
      return {
        ...state,
        resultsSecondCounting: {
          ...state.resultsSecondCounting,
          [keySecondCounting]: valueSecondCounting,
        },
        options: "",
      };
    case "readingTest":
      return {
        ...state,
        readingResults: action.payload,
        options: "",
      };
    case "readingTestId":
      return {
        ...state,
        readingTestId: action.payload,
        options: "",
      };
    case "readingSecondTest":
      return {
        ...state,
        readingSecondTestResults: action.payload,
        options: "",
      };
    case "readingSecondTestId":
      return {
        ...state,
        readingSecondTestId: action.payload,
        options: "",
      };
    case "writingTest":
      return {
        ...state,
        writingResults: action.payload,
        options: "",
      };
    case "writingTestId":
      return {
        ...state,
        writingTestId: action.payload,
        options: "",
      };
    case "writingSecondTest":
      return {
        ...state,
        writingSecondTestResults: action.payload,
        options: "",
      };
    case "writingSecondTestId":
      return {
        ...state,
        writingSecondTestId: action.payload,
        options: "",
      };
    case "countingTest":
      return {
        ...state,
        countingResults: action.payload,
        options: "",
      };
    case "countingTestId":
      return {
        ...state,
        countingTestId: action.payload,
        options: "",
      };
    case "countingSecondTest":
      return {
        ...state,
        countingSecondTestResults: action.payload,
        options: "",
      };
    case "countingSecondTestId":
      return {
        ...state,
        countingSecondTestId: action.payload,
        options: "",
      };
    default:
      return state;
  }
};