Skip to content

Commit

Permalink
Merge pull request #394 from dhis2/remove-duplicate-json-parse-func
Browse files Browse the repository at this point in the history
fix: remove duplicate parsing function
  • Loading branch information
flaminic authored Sep 11, 2024
2 parents d3464f8 + f145ae8 commit c1fff39
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/data-workspace/section-form/section-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,17 @@ import cx from 'classnames'
import PropTypes from 'prop-types'
import React from 'react'
import { useSectionFilter } from '../../shared/index.js'
import { getDisplayOptions } from './displayOptions.js'
import { SectionFormSection } from './section.js'
import styles from './section.module.css'

const parseDisplayOptions = (displayOptionString) => {
try {
return displayOptionString && JSON.parse(displayOptionString)
} catch (e) {
console.error(e)
return undefined
}
}

export const SectionForm = ({ dataSet, globalFilterText }) => {
const [sectionId] = useSectionFilter()
const filteredSections = sectionId
? dataSet.sections.filter((s) => s.id === sectionId)
: dataSet.sections

const { displayOptions: displayOptionString } = dataSet
const displayOptions = parseDisplayOptions(displayOptionString)
const displayOptions = getDisplayOptions(dataSet)

if (dataSet.renderAsTabs) {
return (
Expand Down

1 comment on commit c1fff39

@dhis2-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.