Skip to content

Commit

Permalink
Korjaa virheellinen prisma;
Browse files Browse the repository at this point in the history
Lisäksi älä kaada koko käliä, jos virheellisellä optiikalla yritetään lukea dataa. Jätä se vain mieluummin tyhjäksi.
  • Loading branch information
ilkkahanninen committed Jan 16, 2025
1 parent ea35438 commit f9f42ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
22 changes: 14 additions & 8 deletions web/app/components-v2/forms/FormModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,14 +430,20 @@ export type FormOptic<S, A> =
export const getValue =
<S, A>(optic: FormOptic<S, A>) =>
(source: S): A | undefined => {
switch (optic._tag) {
case 'Equivalence':
case 'Lens':
return $.get(optic)(source)
case 'Prism':
return $.preview(optic)(source)
default:
assertNever(optic)
try {
switch (optic._tag) {
case 'Equivalence':
case 'Lens':
return $.get(optic)(source)
case 'Prism':
return $.preview(optic)(source)

default:
assertNever(optic)
}
} catch {
console.error('An invalid optic detected')
return undefined
}
}

Expand Down
1 change: 1 addition & 0 deletions web/app/ib/IBPaatasonSuoritusTiedot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ const TheoryOfKnowledgeRows: React.FC<IBTutkinnonTiedotRowsProps> = ({
path={theoryOfKnowledgePath
.optional()
.prop('arviointi')
.optional()
.compose(lastElement())}
view={ArvosanaView}
edit={ArvosanaEdit}
Expand Down

0 comments on commit f9f42ca

Please sign in to comment.