diff --git a/src/components/Accordion/CalendarAccordion/CalendarAccordion.jsx b/src/components/Accordion/CalendarAccordion/CalendarAccordion.jsx index 0a7b2051..a796242c 100644 --- a/src/components/Accordion/CalendarAccordion/CalendarAccordion.jsx +++ b/src/components/Accordion/CalendarAccordion/CalendarAccordion.jsx @@ -23,6 +23,7 @@ import { sortByOptionsOrgsPlacesPerson } from '../../../constants/sortByOptions' import { useLazyGetAllOrganizationQuery } from '../../../services/organization'; import { UserOutlined } from '@ant-design/icons'; import { useLazyGetAllPeopleQuery } from '../../../services/people'; +import { taxonomyClass } from '../../../constants/taxonomyClass'; const { Panel } = Collapse; @@ -362,6 +363,11 @@ function CalendarAccordion(props) { name={organizer?.name} description={organizer?.description} bordered + onClickHandle={{ + navigationFlag: readOnly, + entityType: organizer?.type ?? taxonomyClass.ORGANIZATION, + entityId: organizer?.value, + }} closable={readOnly ? false : true} itemWidth="100%" onClose={() => { @@ -477,6 +483,11 @@ function CalendarAccordion(props) { ) } + onClickHandle={{ + navigationFlag: readOnly, + entityType: people?.type ?? taxonomyClass.PERSON, + entityId: people?.value, + }} name={people?.name} description={people?.description} calendarContentLanguage={calendarContentLanguage} diff --git a/src/components/List/SelectionItem/SelectionItem.jsx b/src/components/List/SelectionItem/SelectionItem.jsx index 639dcac8..0115e9d0 100644 --- a/src/components/List/SelectionItem/SelectionItem.jsx +++ b/src/components/List/SelectionItem/SelectionItem.jsx @@ -12,6 +12,9 @@ import ReadOnlyProtectedComponent from '../../../layout/ReadOnlyProtectedCompone import LiteralBadge from '../../Badge/LiteralBadge'; import { contentLanguageKeyMap } from '../../../constants/contentLanguage'; import { isDataValid } from '../../../utils/MultiLingualFormItemSupportFunctions.js'; +import { taxonomyClass } from '../../../constants/taxonomyClass.js'; +import { PathName } from '../../../constants/pathName.js'; +import { useNavigate, useParams } from 'react-router-dom'; function SelectionItem(props) { const { icon, @@ -33,10 +36,12 @@ function SelectionItem(props) { edit, creatorId, fallbackConfig, + onClickHandle = { navigationFlag: false }, } = props; const { t } = useTranslation(); const { user } = useSelector(getUserDetails); - + const navigate = useNavigate(); + const { calendarId } = useParams(); let literalKey = '?'; const promptFlag = calendarContentLanguage.some((language) => { @@ -58,10 +63,30 @@ function SelectionItem(props) { ? t('common.forms.languageLiterals.unKnownLanguagePromptText') : t('common.forms.languageLiterals.knownLanguagePromptText'); + const routinghandler = (e) => { + const type = onClickHandle?.entityType; + const id = onClickHandle?.entityId; + e.stopPropagation(); + + if (type?.toUpperCase() == taxonomyClass.ORGANIZATION) + navigate(`${PathName.Dashboard}/${calendarId}${PathName.Organizations}/${id}`); + else if (type?.toUpperCase() == taxonomyClass.PERSON) + navigate(`${PathName.Dashboard}/${calendarId}${PathName.People}/${id}`); + else if (type?.toUpperCase() == taxonomyClass.PLACE) + navigate(`${PathName.Dashboard}/${calendarId}${PathName.Places}/${id}`); + else if (type?.toUpperCase() == taxonomyClass.EVENT) + navigate(`${PathName.Dashboard}/${calendarId}${PathName.Events}/${id}`); + }; + return (
+ onClick={onClickHandle?.navigationFlag && routinghandler} + style={{ + border: bordered && '1px solid#607EFC', + width: itemWidth && itemWidth, + ...(onClickHandle?.navigationFlag && { cursor: 'pointer' }), + }}> )}
@@ -905,6 +910,11 @@ function EventReadOnly() { bordered closable={false} itemWidth="100%" + onClickHandle={{ + navigationFlag: true, + entityType: organizer?.type, + entityId: organizer?.value, + }} /> ); })} @@ -985,6 +995,11 @@ function EventReadOnly() { calendarContentLanguage={calendarContentLanguage} bordered closable={false} + onClickHandle={{ + navigationFlag: true, + entityType: performer?.type, + entityId: performer?.value, + }} itemWidth="100%" /> ); @@ -1011,6 +1026,11 @@ function EventReadOnly() { bordered itemWidth="100%" closable={false} + onClickHandle={{ + navigationFlag: true, + entityType: supporter?.type, + entityId: supporter?.value, + }} /> ); })} diff --git a/src/pages/Dashboard/OrganizationsReadOnly/OrganizationsReadOnly.jsx b/src/pages/Dashboard/OrganizationsReadOnly/OrganizationsReadOnly.jsx index 24910aee..e8cc5262 100644 --- a/src/pages/Dashboard/OrganizationsReadOnly/OrganizationsReadOnly.jsx +++ b/src/pages/Dashboard/OrganizationsReadOnly/OrganizationsReadOnly.jsx @@ -575,6 +575,11 @@ function OrganizationsReadOnly() { openingHours={locationPlace?.openingHours} calendarContentLanguage={calendarContentLanguage} bordered + onClickHandle={{ + navigationFlag: true, + entityType: locationPlace?.type ?? taxonomyClass.PLACE, + entityId: locationPlace?.value, + }} /> )} @@ -626,6 +631,11 @@ function OrganizationsReadOnly() { calendarContentLanguage={calendarContentLanguage} bordered itemWidth="100%" + onClickHandle={{ + navigationFlag: true, + entityType: place?.type ?? taxonomyClass.PLACE, + entityId: place?._id, + }} />; })} @@ -652,6 +662,11 @@ function OrganizationsReadOnly() { icon={} calendarContentLanguage={calendarContentLanguage} bordered + onClickHandle={{ + navigationFlag: true, + entityType: person?.type ?? taxonomyClass.PERSON, + entityId: person?._id, + }} itemWidth="100%" />; })} @@ -681,6 +696,11 @@ function OrganizationsReadOnly() { description={moment(event.startDateTime).format('YYYY-MM-DD')} calendarContentLanguage={calendarContentLanguage} bordered + onClickHandle={{ + navigationFlag: true, + entityType: event?.type ?? taxonomyClass.EVENT, + entityId: event?._id, + }} itemWidth="100%" /> ); diff --git a/src/pages/Dashboard/PersonReadOnly/PersonReadOnly.jsx b/src/pages/Dashboard/PersonReadOnly/PersonReadOnly.jsx index ba9f1cfb..490dc854 100644 --- a/src/pages/Dashboard/PersonReadOnly/PersonReadOnly.jsx +++ b/src/pages/Dashboard/PersonReadOnly/PersonReadOnly.jsx @@ -531,6 +531,11 @@ function PersonReadOnly() { icon={} calendarContentLanguage={calendarContentLanguage} bordered + onClickHandle={{ + navigationFlag: true, + entityType: place?.type ?? taxonomyClass.PLACE, + entityId: place?._id, + }} itemWidth="100%" />; })} @@ -565,6 +570,11 @@ function PersonReadOnly() { data-cy="organization-logo" /> } + onClickHandle={{ + navigationFlag: true, + entityType: org?.type ?? taxonomyClass.ORGANIZATION, + entityId: org?._id, + }} calendarContentLanguage={calendarContentLanguage} bordered itemWidth="100%" @@ -596,6 +606,11 @@ function PersonReadOnly() { icon={} description={moment(event.startDateTime).format('YYYY-MM-DD')} bordered + onClickHandle={{ + navigationFlag: true, + entityType: event?.type ?? taxonomyClass.EVENT, + entityId: event?._id, + }} calendarContentLanguage={calendarContentLanguage} itemWidth="100%" /> diff --git a/src/pages/Dashboard/PlaceReadOnly/PlaceReadOnly.jsx b/src/pages/Dashboard/PlaceReadOnly/PlaceReadOnly.jsx index ff71ed7b..8e37aa93 100644 --- a/src/pages/Dashboard/PlaceReadOnly/PlaceReadOnly.jsx +++ b/src/pages/Dashboard/PlaceReadOnly/PlaceReadOnly.jsx @@ -801,6 +801,11 @@ function PlaceReadOnly() { calendarContentLanguage={calendarContentLanguage} bordered itemWidth="423px" + onClickHandle={{ + navigationFlag: true, + entityType: containsPlace?.type ?? taxonomyClass.PLACE, + entityId: containsPlace?.key, + }} /> ); })} @@ -833,6 +838,11 @@ function PlaceReadOnly() { itemWidth="423px" calendarContentLanguage={calendarContentLanguage} bordered + onClickHandle={{ + navigationFlag: true, + entityType: locationPlace?.type ?? taxonomyClass.PLACE, + entityId: locationPlace?.key, + }} /> ) : (

} - // description={moment(event.startDateTime).format('YYYY-MM-DD')} + onClickHandle={{ + navigationFlag: true, + entityType: place?.type ?? taxonomyClass.PLACE, + entityId: place?._id, + }} calendarContentLanguage={calendarContentLanguage} bordered itemWidth="100%" @@ -907,6 +921,11 @@ function PlaceReadOnly() { data-cy="organization-logo" /> } + onClickHandle={{ + navigationFlag: true, + entityType: org?.type ?? taxonomyClass.ORGANIZATION, + entityId: org?._id, + }} calendarContentLanguage={calendarContentLanguage} bordered itemWidth="100%" @@ -937,6 +956,11 @@ function PlaceReadOnly() { calendarContentLanguage={calendarContentLanguage} icon={} bordered + onClickHandle={{ + navigationFlag: true, + entityType: person?.type ?? taxonomyClass.PERSON, + entityId: person?._id, + }} itemWidth="100%" />; })} @@ -965,6 +989,11 @@ function PlaceReadOnly() { icon={} description={moment(event.startDateTime).format('YYYY-MM-DD')} calendarContentLanguage={calendarContentLanguage} + onClickHandle={{ + navigationFlag: true, + entityType: event?.type ?? taxonomyClass.EVENT, + entityId: event?._id, + }} bordered itemWidth="100%" /> diff --git a/src/utils/bilingual.js b/src/utils/bilingual.js index 9c4123ac..8c593c7c 100644 --- a/src/utils/bilingual.js +++ b/src/utils/bilingual.js @@ -1,5 +1,6 @@ //Function which returns the language key depending on the interface language +import i18next from 'i18next'; import { contentLanguage, contentLanguageKeyMap } from '../constants/contentLanguage'; import { userLanguages } from '../constants/userLanguages'; @@ -39,14 +40,25 @@ export const contentLanguageBilingual = ({ calendarContentLanguage, data, requir **/ if (!data) return ''; + if (requiredLanguageKey && data[requiredLanguageKey]) { return data[requiredLanguageKey]; } + const interfaceLanguage = i18next.language; + + const isInterfaceLanguageDataAvailable = calendarContentLanguage.some( + (lang) => contentLanguageKeyMap[lang] === interfaceLanguage && data[interfaceLanguage], + ); + + if (isInterfaceLanguageDataAvailable) { + return data[interfaceLanguage]; + } + let contentLanguageKey = contentLanguageKeyMap[calendarContentLanguage[0]]; - if (data[contentLanguageKey] === undefined) { + if (!data[contentLanguageKey]) { contentLanguageKey = - Object.values(contentLanguageKeyMap).find((key) => data[key] !== undefined) || Object.keys(data)[0]; // Fallback to the first key in data + Object.values(contentLanguageKeyMap).find((key) => data[key] !== undefined) || Object.keys(data)[0]; } return data[contentLanguageKey] ?? '';