Skip to content

Commit

Permalink
[JN-1536] more typescript fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
devonbush committed Jan 3, 2025
1 parent 9632762 commit b0bb65e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"answerPopDtos": [
{"questionStableId": "hd_hd_basic_firstName", "stringValue": "Child 2"},
{"questionStableId": "hd_hd_basic_lastName", "stringValue": "Family 2"},
{"questionStableId": "hd_hd_basic_dateOfBirth", "stringValue": "08/24/2019"},
{"questionStableId": "hd_hd_basic_streetAddress", "stringValue": "105 Broadway"},
{"questionStableId": "hd_hd_basic_mghPatient", "stringValue": "yes"}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"answerPopDtos": [
{"questionStableId": "hd_hd_basic_firstName", "stringValue": "Invited"},
{"questionStableId": "hd_hd_basic_lastName", "stringValue": "PriorUser"},
{"questionStableId": "hd_hd_basic_dateOfBirth", "stringValue": "05/04/1990"},
{"questionStableId": "hd_hd_basic_streetAddress", "stringValue": "465 Spruce Street"},
{"questionStableId": "hd_hd_basic_mghPatient", "stringValue": "yes"},
{"questionStableId": "hd_hd_basic_sexualOrientation", "stringValue": "preferNoAnswer"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"answerPopDtos": [
{"questionStableId": "hd_hd_basic_firstName", "stringValue": "Jonas", "viewedLanguage": "en"},
{"questionStableId": "hd_hd_basic_lastName", "stringValue": "Salk", "viewedLanguage": "en"},
{"questionStableId": "hd_hd_basic_dateOfBirth", "stringValue": "11/13/1983", "viewedLanguage": "en"},
{"questionStableId": "hd_hd_basic_streetAddress", "stringValue": "1223 Walnut Street", "viewedLanguage": "es"},
{"questionStableId": "hd_hd_basic_mghPatient", "stringValue": "yes", "viewedLanguage": "es"},
{"questionStableId": "hd_hd_basic_languages", "objectValue": "[{\"language\": \"English\", \"proficiency\": \"native\", \"workUse\": [\"yes\"]}, {\"language\": \"Dutch\", \"proficiency\": \"fluent\", \"workUse\": []}]", "viewedLanguage": "es"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"answerPopDtos": [
{"questionStableId": "hd_hd_basic_firstName", "stringValue": "Lost"},
{"questionStableId": "hd_hd_basic_lastName", "stringValue": "Interest"},
{"questionStableId": "hd_hd_basic_dateOfBirth", "stringValue": "02/24/2000"},
{"questionStableId": "hd_hd_basic_streetAddress", "stringValue": "857 Spruce Street"},
{"questionStableId": "hd_hd_basic_mghPatient", "stringValue": "yes"}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"answerPopDtos": [
{"questionStableId": "hd_hd_basic_firstName", "stringValue": "Recurrence"},
{"questionStableId": "hd_hd_basic_lastName", "stringValue": "Due"},
{"questionStableId": "hd_hd_basic_dateOfBirth", "stringValue": "05/07/1983"},
{"questionStableId": "hd_hd_basic_streetAddress", "stringValue": "99 Spruce Street"},
{"questionStableId": "hd_hd_basic_mghPatient", "stringValue": "yes"}
],
Expand Down
31 changes: 19 additions & 12 deletions ui-admin/src/forms/designer/split/QuestionDesigner.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import React, { useState } from 'react'

import { HtmlQuestion, PortalEnvironmentLanguage, Question, QuestionType } from '@juniper/ui-core'
import {
HtmlQuestion,
PortalEnvironmentLanguage,
Question,
SimpleQuestion,
SimpleQuestionType
} from '@juniper/ui-core'

import { Textarea } from 'components/forms/Textarea'
import { i18nSurveyText, updateI18nSurveyText } from 'util/juniperSurveyUtils'
Expand Down Expand Up @@ -59,14 +65,15 @@ export const QuestionDesigner = (props: QuestionDesignerProps) => {
</div>
{ (!isTemplated && question.type !== 'html') &&
<IconButton
className={classNames('mb-2', 'ms-1', 'border', question.isRequired ? 'text-danger' : 'text-muted')}
className={classNames('mb-2', 'ms-1', 'border',
(question as SimpleQuestion).isRequired ? 'text-danger' : 'text-muted')}
icon={faAsterisk}
aria-label={'Toggle required'}
onClick={() => {
onChange({
onChange(({
...question,
isRequired: !question.isRequired
})
isRequired: !(question as SimpleQuestion).isRequired
}) as SimpleQuestion)
}}
/> }
</div>
Expand All @@ -75,7 +82,7 @@ export const QuestionDesigner = (props: QuestionDesignerProps) => {
questionType={question.type}
onChange={newType => {
onChange({
...baseQuestions[newType as QuestionType],
...baseQuestions[newType as SimpleQuestionType],
...question,
// @ts-ignore
type: newType
Expand All @@ -99,7 +106,7 @@ export const QuestionDesigner = (props: QuestionDesignerProps) => {
disabled={readOnly}
currentLanguage={currentLanguage}
supportedLanguages={supportedLanguages}
question={question}
question={question as SimpleQuestion}
onChange={onChange}
/>

Expand Down Expand Up @@ -143,7 +150,7 @@ export const QuestionDesigner = (props: QuestionDesignerProps) => {
>
<VisibilityFields
disabled={readOnly}
question={question}
question={question as SimpleQuestion}
onChange={onChange}
/>
</Tab>
Expand Down Expand Up @@ -184,17 +191,17 @@ export const QuestionDesigner = (props: QuestionDesignerProps) => {
label="Description"
labelClassname={'mb-0'}
rows={2}
value={i18nSurveyText(question.description, currentLanguage.languageCode)}
value={i18nSurveyText((question as SimpleQuestion).description, currentLanguage.languageCode)}
onChange={value => {
onChange({
onChange(({
...question,
description: updateI18nSurveyText({
valueText: value,
oldValue: question.description,
oldValue: (question as SimpleQuestion).description,
languageCode: currentLanguage.languageCode,
supportedLanguages
})
})
}) as SimpleQuestion)
}}
/>
</div>
Expand Down

0 comments on commit b0bb65e

Please sign in to comment.