Skip to content

Commit

Permalink
Group types a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
HRemonen committed Mar 14, 2023
1 parent 830b571 commit b123768
Showing 1 changed file with 50 additions and 52 deletions.
102 changes: 50 additions & 52 deletions src/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<FieldValues>
watch?: UseFormWatch<FieldValues>
Expand All @@ -17,6 +33,16 @@ export interface InputProps {
handleSubmit?: SubmitHandler<FieldValues>
}

export interface FormValues {
[key: number]: Record<string, { [key: string]: boolean }>
faculty: string
}

export interface PersistForm {
value: FormValues
sessionStorageKey: string
}

export type Locales = {
en: string
fi: string
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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<string, { [key: string]: boolean }>
faculty: string
}

export interface PersistForm {
value: FormValues
sessionStorageKey: string
}

export interface Result {
id: number
surveyId: number
Expand All @@ -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[]
}

0 comments on commit b123768

Please sign in to comment.