Skip to content

Commit 103f275

Browse files
committed
refactor: clean up formatting
1 parent a3ee0a5 commit 103f275

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

src/period-types/PeriodTypes.component.jsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { useDataQuery } from '@dhis2/app-runtime'
22
import i18n from '@dhis2/d2-i18n'
33
import { CenteredContent, CircularLoader } from '@dhis2/ui'
4+
import { getInstance as getD2 } from 'd2'
45
import CheckboxMaterial from 'material-ui/Checkbox'
56
import React, { useState, useCallback } from 'react'
6-
import { getInstance as getD2 } from 'd2'
77
import settingsActions from '../settingsActions.js'
88
import styles from './PeriodTypes.module.css'
99

@@ -143,7 +143,6 @@ const PeriodTypes = () => {
143143
try {
144144
const d2 = await getD2()
145145
const api = d2.Api.getApi()
146-
const allPeriodTypes = data?.periodTypes?.periodTypes || []
147146
const allowedPeriodTypes = data?.dataOutputPeriodTypes || []
148147
// Handle both array of strings and array of objects with name property
149148
const currentAllowedSet = new Set(
@@ -161,18 +160,21 @@ const PeriodTypes = () => {
161160

162161
// Convert set to array of objects with name property
163162
// The API expects: [{name: "Monthly"}, {name: "Quarterly"}, ...]
164-
const updatedPeriodTypes = Array.from(currentAllowedSet).map((name) => ({
165-
name,
166-
}))
163+
const updatedPeriodTypes = Array.from(currentAllowedSet).map(
164+
(name) => ({
165+
name,
166+
})
167+
)
167168

168169
// POST to the configuration endpoint
169-
await api.post('configuration/dataOutputPeriodTypes', updatedPeriodTypes)
170+
await api.post(
171+
'configuration/dataOutputPeriodTypes',
172+
updatedPeriodTypes
173+
)
170174

171175
// Refetch the data to get the updated state
172176
await refetch()
173-
settingsActions.showSnackbarMessage(
174-
i18n.t('Settings updated')
175-
)
177+
settingsActions.showSnackbarMessage(i18n.t('Settings updated'))
176178
} catch (err) {
177179
console.error('Failed to update period types:', err)
178180
settingsActions.showSnackbarMessage(
@@ -212,9 +214,7 @@ const PeriodTypes = () => {
212214
// Create a Set of allowed period type names for quick lookup
213215
// Handle both array of strings and array of objects with name property
214216
const allowedSet = new Set(
215-
allowedPeriodTypes.map((pt) =>
216-
typeof pt === 'string' ? pt : pt.name
217-
)
217+
allowedPeriodTypes.map((pt) => (typeof pt === 'string' ? pt : pt.name))
218218
)
219219

220220
// Group period types by frequency
@@ -263,4 +263,4 @@ const PeriodTypes = () => {
263263
)
264264
}
265265

266-
export default PeriodTypes
266+
export default PeriodTypes

src/settingsFields.component.jsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ function wrapUserSettingsOverride({ component, valueLabel }) {
8484

8585
const labelText = valueLabel
8686
? `${i18n.t(
87-
'This setting will be overridden by the current user setting: {{settingName}}',
88-
{
89-
settingName: valueLabel,
90-
nsSeparator: '-:-',
91-
}
92-
)}`
87+
'This setting will be overridden by the current user setting: {{settingName}}',
88+
{
89+
settingName: valueLabel,
90+
nsSeparator: '-:-',
91+
}
92+
)}`
9393
: i18n.t('This setting can be overridden by user settings')
9494

9595
return (
@@ -309,7 +309,6 @@ class SettingsFields extends React.Component {
309309

310310
case 'periodTypes':
311311
return Object.assign({}, fieldBase, {
312-
313312
component: PeriodTypes,
314313
})
315314
default:
@@ -393,16 +392,16 @@ class SettingsFields extends React.Component {
393392
(options && options.userSettingsNoFallback) || {}
394393
const userSettingValue =
395394
userSettingsNoFallback &&
396-
userSettingsNoFallback[field.name] !== null
395+
userSettingsNoFallback[field.name] !== null
397396
? userSettingsNoFallback[field.name]
398397
: ''
399398
const component = wrapUserSettingsOverride({
400399
component: field.component,
401400
valueLabel: mapping.source
402401
? ((options && options[mapping.source]) || [])
403-
.filter((opt) => opt.id === userSettingValue)
404-
.map((opt) => opt.displayName)
405-
.pop()
402+
.filter((opt) => opt.id === userSettingValue)
403+
.map((opt) => opt.displayName)
404+
.pop()
406405
: userSettingValue,
407406
})
408407

0 commit comments

Comments
 (0)