diff --git a/web/app/components-v2/createdialog/DialogField.ts b/web/app/components-v2/createdialog/DialogField.ts index b96c0749ef..24977da896 100644 --- a/web/app/components-v2/createdialog/DialogField.ts +++ b/web/app/components-v2/createdialog/DialogField.ts @@ -9,7 +9,7 @@ export type DialogField = { export const useDialogField = ( isVisible: boolean, - defaultValue?: () => T + defaultValue?: () => T | undefined ): DialogField => { const [value, set] = useState(defaultValue) const [visible, setVisible] = useState(false) diff --git a/web/app/ib/IBPaatasonSuoritusTiedot.tsx b/web/app/ib/IBPaatasonSuoritusTiedot.tsx index 63002beb77..c6a5ba54b2 100644 --- a/web/app/ib/IBPaatasonSuoritusTiedot.tsx +++ b/web/app/ib/IBPaatasonSuoritusTiedot.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useMemo } from 'react' +import React, { useCallback, useEffect, useMemo } from 'react' import { ActivePäätasonSuoritus, hasPäätasonsuoritusOf @@ -7,31 +7,42 @@ import { KeyValueRow, KeyValueTable } from '../components-v2/containers/KeyValueTable' +import { + LocalizedTextEdit, + LocalizedTextView +} from '../components-v2/controls/LocalizedTestField' +import { Select, useKoodistoOptions } from '../components-v2/controls/Select' +import { FormField } from '../components-v2/forms/FormField' import { FormModel } from '../components-v2/forms/FormModel' -import { t } from '../i18n/i18n' -import { IBOpiskeluoikeus } from '../types/fi/oph/koski/schema/IBOpiskeluoikeus' import { KoodistoEdit, KoodistoView } from '../components-v2/opiskeluoikeus/KoodistoField' -import { FormField } from '../components-v2/forms/FormField' +import { KoodistoSelect } from '../components-v2/opiskeluoikeus/KoodistoSelect' import { OrganisaatioEdit, OrganisaatioView } from '../components-v2/opiskeluoikeus/OrganisaatioField' -import { TextEdit, TextView } from '../components-v2/controls/TextField' -import { - LocalizedTextEdit, - LocalizedTextView -} from '../components-v2/controls/LocalizedTestField' +import { t } from '../i18n/i18n' +import { IBOpiskeluoikeus } from '../types/fi/oph/koski/schema/IBOpiskeluoikeus' import { IBTutkinnonSuoritus, isIBTutkinnonSuoritus } from '../types/fi/oph/koski/schema/IBTutkinnonSuoritus' import { Koodistokoodiviite } from '../types/fi/oph/koski/schema/Koodistokoodiviite' +import { parasArviointi, viimeisinArviointi } from '../util/arvioinnit' +import { koodiviiteId } from '../util/koodisto' +import { isKoodiarvoOf } from '../util/types' +import { DialogSelect } from '../uusiopiskeluoikeus/components/DialogSelect' import { createIBCASSuoritus } from './oppiaineet/ibTutkintoOppiaine' -import { isKoodiarvoOf, isKoodistoOf } from '../util/types' -import { KoodistoSelect } from '../components-v2/opiskeluoikeus/KoodistoSelect' +import { useExtendedEssayState } from './state/extendedEssay' +import { + useAineryhmäOptions, + useKielivalikoimaOptions, + useOppiaineTasoOptions +} from './state/options' +import { Checkbox } from '../components-v2/controls/Checkbox' +import { useTheoryOfKnowledgeState } from './state/theoryOfKnowledge' export type IBTutkintTiedotProps = { form: FormModel @@ -101,6 +112,7 @@ const IBTutkinnonTiedotRows: React.FC = ({ return ( <> + = ({ ) } +const TheoryOfKnowledgeRows: React.FC = ({ + form, + päätasonSuoritus +}) => { + const state = useTheoryOfKnowledgeState(form, päätasonSuoritus) + const osasuoritukset = päätasonSuoritus.suoritus.osasuoritukset || [] + + return form.editMode ? ( + <> + + + {osasuoritukset.map((os, index) => ( + + TODO + + ))} + {state.pakollinen.visible && ( + + + + )} + + {state.arvosana.visible && ( + + + + )} + + + ) : ( + + { + parasArviointi(päätasonSuoritus.suoritus.extendedEssay?.arviointi) + ?.arvosana.koodiarvo + } + + ) +} + +const ExtendedEssayFieldRows: React.FC = ({ + form, + päätasonSuoritus +}) => { + const state = useExtendedEssayState(form, päätasonSuoritus) + const tunnisteet = useKoodistoOptions('oppiaineetib') + const kielet = useKielivalikoimaOptions(true) + const ryhmät = useAineryhmäOptions(true) + const tasot = useOppiaineTasoOptions(true) + + return form.editMode ? ( + <> + + + {state.tunniste.visible && tunnisteet && ( + +