From 3d7fc762d14f9dad261df2dfe538da5cd991e1c9 Mon Sep 17 00:00:00 2001 From: Yury Saukou Date: Tue, 26 Nov 2024 11:47:11 +0400 Subject: [PATCH] update card header --- .../OrganizationVersionView.js | 2 -- .../OrganizationContactInfoVersionView.js | 10 ++----- .../components/ContactAddressesVersionView.js | 28 ++++++++----------- .../ContactCardHeaderVersionView.css | 7 +++++ .../ContactCardHeaderVersionView.js | 26 +++++++++++++++++ .../ContactCardHeaderVersionView/index.js | 1 + .../ContactPersonEmailsVersionView.js | 23 ++++++--------- .../ContactPersonPhonesVersionView.js | 23 ++++++--------- .../ContactPersonURLsVersionView.js | 23 ++++++--------- 9 files changed, 74 insertions(+), 69 deletions(-) create mode 100644 src/Organizations/OrganizationVersion/components/OrganizationContactInfoVersionView/components/ContactCardHeaderVersionView/ContactCardHeaderVersionView.css create mode 100644 src/Organizations/OrganizationVersion/components/OrganizationContactInfoVersionView/components/ContactCardHeaderVersionView/ContactCardHeaderVersionView.js create mode 100644 src/Organizations/OrganizationVersion/components/OrganizationContactInfoVersionView/components/ContactCardHeaderVersionView/index.js diff --git a/src/Organizations/OrganizationVersion/OrganizationVersionView/OrganizationVersionView.js b/src/Organizations/OrganizationVersion/OrganizationVersionView/OrganizationVersionView.js index ee667272..d96763da 100644 --- a/src/Organizations/OrganizationVersion/OrganizationVersionView/OrganizationVersionView.js +++ b/src/Organizations/OrganizationVersion/OrganizationVersionView/OrganizationVersionView.js @@ -54,8 +54,6 @@ export const OrganizationVersionView = ({ version }) => { }, ]; - console.log('version', version); - return ( - - + + ))} diff --git a/src/Organizations/OrganizationVersion/components/OrganizationContactInfoVersionView/components/ContactAddressesVersionView.js b/src/Organizations/OrganizationVersion/components/OrganizationContactInfoVersionView/components/ContactAddressesVersionView.js index 72abba41..db641a15 100644 --- a/src/Organizations/OrganizationVersion/components/OrganizationContactInfoVersionView/components/ContactAddressesVersionView.js +++ b/src/Organizations/OrganizationVersion/components/OrganizationContactInfoVersionView/components/ContactAddressesVersionView.js @@ -1,5 +1,4 @@ import PropTypes from 'prop-types'; -import { useContext } from 'react'; import { FormattedMessage } from 'react-intl'; import { @@ -7,29 +6,24 @@ import { Col, Row, } from '@folio/stripes/components'; -import { - VersionKeyValue, - VersionViewContext, -} from '@folio/stripes-acq-components'; +import { VersionKeyValue } from '@folio/stripes-acq-components'; -export const ContactAddressesVersionView = ({ addresses }) => { - const versionContext = useContext(VersionViewContext); +import { ContactCardHeaderVersionView } from './ContactCardHeaderVersionView'; +export const ContactAddressesVersionView = ({ addresses }) => { return ( {addresses?.map((address) => { - const isPrimaryValue = ( -

- -

- ); - const headerStart = versionContext?.paths?.includes(`${address?._initialFieldPath}.isPrimary`) - ? {isPrimaryValue} - : isPrimaryValue; - return ( - + + )} + > { + const versionContext = useContext(VersionViewContext); + + const isUpdated = versionContext?.paths?.includes(name); + + const headerStart = ( +

+ +

+ ); + + return headerStart; +}; + +ContactCardHeaderVersionView.propTypes = { + isPrimary: PropTypes.bool.isRequired, + name: PropTypes.string.isRequired, +}; diff --git a/src/Organizations/OrganizationVersion/components/OrganizationContactInfoVersionView/components/ContactCardHeaderVersionView/index.js b/src/Organizations/OrganizationVersion/components/OrganizationContactInfoVersionView/components/ContactCardHeaderVersionView/index.js new file mode 100644 index 00000000..f958e7ee --- /dev/null +++ b/src/Organizations/OrganizationVersion/components/OrganizationContactInfoVersionView/components/ContactCardHeaderVersionView/index.js @@ -0,0 +1 @@ +export { ContactCardHeaderVersionView } from './ContactCardHeaderVersionView'; diff --git a/src/Organizations/OrganizationVersion/components/OrganizationContactInfoVersionView/components/ContactPersonEmailsVersionView.js b/src/Organizations/OrganizationVersion/components/OrganizationContactInfoVersionView/components/ContactPersonEmailsVersionView.js index 65b6d1b3..46cf494e 100644 --- a/src/Organizations/OrganizationVersion/components/OrganizationContactInfoVersionView/components/ContactPersonEmailsVersionView.js +++ b/src/Organizations/OrganizationVersion/components/OrganizationContactInfoVersionView/components/ContactPersonEmailsVersionView.js @@ -1,5 +1,4 @@ import PropTypes from 'prop-types'; -import { useContext } from 'react'; import { FormattedMessage } from 'react-intl'; import { @@ -10,31 +9,27 @@ import { import { LANG_LABEL_BY_CODE, VersionKeyValue, - VersionViewContext, } from '@folio/stripes-acq-components'; import { ContactPersonSection } from '../../../../../ContactPeople/ContactPerson'; +import { ContactCardHeaderVersionView } from './ContactCardHeaderVersionView'; export const ContactPersonEmailsVersionView = ({ emails }) => { - const versionContext = useContext(VersionViewContext); - if (!emails?.length) return null; const renderBody = () => ( {emails?.map((email) => { - const isPrimaryValue = ( -

- -

- ); - const headerStart = versionContext?.paths?.includes(`${email?._initialFieldPath}.isPrimary`) - ? {isPrimaryValue} - : isPrimaryValue; - return ( - + + )} + > { - const versionContext = useContext(VersionViewContext); - if (!phones?.length) return null; const renderBody = () => ( @@ -25,17 +22,15 @@ export const ContactPersonPhonesVersionView = ({ phones }) => { {phones?.map((phone) => { - const isPrimaryValue = ( -

- -

- ); - const headerStart = versionContext?.paths?.includes(`${phone?._initialFieldPath}.isPrimary`) - ? {isPrimaryValue} - : isPrimaryValue; - return ( - + + )} + > { - const versionContext = useContext(VersionViewContext); - if (!urls?.length) return null; const renderBody = () => ( {urls?.map((url) => { - const isPrimaryValue = ( -

- -

- ); - const headerStart = versionContext?.paths?.includes(`${url?._initialFieldPath}.isPrimary`) - ? {isPrimaryValue} - : isPrimaryValue; - return ( - + + )} + >