62 lines
1.1 KiB
TypeScript
62 lines
1.1 KiB
TypeScript
export type QuestionType =
|
|
| 'single_choice'
|
|
| 'multiple_choice'
|
|
| 'rating'
|
|
| 'text_long'
|
|
| 'text_short'
|
|
| 'section'
|
|
|
|
export interface QuestionOption {
|
|
value: string
|
|
label: string
|
|
}
|
|
|
|
export interface RatingOptions {
|
|
min: number
|
|
max: number
|
|
min_label: string
|
|
max_label: string
|
|
}
|
|
|
|
export interface ConditionalRule {
|
|
if_question: string
|
|
op: 'eq'
|
|
value: string
|
|
action: 'show'
|
|
}
|
|
|
|
export interface Question {
|
|
id: string
|
|
survey_id: string
|
|
code: string
|
|
type: QuestionType
|
|
prompt: string
|
|
position: number
|
|
is_sensitive: boolean
|
|
required: boolean
|
|
max_select: number | null
|
|
options: QuestionOption[] | RatingOptions | null
|
|
conditional_rules: ConditionalRule[] | null
|
|
}
|
|
|
|
export interface BrandConfig {
|
|
org_name?: string
|
|
branch_name?: string
|
|
branch_city?: string
|
|
}
|
|
|
|
export interface Survey {
|
|
id: string
|
|
org_id: string
|
|
title: string
|
|
status: string
|
|
is_anonymous: boolean
|
|
k_threshold: number
|
|
consent_version_id: string
|
|
brand_config: BrandConfig | null
|
|
questions: Question[]
|
|
}
|
|
|
|
// Answers keyed by question code
|
|
export type FormAnswers = Record<string, string | string[] | number | null>
|