diff --git a/CHANGELOG.md b/CHANGELOG.md index 6119fd95..22fda58f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * Modify summary display in organization view mode. Refs UIORGS-398. * Protection of viewing and changes of banking information by permissions. Refs UIORGS-388. * Search organization on bank account number. Refs UIORGS-392. +* Create Privileged donor information accordion in organization record. Refs UIORGS-397. ## [5.0.0](https://github.com/folio-org/ui-organizations/tree/v5.0.0) (2023-10-12) [Full Changelog](https://github.com/folio-org/ui-organizations/compare/v4.0.0...v5.0.0) diff --git a/index.js b/index.js index f2d26fda..1810b9c4 100644 --- a/index.js +++ b/index.js @@ -31,19 +31,19 @@ class Organizations extends Component { - - - {/* - TODO: add Privileged donor information component https://issues.folio.org/browse/UIORGS-397 - */} + ) } diff --git a/src/Organizations/OrganizationForm/OrganizationForm.js b/src/Organizations/OrganizationForm/OrganizationForm.js index 2e3785c6..f569e41f 100644 --- a/src/Organizations/OrganizationForm/OrganizationForm.js +++ b/src/Organizations/OrganizationForm/OrganizationForm.js @@ -19,6 +19,7 @@ import { import { ViewMetaData } from '@folio/stripes/smart-components'; import { FormFooter, + PrivilegedDonorContacts, handleKeyCommand, useAccordionToggle, } from '@folio/stripes-acq-components'; @@ -55,6 +56,7 @@ const OrganizationForm = ({ [ORGANIZATION_SECTIONS.contactInformationSection]: false, [ORGANIZATION_SECTIONS.contactPeopleSection]: false, [ORGANIZATION_SECTIONS.interfacesSection]: false, + [ORGANIZATION_SECTIONS.privilegedDonorInformation]: false, [ORGANIZATION_SECTIONS.vendorInformationSection]: false, [ORGANIZATION_SECTIONS.bankingInformationSection]: false, [ORGANIZATION_SECTIONS.vendorTermsSection]: false, @@ -199,6 +201,20 @@ const OrganizationForm = ({ { formValues.isVendor && ( <> + { + formValues.isDonor && ( + + + + ) + } , [ORGANIZATION_SECTIONS.integrationDetailsSection]: , [ORGANIZATION_SECTIONS.agreements]: , - [ORGANIZATION_SECTIONS.donorContacts]: , + [ORGANIZATION_SECTIONS.privilegedDonorInformation]: , }; export const CREATE_UNITS_PERM = 'organizations.acquisitions-units-assignments.assign'; diff --git a/src/common/constants/api.js b/src/common/constants/api.js index a9055baa..75237d36 100644 --- a/src/common/constants/api.js +++ b/src/common/constants/api.js @@ -4,6 +4,7 @@ export const BANKING_INFORMATION_API = 'organizations/banking-information'; export const CATEGORIES_API = 'organizations-storage/categories'; export const CONTACTS_API = 'organizations-storage/contacts'; export const INTERFACES_API = 'organizations-storage/interfaces'; +export const PRIVILEGED_CONTACTS_API = 'organizations-storage/privileged-contacts'; export const SETTINGS_API = 'organizations-storage/settings'; export const TYPES_API = 'organizations-storage/organization-types'; diff --git a/src/common/resources/contacts.js b/src/common/resources/contacts.js index 54a942b4..636f588b 100644 --- a/src/common/resources/contacts.js +++ b/src/common/resources/contacts.js @@ -1,4 +1,8 @@ -import { CONTACTS_API, MAX_LIMIT } from '../constants'; +import { + CONTACTS_API, + MAX_LIMIT, + PRIVILEGED_CONTACTS_API, +} from '../constants'; export const contactResource = { throwErrors: false, @@ -9,6 +13,15 @@ export const contactResource = { }, }; +export const privilegedContactResource = { + throwErrors: false, + type: 'okapi', + path: `${PRIVILEGED_CONTACTS_API}/:{id}`, + POST: { + path: PRIVILEGED_CONTACTS_API, + }, +}; + export const baseContactsResource = { throwErrors: false, type: 'okapi', diff --git a/src/contacts/ContactsContainer.js b/src/contacts/ContactsContainer.js index 3ba87518..5b0a5034 100644 --- a/src/contacts/ContactsContainer.js +++ b/src/contacts/ContactsContainer.js @@ -16,11 +16,13 @@ import { } from '@folio/stripes-acq-components'; import { VIEW_ORG_DETAILS } from '../common/constants'; -import ViewContact from './ViewContact'; +import { PRIVILEGED_CONTACT_URL_PATH } from './constants'; import EditContact from './EditContact'; +import ViewContact from './ViewContact'; function ContactsContainer({ history, match: { params, url } }) { const sendCallout = useShowCallout(); + const contactsUrlPath = url.includes(PRIVILEGED_CONTACT_URL_PATH) ? PRIVILEGED_CONTACT_URL_PATH : 'contacts'; const showMessage = useCallback((messageKey, messageType = 'success') => { sendCallout({ type: messageType, @@ -32,9 +34,9 @@ function ContactsContainer({ history, match: { params, url } }) { if (!contactId) { history.push(`${VIEW_ORG_DETAILS}${orgId}`); } else { - history.push(`/organizations/${orgId}/contacts/details/${contactId}/view`); + history.push(`/organizations/${orgId}/${contactsUrlPath}/details/${contactId}/view`); } - }, [history]); + }, [contactsUrlPath, history]); const goToEdit = useCallback((props) => ( { const isNew = !match.params.id; - const loadedContact = resources?.contact?.records?.[0]; + const isPrivilegedContactUrl = match.path.includes(PRIVILEGED_CONTACT_URL_PATH); + const contactResources = isPrivilegedContactUrl ? 'privilegedContact' : 'contact'; + const loadedContact = get(resources[contactResources], 'records[0]'); const categories = resources?.[DICT_CATEGORIES]?.records; const [translatedCategories] = useTranslatedCategories(categories); const contactsOrganization = resources?.contactsOrg?.records?.[0]; @@ -36,12 +41,12 @@ export const EditContactContainer = ({ if (onClose) { onClose(orgId, contactId); } else { - history.push(getBackPath(orgId, contactId, 'contacts')); + history.push(getBackPath(orgId, contactId, isPrivilegedContactUrl ? PRIVILEGED_CONTACT_URL_PATH : 'contacts')); } - }, [match.params.id, onClose, history, orgId]); + }, [match.params.id, onClose, orgId, history, isPrivilegedContactUrl]); const onSubmit = useCallback(contactValues => { - saveContact(mutator, contactValues, contactsOrganization) + saveContact(mutator, contactValues, contactsOrganization, isPrivilegedContactUrl) .then(({ id }) => { showMessage('ui-organizations.contacts.message.saved.success', 'success'); onCloseForm(id); @@ -63,6 +68,7 @@ export const EditContactContainer = ({ const contact = isNew ? {} : loadedContact; const { firstName, lastName } = contact; const name = `${lastName}, ${firstName}`; + const paneTitle = isNew ? : ; @@ -82,6 +88,7 @@ EditContactContainer.manifest = Object.freeze({ contact: contactResource, [DICT_CATEGORIES]: categoriesResource, contactsOrg: organizationResource, + privilegedContact: privilegedContactResource, }); EditContactContainer.propTypes = { diff --git a/src/contacts/EditContact/util.js b/src/contacts/EditContact/util.js index 0b236b0c..2689bbab 100644 --- a/src/contacts/EditContact/util.js +++ b/src/contacts/EditContact/util.js @@ -1,7 +1,8 @@ // eslint-disable-next-line import/prefer-default-export -export const saveContact = (mutator, contact, org) => { +export const saveContact = (mutator, contact, org, isPrivilegedContactUrl = false) => { const isNew = !contact.id; - const httpMethod = isNew ? mutator.contact.POST : mutator.contact.PUT; + const currentMutator = isPrivilegedContactUrl ? mutator.privilegedContact : mutator.contact; + const httpMethod = isNew ? currentMutator.POST : currentMutator.PUT; return httpMethod(contact) .then(savedContact => { diff --git a/src/contacts/ViewContact/ViewContact.js b/src/contacts/ViewContact/ViewContact.js index 59fad6a2..3d56a84e 100644 --- a/src/contacts/ViewContact/ViewContact.js +++ b/src/contacts/ViewContact/ViewContact.js @@ -34,6 +34,7 @@ import { ORGANIZATIONS_ROUTE } from '../../common/constants'; import { CONTACT_PERSON_ACCORDIONS, CONTACT_PERSON_ACCORDION_LABELS, + PRIVILEGED_CONTACT_URL_PATH, } from '../constants'; import ContactDetails from './ContactDetails'; import ContactAddresses from './ContactAddresses'; @@ -51,6 +52,7 @@ const ViewContact = ({ }) => { const history = useHistory(); const accordionStatusRef = useRef(); + const isPrivilegedContactUrl = history.location?.pathname?.includes(PRIVILEGED_CONTACT_URL_PATH); const stripes = useStripes(); @@ -81,6 +83,7 @@ const ViewContact = ({ // eslint-disable-next-line react/prop-types const getActionMenu = ({ onToggle }) => { const contactId = contact.id; + const isUnassignVisible = contactId && !isPrivilegedContactUrl; return (
@@ -95,7 +98,7 @@ const ViewContact = ({ - {contactId && ( + {isUnassignVisible && (