Skip to content

Commit

Permalink
refactor(use has field value): add "id" field to query to suppress co…
Browse files Browse the repository at this point in the history
…nsole.warn
  • Loading branch information
Mohammer5 committed Oct 30, 2023
1 parent 526fc8b commit 2a908ba
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/pages/dataElements/form/useHasFieldValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const HAS_FIELD_VALUE_QUERY = {
resource: 'dataElements',
params: (variables: Record<string, string>) => ({
pageSize: 1,
fields: '',
fields: 'id',
filter: [`${variables.field}:eq:${variables.value}`],
}),
},
Expand Down Expand Up @@ -38,13 +38,14 @@ export function useHasFieldValue(field: string) {
// so we have to ignore the type error
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
(data: QueryResponse) =>
data.dataElements.pager.total
? i18n.t(
'This {{field}} already exists, please choose antoher one',
{ field }
)
: undefined
(data: QueryResponse) => {
if (data.dataElements.pager.total) {
return i18n.t(
'This {{field}} already exists, please choose antoher one',
{ field }
)
}
}
)
},
}),
Expand Down

0 comments on commit 2a908ba

Please sign in to comment.