-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UISACQCOMP-168: extend <Donors />
component props
#730
Changes from 4 commits
31f95e9
eecb03d
26b9fdb
5da4eda
83a6b08
f733e86
00d15f7
6344233
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import { map, sortBy } from 'lodash'; | ||
import { map, noop, sortBy } from 'lodash'; | ||
import PropTypes from 'prop-types'; | ||
import { useMemo } from 'react'; | ||
import { useIntl } from 'react-intl'; | ||
|
||
import { useStripes } from '@folio/stripes/core'; | ||
|
||
import { defaultContainerVisibleColumns } from './constants'; | ||
import { | ||
defaultContainerVisibleColumns, | ||
pluginVisibleColumns, | ||
} from './constants'; | ||
import { DonorsList } from './DonorsList'; | ||
import { DonorsLookup } from './DonorsLookup'; | ||
import { getDonorsFormatter } from './utils'; | ||
|
@@ -14,9 +17,12 @@ export function DonorsContainer({ | |
columnMapping, | ||
columnWidths, | ||
donors, | ||
donorIds, | ||
fields, | ||
formatter, | ||
id, | ||
onRemove, | ||
pluginVisibleColumns: pluginVisibleColumnsProp, | ||
setDonorIds, | ||
searchLabel, | ||
showTriggerButton, | ||
|
@@ -35,21 +41,21 @@ export function DonorsContainer({ | |
}, {}); | ||
}, [donors]); | ||
|
||
const listOfDonors = useMemo(() => (fields.value || []) | ||
const listOfDonors = useMemo(() => (donorIds || []) | ||
.map((contactId, _index) => { | ||
const contact = donorsMap?.[contactId]; | ||
|
||
return { | ||
...(contact || { isDeleted: true }), | ||
_index, | ||
}; | ||
}), [donorsMap, fields.value]); | ||
}), [donorIds, donorsMap]); | ||
|
||
const contentData = useMemo(() => sortBy(listOfDonors, [({ lastName }) => lastName?.toLowerCase()]), [listOfDonors]); | ||
|
||
const resultsFormatter = useMemo(() => { | ||
return formatter || getDonorsFormatter({ intl, fields, canViewOrganizations }); | ||
}, [canViewOrganizations, fields, formatter, intl]); | ||
return formatter || getDonorsFormatter({ intl, fields, canViewOrganizations, onRemove }); | ||
}, [canViewOrganizations, fields, formatter, intl, onRemove]); | ||
|
||
const onAddDonors = (values = []) => { | ||
const addedDonorIds = new Set(fields.value); | ||
|
@@ -79,7 +85,7 @@ export function DonorsContainer({ | |
onAddDonors={onAddDonors} | ||
name={id} | ||
searchLabel={searchLabel} | ||
visibleColumns={visibleColumns} | ||
visibleColumns={pluginVisibleColumnsProp} | ||
/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you really need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean |
||
) | ||
} | ||
|
@@ -91,16 +97,21 @@ DonorsContainer.propTypes = { | |
columnWidths: PropTypes.object, | ||
columnMapping: PropTypes.object, | ||
donors: PropTypes.arrayOf(PropTypes.object), | ||
donorIds: PropTypes.arrayOf(PropTypes.string), | ||
fields: PropTypes.object, | ||
formatter: PropTypes.object, | ||
id: PropTypes.string, | ||
onRemove: PropTypes.func, | ||
searchLabel: PropTypes.node, | ||
setDonorIds: PropTypes.func.isRequired, | ||
showTriggerButton: PropTypes.bool, | ||
visibleColumns: PropTypes.arrayOf(PropTypes.string), | ||
pluginVisibleColumns: PropTypes.arrayOf(PropTypes.string), | ||
}; | ||
|
||
DonorsContainer.defaultProps = { | ||
onRemove: noop, | ||
showTriggerButton: true, | ||
visibleColumns: defaultContainerVisibleColumns, | ||
pluginVisibleColumns, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { Donors } from './Donors'; | ||
export { DonorsList } from './DonorsList'; | ||
export { DonorsListContainer } from './DonorsListContainer'; | ||
export { DonorsLookup } from './DonorsLookup'; | ||
export { useFetchDonors } from './hooks/useFetchDonors'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please apply some changes to improve the UX (keep prev changes in the MCL and display loading indicator inside the list):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very nice improvement. Thank you for your advice.