From da8a1c2561f7b4df7759183f8068daf36f78e558 Mon Sep 17 00:00:00 2001 From: Alisher Musurmonov Date: Thu, 9 Nov 2023 14:36:20 +0500 Subject: [PATCH 1/5] updated default formatters --- lib/Donors/DonorsContainer.js | 18 +++--------------- lib/Donors/utils.js | 3 ++- lib/Donors/utils.test.js | 6 +++--- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/lib/Donors/DonorsContainer.js b/lib/Donors/DonorsContainer.js index 615b3c3b..90f156cf 100644 --- a/lib/Donors/DonorsContainer.js +++ b/lib/Donors/DonorsContainer.js @@ -8,10 +8,7 @@ import { useStripes } from '@folio/stripes/core'; import { defaultVisibleColumns } from './constants'; import { DonorsList } from './DonorsList'; import { DonorsLookup } from './DonorsLookup'; -import { - getDonorsListFormatter, - getUnAssignDonorFormatter, -} from './utils'; +import { getDonorsFormatter } from './utils'; export function DonorsContainer({ columnMapping, @@ -50,17 +47,8 @@ export function DonorsContainer({ const contentData = useMemo(() => sortBy(listOfDonors, [({ lastName }) => lastName?.toLowerCase()]), [listOfDonors]); const resultsFormatter = useMemo(() => { - const defaultFormatter = formatter || getDonorsListFormatter({ intl, fields, canViewOrganizations }); - - if (visibleColumns.includes('unassignDonor')) { - return { - ...getUnAssignDonorFormatter({ intl, fields }), - ...defaultFormatter, - }; - } - - return defaultFormatter; - }, [canViewOrganizations, fields, formatter, intl, visibleColumns]); + return formatter || getDonorsFormatter({ intl, fields, canViewOrganizations }); + }, [canViewOrganizations, fields, formatter, intl]); const onAddDonors = (values = []) => { const addedDonorIds = new Set(fields.value); diff --git a/lib/Donors/utils.js b/lib/Donors/utils.js index a31a8569..b706eaab 100644 --- a/lib/Donors/utils.js +++ b/lib/Donors/utils.js @@ -17,7 +17,8 @@ export const getDonorsListFormatter = ({ canViewOrganizations }) => ({ code: donor => donor.code, }); -export const getUnAssignDonorFormatter = ({ fields, intl }) => ({ +export const getDonorsFormatter = ({ canViewOrganizations, fields, intl }) => ({ + ...getDonorsListFormatter({ canViewOrganizations }), unassignDonor: donor => (