-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CM-456: adjust fe to create deduplication tasks
- Loading branch information
Jan
committed
Jan 23, 2024
1 parent
b53053d
commit 13f3b94
Showing
6 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,52 @@ | ||
import { | ||
graphql, | ||
formatQuery, | ||
formatMutation, | ||
} from '@openimis/fe-core'; | ||
import { ACTION_TYPE } from './reducer'; | ||
import { ERROR, REQUEST, SUCCESS } from './util/action-type'; | ||
|
||
const DEDUPLICATION_SUMMARY_FULL_PROJECTION = () => [ | ||
'rows {count, columnValues}', | ||
'rows {count, ids, columnValues}', | ||
]; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export function fetchDeduplicationSummary(params) { | ||
const payload = formatQuery('beneficiaryDeduplicationSummary', params, DEDUPLICATION_SUMMARY_FULL_PROJECTION()); | ||
return graphql(payload, ACTION_TYPE.GET_DEDUPLICATION_SUMMARY); | ||
} | ||
|
||
function formatDeduplicationTasksMutation(summary) { | ||
if (!summary || !Array.isArray(summary)) { | ||
return ''; | ||
} | ||
|
||
const formattedSummary = summary.map((item) => { | ||
const keyValuePairs = Object.entries(item) | ||
.map(([key, value]) => `${key}: ${JSON.stringify(value)}`) | ||
.join(', '); | ||
|
||
return `{ ${keyValuePairs} }`; | ||
}); | ||
|
||
return `summary: [${formattedSummary.join(', ')}]`; | ||
} | ||
export function createDeduplicationTasks(summary, clientMutationLabel) { | ||
console.log(formatDeduplicationTasksMutation(summary)); | ||
const mutation = formatMutation( | ||
'createDeduplicationTasks', | ||
formatDeduplicationTasksMutation(summary), | ||
clientMutationLabel, | ||
); | ||
const requestedDateTime = new Date(); | ||
return graphql( | ||
mutation.payload, | ||
[REQUEST(ACTION_TYPE.MUTATION), SUCCESS(ACTION_TYPE.CREATE_DEDUPLICATION_TASKS), ERROR(ACTION_TYPE.MUTATION)], | ||
{ | ||
actionType: ACTION_TYPE.CREATE_DEDUPLICATION_TASKS, | ||
clientMutationId: mutation.clientMutationId, | ||
clientMutationLabel, | ||
requestedDateTime, | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters