Skip to content

Commit

Permalink
chore: fix lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
Chisomchima committed Apr 4, 2024
1 parent 6326a69 commit 4389ae3
Show file tree
Hide file tree
Showing 67 changed files with 166 additions and 165 deletions.
2 changes: 1 addition & 1 deletion cypress/integration/user-group/search-groups/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Then(
'only the user groups whose display name contains the search term should be displayed',
() => {
cy.get('[data-test="dhis2-uicore-tablebody"] tr td:first-child').each(
$td => {
($td) => {
cy.wrap($td).contains(NAME_SEARCH_QUERY, { matchCase: false })
}
)
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/user-role/search-roles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Then(
'only the user roles whose display name contains the search term should be displayed',
() => {
cy.get('[data-test="dhis2-uicore-tablebody"] tr td:first-child').each(
$td => {
($td) => {
cy.wrap($td).contains(NAME_SEARCH_QUERY, { matchCase: false })
}
)
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/user/search-users/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ When('the user-manager searches the list by entering a name', () => {
Then(
'only the users whose username or display name contains the search term should be displayed',
() => {
cy.get('[data-test="dhis2-uicore-tablebody"] tr').each($tr => {
cy.get('[data-test="dhis2-uicore-tablebody"] tr').each(($tr) => {
// Either the display name cell or the username cell will contain
// text matching the search query, so check entire row
cy.wrap($tr).contains(NAME_SEARCH_QUERY, { matchCase: false })
Expand Down
2 changes: 1 addition & 1 deletion src/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const groupAttributesQuery = {
}

export const getAttributeValues = ({ attributes, values }) =>
attributes.map(attribute => {
attributes.map((attribute) => {
let value = values.attributeValues?.[attribute.id] || ''
if (attribute.valueType === 'TRUE_ONLY' && !value) {
value = ''
Expand Down
4 changes: 2 additions & 2 deletions src/components/Attributes/Attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
useDebouncedUniqueAttributeValidator,
} from './validators.js'

const getFieldName = attribute => `attributeValues.${attribute.id}`
const getFieldName = (attribute) => `attributeValues.${attribute.id}`

/**************************************************************************
* Attributes can be either based on an optionSet, or based on a valueType.
Expand Down Expand Up @@ -68,7 +68,7 @@ const Attribute = ({ attribute, value, entity, entityType }) => {
})
)
// SingleSelectField throws an error if its value does not correspond to an option
const initialValue = options.find(option => option.value === value)
const initialValue = options.find((option) => option.value === value)
? value
: undefined

Expand Down
2 changes: 1 addition & 1 deletion src/components/Attributes/Attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Attributes = React.memo(
return values
}, new Map())

return attributes.map(attribute => (
return attributes.map((attribute) => (
<Attribute
key={attribute.id}
attribute={attribute}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Attributes/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const useDebouncedUniqueAttributeValidator = ({
entityType,
}) => {
const engine = useDataEngine()
const findAllByAttributeValue = pDebounce(async value => {
const findAllByAttributeValue = pDebounce(async (value) => {
const filters = [
`attributeValues.attribute.id:eq:${attribute.id}`,
`attributeValues.value:eq:${value}`,
Expand All @@ -41,13 +41,13 @@ export const useDebouncedUniqueAttributeValidator = ({
// value and attributeId
return entities[entityType].filter(({ attributeValues }) =>
attributeValues.some(
attributeValue =>
(attributeValue) =>
attributeValue.attribute.id === attribute.id &&
attributeValue.value === value
)
)
}, 350)
const validator = async value => {
const validator = async (value) => {
if (value === currentValue) {
return
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/BulkMemberManager/BulkMemberManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const BulkMemberManager = ({
? rowActionLabel({ mode })
: rowActionLabel
}
onActionClick={entity => {
onActionClick={(entity) => {
onChange(
mode === 'MEMBERS'
? removeEntity(pendingChanges, entity)
Expand All @@ -126,7 +126,7 @@ const BulkMemberManager = ({
deselect(entity.id)
}}
pendingChanges={pendingChanges}
onPendingChangeCancel={entity => {
onPendingChangeCancel={(entity) => {
onChange(
mode === 'MEMBERS'
? cancelRemoveEntity(pendingChanges, entity)
Expand Down Expand Up @@ -175,11 +175,11 @@ BulkMemberManager.defaultProps = {
columns: [
{
label: i18n.t('Display name'),
mapDataToValue: entity => entity.displayName,
mapDataToValue: (entity) => entity.displayName,
},
],
filterDebounceMs: 375,
transformQueryResponse: response => response,
transformQueryResponse: (response) => response,
}

const QueryPropType = PropTypes.shape({
Expand Down
4 changes: 2 additions & 2 deletions src/components/BulkMemberManager/PendingChanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const PendingChanges = ({ pendingChanges, onChange }) => (
)}
</div>
<div className={styles.scrollbox}>
{pendingChanges.additions.map(entity => (
{pendingChanges.additions.map((entity) => (
<div key={entity.id} className={styles.pendingAddRow}>
<span className={styles.pendingChangeSummary}>
<IconAdd16 color={colors.green700} />
Expand All @@ -49,7 +49,7 @@ const PendingChanges = ({ pendingChanges, onChange }) => (
</Button>
</div>
))}
{pendingChanges.removals.map(entity => (
{pendingChanges.removals.map((entity) => (
<div key={entity.id} className={styles.pendingRemoveRow}>
<span className={styles.pendingChangeSummary}>
<IconCross16 color={colors.red700} />
Expand Down
8 changes: 4 additions & 4 deletions src/components/BulkMemberManager/ResultsTable/ResultsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const ResultsTable = ({
onChange={() => onToggleAllSelected(pendingChanges)}
/>
</DataTableColumnHeader>
{columns.map(column => (
{columns.map((column) => (
<DataTableColumnHeader key={column.label}>
{column.label}
</DataTableColumnHeader>
Expand All @@ -89,16 +89,16 @@ const ResultsTable = ({
</DataTableRow>
</DataTableHead>
<DataTableBody loading={loading}>
{results.map(result => {
{results.map((result) => {
const pendingChangeEntity = (
mode === 'MEMBERS'
? pendingChanges.removals
: pendingChanges.additions
).find(e => e.id === result.id)
).find((e) => e.id === result.id)
const hasPendingChange = !!pendingChangeEntity
const pendingChangeAction =
mode === 'MEMBERS' ? 'REMOVE' : 'ADD'
const cells = columns.map(column =>
const cells = columns.map((column) =>
column.mapDataToValue(result)
)

Expand Down
17 changes: 9 additions & 8 deletions src/components/BulkMemberManager/hooks/useResults/useResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export const useResults = ({
: prevPageRef.current.nonMembers.pager

const navigateToPage = useCallback(
page => refetch({ page, filter: queryFilter, inverse: !isMemberMode }),
(page) =>
refetch({ page, filter: queryFilter, inverse: !isMemberMode }),
[refetch, queryFilter, isMemberMode]
)

Expand Down Expand Up @@ -112,29 +113,29 @@ export const useResults = ({
results,
pager: data ? data.results.pager : prevPager,
navigateToPage,
isSelected: id => selected.has(id),
isPendingChange: id => pendingChangesForMode.has(id),
deselect: id => {
isSelected: (id) => selected.has(id),
isPendingChange: (id) => pendingChangesForMode.has(id),
deselect: (id) => {
selected.delete(id)
},
toggleSelected: id => {
toggleSelected: (id) => {
if (selected.has(id)) {
selected.delete(id)
} else {
selected.add(id)
}
},
toggleAllSelected: pendingChanges => {
toggleAllSelected: (pendingChanges) => {
const pendingIdsSet = new Set(
pendingChanges.additions
.concat(pendingChanges.removals)
.map(({ id }) => id)
)
const ids = results.map(({ id }) => id)
if (ids.some(id => selected.has(id))) {
if (ids.some((id) => selected.has(id))) {
ids.forEach(selected.delete)
} else {
ids.forEach(id => {
ids.forEach((id) => {
if (!pendingIdsSet.has(id)) {
selected.add(id)
}
Expand Down
10 changes: 5 additions & 5 deletions src/components/BulkMemberManager/hooks/useResults/useSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ export const useSet = () => {

return useMemo(
() => ({
has: value => set.has(value),
add: value => {
setSet(set => {
has: (value) => set.has(value),
add: (value) => {
setSet((set) => {
const newSet = new Set(set)
newSet.add(value)
return newSet
})
},
delete: value => {
setSet(set => {
delete: (value) => {
setSet((set) => {
const newSet = new Set(set)
newSet.delete(value)
return newSet
Expand Down
6 changes: 3 additions & 3 deletions src/components/BulkMemberManager/pendingChangesActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ export const removeEntity = (pendingChanges, entity) => ({

export const cancelAddEntity = (pendingChanges, entity) => ({
...pendingChanges,
additions: pendingChanges.additions.filter(e => e !== entity),
additions: pendingChanges.additions.filter((e) => e !== entity),
})

export const cancelRemoveEntity = (pendingChanges, entity) => ({
...pendingChanges,
removals: pendingChanges.removals.filter(e => e !== entity),
removals: pendingChanges.removals.filter((e) => e !== entity),
})

export const totalPendingChanges = pendingChanges =>
export const totalPendingChanges = (pendingChanges) =>
pendingChanges.additions.length + pendingChanges.removals.length
14 changes: 7 additions & 7 deletions src/components/CurrentUserProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,25 +113,25 @@ const CurrentUserProvider = ({ children }) => {
teiSearchOrganisationUnits: data.me.teiSearchOrganisationUnits ?? [],
systemOrganisationUnitRoots:
data.systemOrganisationUnitRoots.organisationUnits ?? [],
hasAppAccess: data.me.authorities.some(auth =>
hasAppAccess: data.me.authorities.some((auth) =>
AUTH_LOOKUP.APP.has(auth)
),
hasUserSectionAccess: data.me.authorities.some(auth =>
hasUserSectionAccess: data.me.authorities.some((auth) =>
AUTH_LOOKUP.USER.has(auth)
),
hasGroupSectionAccess: data.me.authorities.some(auth =>
hasGroupSectionAccess: data.me.authorities.some((auth) =>
AUTH_LOOKUP.GROUP.has(auth)
),
hasRoleSectionAccess: data.me.authorities.some(auth =>
hasRoleSectionAccess: data.me.authorities.some((auth) =>
AUTH_LOOKUP.ROLE.has(auth)
),
canCreateUsers: data.me.authorities.some(auth =>
canCreateUsers: data.me.authorities.some((auth) =>
AUTH_LOOKUP.USER_CREATE.has(auth)
),
canCreateGroups: data.me.authorities.some(auth =>
canCreateGroups: data.me.authorities.some((auth) =>
AUTH_LOOKUP.GROUP_CREATE.has(auth)
),
canCreateRoles: data.me.authorities.some(auth =>
canCreateRoles: data.me.authorities.some((auth) =>
AUTH_LOOKUP.ROLE_CREATE.has(auth)
),
refresh: refetch,
Expand Down
18 changes: 9 additions & 9 deletions src/components/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ FormSection.propTypes = {
description: PropTypes.string,
}

const InputFieldFFWrapper = props => {
const InputFieldFFWrapper = (props) => {
// `meta.validating` is true for all fields when an async validator is used
// so only show spinner if input field is currently focused
const validating = props.meta.active && props.meta.validating
Expand All @@ -51,15 +51,15 @@ InputFieldFFWrapper.propTypes = {
meta: PropTypes.object,
}

export const TextField = props => (
export const TextField = (props) => (
<ReactFinalForm.Field
{...props}
className={styles.textField}
component={InputFieldFFWrapper}
/>
)

export const EmailField = props => (
export const EmailField = (props) => (
<ReactFinalForm.Field
{...props}
className={styles.textField}
Expand All @@ -68,7 +68,7 @@ export const EmailField = props => (
/>
)

export const PasswordField = props => (
export const PasswordField = (props) => (
<ReactFinalForm.Field
{...props}
className={styles.passwordField}
Expand All @@ -77,7 +77,7 @@ export const PasswordField = props => (
/>
)

export const DateField = props => (
export const DateField = (props) => (
<ReactFinalForm.Field
{...props}
className={styles.dateField}
Expand All @@ -86,23 +86,23 @@ export const DateField = props => (
/>
)

export const TextAreaField = props => (
export const TextAreaField = (props) => (
<ReactFinalForm.Field
{...props}
className={styles.textField}
component={TextAreaFieldFF}
/>
)

export const SingleSelectField = props => (
export const SingleSelectField = (props) => (
<ReactFinalForm.Field
{...props}
className={styles.singleSelectField}
component={SingleSelectFieldFF}
/>
)

export const CheckboxField = props => (
export const CheckboxField = (props) => (
<ReactFinalForm.Field
{...props}
className={styles.field}
Expand Down Expand Up @@ -147,7 +147,7 @@ export const SearchableOrgUnitTreeField = ({
// Fixes the infinite loop rendering bug that occurs when the
// initial value fails shallow equal on form rerender.
// Issue on GitHub: https://github.com/final-form/react-final-form/issues/686
const [memoedInitialValue] = useState(initialValue.map(ou => ou.id))
const [memoedInitialValue] = useState(initialValue.map((ou) => ou.id))

return (
<ReactFinalForm.Field
Expand Down
8 changes: 4 additions & 4 deletions src/components/GroupForm/BulkUserManager/BulkUserManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const renderTopBarActionText = ({ mode, selectedCount }) =>
const renderRowActionLabel = ({ mode }) =>
mode === 'MEMBERS' ? i18n.t('Remove from group') : i18n.t('Add to group')

const transformUserResults = results =>
results.users.map(user => ({
const transformUserResults = (results) =>
results.users.map((user) => ({
...user,
displayName: user.username || user.name,
}))
Expand All @@ -59,11 +59,11 @@ const BulkUserManager = ({ className, groupId, value, onChange }) => {
columns={[
{
label: i18n.t('Username'),
mapDataToValue: user => user.username,
mapDataToValue: (user) => user.username,
},
{
label: i18n.t('Display name'),
mapDataToValue: user => user.name,
mapDataToValue: (user) => user.name,
},
]}
rowActionLabel={renderRowActionLabel}
Expand Down
Loading

0 comments on commit 4389ae3

Please sign in to comment.