From b1237680d3d49b945225dba0748054720759b125 Mon Sep 17 00:00:00 2001 From: Henri Remonen Date: Tue, 14 Mar 2023 12:24:30 +0200 Subject: [PATCH] Group types a bit --- src/client/types.ts | 102 ++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 52 deletions(-) diff --git a/src/client/types.ts b/src/client/types.ts index 721985f4..6c44cad3 100644 --- a/src/client/types.ts +++ b/src/client/types.ts @@ -6,6 +6,22 @@ import { SubmitHandler, } from 'react-hook-form' +export interface Faculty { + code: string + name: Locales +} + +export interface User { + id: string + username: string + firsName?: string + lastName?: string + email?: string + language?: string + isAdmin: boolean + iamGroups: string[] +} + export interface InputProps { control?: Control watch?: UseFormWatch @@ -17,6 +33,16 @@ export interface InputProps { handleSubmit?: SubmitHandler } +export interface FormValues { + [key: number]: Record + faculty: string +} + +export interface PersistForm { + value: FormValues + sessionStorageKey: string +} + export type Locales = { en: string fi: string @@ -29,17 +55,29 @@ export interface InfoType { label: Locales } -export interface SingleChoiceType { +export type SingleChoiceType = { id: string label: Locales } -export interface MultipleChoiceType { - id: string - label: Locales +export interface MultipleChoiceType extends SingleChoiceType { data: Locales } +export type ChoiceType = + | SingleChoiceType[] + | MultipleChoiceType[] + | DimensionSelectionData[] + +export interface OptionData { + type: string + options: ChoiceType +} + +export type Visibility = { + options: string[] +} + export interface Subtool { label: string title: Locales @@ -68,25 +106,19 @@ export interface MergedRecommendationDataType { text: Locales } +export interface RecommendationData { + id: number + label: string + title: Locales + text: Locales + dimensions?: string[] +} + export interface SelectedToolsType { mergedRecommendationData: MergedRecommendationDataType[] dimensionSelections?: DimensionSelectionData[] } -export type ChoiceType = - | SingleChoiceType[] - | MultipleChoiceType[] - | DimensionSelectionData[] - -export interface OptionData { - type: string - options: ChoiceType -} - -export type Visibility = { - options: string[] -} - export interface Survey { id: number name: string @@ -108,24 +140,6 @@ export interface Question { updatedAt: Date } -export interface RecommendationData { - id: number - label: string - title: Locales - text: Locales - dimensions?: string[] -} - -export interface FormValues { - [key: number]: Record - faculty: string -} - -export interface PersistForm { - value: FormValues - sessionStorageKey: string -} - export interface Result { id: number surveyId: number @@ -137,19 +151,3 @@ export interface Result { [key: string]: Locales } } - -export interface Faculty { - code: string - name: Locales -} - -export interface User { - id: string - username: string - firsName?: string - lastName?: string - email?: string - language?: string - isAdmin: boolean - iamGroups: string[] -}