Skip to content

Commit

Permalink
Merge pull request #615 from culturecreates/feature/issue-471
Browse files Browse the repository at this point in the history
Feature/issue 471
  • Loading branch information
AbhishekPAnil authored Sep 25, 2023
2 parents d52b395 + 762c94e commit 53cf96c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 10 deletions.
15 changes: 6 additions & 9 deletions src/constants/formFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { contentLanguage } from './contentLanguage';
import ContentLanguageInput from '../components/ContentLanguageInput/ContentLanguageInput';
import BilingualInput from '../components/BilingualInput/BilingualInput';
import ImageUpload from '../components/ImageUpload/ImageUpload';
import { contentLanguageBilingual } from '../utils/bilingual';
import { bilingual, contentLanguageBilingual } from '../utils/bilingual';
import { Translation } from 'react-i18next';
import StyledInput from '../components/Input/Common';
import { formInitialValueHandler } from '../utils/formInitialValueHandler';
Expand Down Expand Up @@ -447,17 +447,15 @@ export const returnFormDataWithFields = ({
calendarContentLanguage,
name: [field?.mappedField],
preview: true,
placeholder: contentLanguageBilingual({
placeholder: bilingual({
en: field?.placeholder?.en,
fr: field?.placeholder?.fr,
interfaceLanguage: user?.interfaceLanguage?.toLowerCase(),
calendarContentLanguage: calendarContentLanguage,
}),
validations: contentLanguageBilingual({
validations: bilingual({
en: field?.validations?.en,
fr: field?.validations?.fr,
interfaceLanguage: user?.interfaceLanguage?.toLowerCase(),
calendarContentLanguage: calendarContentLanguage,
}),
largeUrl:
field?.mappedField === mappedFieldTypes.IMAGE
Expand All @@ -469,7 +467,7 @@ export const returnFormDataWithFields = ({
: field?.mappedField === mappedFieldTypes.LOGO && entityData?.logo?.original?.uri,
required: field?.isRequiredField,
t: t,
userTips: contentLanguageBilingual({
userTips: bilingual({
en: field?.userTips?.text?.en,
fr: field?.userTips?.text?.fr,
interfaceLanguage: user?.interfaceLanguage?.toLowerCase(),
Expand Down Expand Up @@ -500,13 +498,12 @@ export const returnFormDataWithFields = ({
}),
key: index,
initialValue: formInitialValueHandler(field?.type, field?.mappedField, field?.datatype, entityData),
label: contentLanguageBilingual({
label: bilingual({
en: field?.label?.en,
fr: field?.label?.fr,
interfaceLanguage: user?.interfaceLanguage?.toLowerCase(),
calendarContentLanguage: calendarContentLanguage,
}),
userTips: contentLanguageBilingual({
userTips: bilingual({
en: field?.userTips?.text?.en,
fr: field?.userTips?.text?.fr,
interfaceLanguage: user?.interfaceLanguage?.toLowerCase(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
useUpdateOrganizationMutation,
} from '../../../services/organization';
import { taxonomyClass } from '../../../constants/taxonomyClass';
import { useGetAllTaxonomyQuery } from '../../../services/taxonomy';
import { useGetAllTaxonomyQuery, useLazyGetAllTaxonomyQuery } from '../../../services/taxonomy';
import TreeSelectOption from '../../../components/TreeSelectOption/TreeSelectOption';
import NoContent from '../../../components/NoContent/NoContent';
import { treeDynamicTaxonomyOptions } from '../../../components/TreeSelectOption/treeSelectOption.settings';
Expand All @@ -39,6 +39,7 @@ import { useAddImageMutation } from '../../../services/image';
import { routinghandler } from '../../../utils/roleRoutingHandler';
import ArtsDataInfo from '../../../components/ArtsDataInfo/ArtsDataInfo';
import { artsDataLinkChecker } from '../../../utils/artsDataLinkChecker';
import { useLazyGetPlaceQuery } from '../../../services/places';

function CreateNewOrganization() {
const timestampRef = useRef(Date.now()).current;
Expand Down Expand Up @@ -66,6 +67,8 @@ function CreateNewOrganization() {
includeConcepts: true,
sessionId: timestampRef,
});
const [getPlace] = useLazyGetPlaceQuery();
const [getAllTaxonomy] = useLazyGetAllTaxonomyQuery({ sessionId: timestampRef });
const [getEntities] = useLazyGetEntitiesQuery({ sessionId: timestampRef });
const [addOrganization, { isLoading: addOrganizationLoading }] = useAddOrganizationMutation();
const [updateOrganization, { isLoading: updateOrganizationLoading }] = useUpdateOrganizationMutation();
Expand Down Expand Up @@ -445,6 +448,8 @@ function CreateNewOrganization() {

useEffect(() => {
if (calendarId && organizationData && currentCalendarData) {
let initialPlaceAccessibiltiy = [],
initialPlace;
if (routinghandler(user, calendarId, organizationData?.createdByUserId, null, true)) {
if (organizationData?.image) {
form.setFieldsValue({
Expand All @@ -469,6 +474,49 @@ function CreateNewOrganization() {
},
});
}
if (organizationData?.place?.entityId) {
getPlace({ placeId: organizationData?.place?.entityId, calendarId })
.unwrap()
.then((response) => {
if (response?.accessibility?.length > 0) {
getAllTaxonomy({
calendarId,
search: '',
taxonomyClass: taxonomyClass.PLACE,
includeConcepts: true,
sessionId: timestampRef,
})
.unwrap()
.then((res) => {
res?.data?.forEach((taxonomy) => {
if (taxonomy?.mappedToField === 'PlaceAccessibility') {
response?.accessibility?.forEach((accessibility) => {
taxonomy?.concept?.forEach((concept) => {
if (concept?.id == accessibility?.entityId) {
initialPlaceAccessibiltiy = initialPlaceAccessibiltiy?.concat([concept]);
}
});
});
}
});
initialPlace = {
...response,
['accessibility']: initialPlaceAccessibiltiy,
};
setLocationPlace(placesOptions([initialPlace], user, calendarContentLanguage)[0]);
})
.catch((error) => console.log(error));
} else {
initialPlace = {
...response,
['accessibility']: [],
};
setLocationPlace(placesOptions([response], user, calendarContentLanguage)[0]);
}
})
.catch((error) => console.log(error));
form.setFieldValue('place', organizationData?.place?.entityId);
}
let organizationKeys = Object.keys(organizationData);
if (organizationKeys?.length > 0) setAddedFields(organizationKeys);
} else
Expand Down

0 comments on commit 53cf96c

Please sign in to comment.