Skip to content

Commit

Permalink
Merge pull request #441 from culturecreates/feature/issue-420
Browse files Browse the repository at this point in the history
Feature/issue 420
  • Loading branch information
AbhishekPAnil authored Jul 19, 2023
2 parents e964aaa + 1f14d04 commit 30cdaf6
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 10 deletions.
7 changes: 5 additions & 2 deletions src/components/Card/Common/Event.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import { Row, Col } from 'antd';
function Event(props) {
const { title, required, hidden } = props;
return (
<Col flex={'780px'} className="add-event-section-col" style={{ display: hidden && 'none' }}>
<Col
flex={'780px'}
className="add-event-section-col"
style={{ display: hidden && 'none', borderRadius: '4px', backgroundColor: '#ffffff' }}>
<Row gutter={{ xs: 8, sm: 16, md: 24, lg: 32 }} className="events-content">
<Col flex={'423px'}>
<div className="add-event-section-wrapper">
<div className="add-event-section-wrapper" style={{ padding: '24px' }}>
{title && (
<Row>
<Col>
Expand Down
127 changes: 124 additions & 3 deletions src/pages/Dashboard/PlaceReadOnly/PlaceReadOnly.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useRef } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import Card from '../../../components/Card/Common/Event';
import { useTranslation } from 'react-i18next';
import { Breadcrumb, Col, Row } from 'antd';
Expand All @@ -9,7 +9,7 @@ import { bilingual, contentLanguageBilingual } from '../../../utils/bilingual';
import { useSelector } from 'react-redux';
import { getUserDetails } from '../../../redux/reducer/userSlice';
import { taxonomyClass } from '../../../constants/taxonomyClass';
import { useGetAllTaxonomyQuery } from '../../../services/taxonomy';
import { useGetAllTaxonomyQuery, useLazyGetAllTaxonomyQuery } from '../../../services/taxonomy';
import {
treeDynamicTaxonomyOptions,
treeTaxonomyOptions,
Expand All @@ -18,9 +18,11 @@ import Tags from '../../../components/Tags/Common/Tags';
import TreeSelectOption from '../../../components/TreeSelectOption/TreeSelectOption';
import FeatureFlag from '../../../layout/FeatureFlag/FeatureFlag';
import { featureFlags } from '../../../utils/featureFlags';
import { useGetPlaceQuery } from '../../../services/places';
import { useGetPlaceQuery, useLazyGetPlaceQuery } from '../../../services/places';
import ArtsDataLink from '../../../components/Tags/ArtsDataLink/ArtsDataLink';
import { taxonomyDetails } from '../../../utils/taxonomyDetails';
import SelectionItem from '../../../components/List/SelectionItem/SelectionItem';
import { placesOptions } from '../../../components/Select/selectOption.settings';

function PlaceReadOnly() {
const { t } = useTranslation();
Expand All @@ -42,15 +44,64 @@ function PlaceReadOnly() {
includeConcepts: true,
sessionId: timestampRef,
});
const [getPlace] = useLazyGetPlaceQuery();
const [getAllTaxonomy] = useLazyGetAllTaxonomyQuery();

const { user } = useSelector(getUserDetails);

const [locationPlace, setLocationPlace] = useState();

const calendarContentLanguage = currentCalendarData?.contentLanguage;

useEffect(() => {
if (placeError) navigate(`${PathName.NotFound}`);
}, [placeError]);

useEffect(() => {
if (placeSuccess) {
if (placeData?.containedInPlace?.entityId) {
let initialPlace = [];
let initialPlaceAccessibiltiy = [];
getPlace({ placeId: placeData?.containedInPlace?.entityId, calendarId })
.unwrap()
.then((response) => {
console.log(response);
initialPlace = [response];
initialPlace[0] = {
...initialPlace[0],
['openingHours']: initialPlace[0]?.openingHours?.uri,
};
getAllTaxonomy({
calendarId,
search: '',
taxonomyClass: taxonomyClass.PLACE,
includeConcepts: true,
})
.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[0] = {
...initialPlace[0],
['accessibility']: initialPlaceAccessibiltiy,
};
setLocationPlace(placesOptions(initialPlace, user, calendarContentLanguage)[0]);
})
.catch((error) => console.log(error));
});
}
}
}, [placeSuccess]);

return (
placeSuccess &&
!placeLoading &&
Expand Down Expand Up @@ -269,6 +320,46 @@ function PlaceReadOnly() {
)}
</Col>
)}
{(placeData?.name?.fr || placeData?.name?.en) && (
<Col span={24}>
<p className="read-only-event-content-sub-title-primary">
{t('dashboard.places.readOnly.placeName')}
</p>
{placeData?.name?.fr && (
<>
<p className="read-only-event-content-sub-title-secondary">{t('common.tabFrench')}</p>
<p className="read-only-event-content">{placeData?.name?.fr}</p>
</>
)}
{placeData?.name?.en && (
<>
<p className="read-only-event-content-sub-title-secondary">{t('common.tabEnglish')}</p>
<p className="read-only-event-content">{placeData?.name?.en}</p>
</>
)}
</Col>
)}
{placeData?.regions?.length > 0 && (
<div>
<p className="read-only-event-content-sub-title-primary">
{taxonomyDetails(allTaxonomyData?.data, user, 'Region', 'name', false)}
</p>
<TreeSelectOption
style={{ marginBottom: '1rem' }}
bordered={false}
open={false}
disabled
treeData={treeTaxonomyOptions(allTaxonomyData, user, 'Region', false, calendarContentLanguage)}
defaultValue={placeData?.regions?.map((type) => {
return type?.entityId;
})}
tagRender={(props) => {
const { label } = props;
return <Tags>{label}</Tags>;
}}
/>
</div>
)}
{(placeData?.address?.addressLocality?.en || placeData?.address?.addressLocality?.fr) && (
<Col span={24}>
<p className="read-only-event-content-sub-title-primary">
Expand Down Expand Up @@ -407,6 +498,36 @@ function PlaceReadOnly() {
<Col></Col>
</Card>
)}
<Card>
<Col>
<Row gutter={[0, 24]}>
<Col span={24}>
<p className="read-only-event-content" style={{ fontSize: '24px' }}>
{t('dashboard.places.readOnly.containedInPlace')}
</p>

<Col span={24}>
{placeData?.containedInPlace?.entityId && locationPlace ? (
<SelectionItem
icon={locationPlace?.label?.props?.icon}
name={locationPlace?.name}
description={locationPlace?.description}
itemWidth="423px"
postalAddress={locationPlace?.postalAddress}
accessibility={locationPlace?.accessibility}
openingHours={locationPlace?.openingHours}
calendarContentLanguage={calendarContentLanguage}
bordered
/>
) : (
t('dashboard.places.readOnly.notContainedInPlace')
)}
</Col>
</Col>
</Row>
</Col>
<Col></Col>
</Card>
</Row>
</FeatureFlag>
)
Expand Down
6 changes: 3 additions & 3 deletions src/services/organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const organizationApi = createApi({
endpoints: (builder) => ({
addOrganization: builder.mutation({
query: ({ data, calendarId }) => ({
url: 'organizations',
url: `organizations`,
method: 'POST',
headers: {
'calendar-id': calendarId,
Expand All @@ -26,8 +26,8 @@ export const organizationApi = createApi({
}),
}),
getAllOrganization: builder.query({
query: ({ calendarId, sort }) => ({
url: `organizations?${sort}`,
query: ({ calendarId }) => ({
url: `organizations?page=${1}&limit=${100}`,
method: 'GET',
headers: {
'calendar-id': calendarId,
Expand Down
2 changes: 1 addition & 1 deletion src/services/people.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const peopleApi = createApi({
endpoints: (builder) => ({
getAllPeople: builder.query({
query: ({ calendarId }) => ({
url: `people`,
url: `people?page=${1}&limit=${100}`,
method: 'GET',
headers: {
'calendar-id': calendarId,
Expand Down
2 changes: 1 addition & 1 deletion src/services/places.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const placesApi = createApi({
endpoints: (builder) => ({
getAllPlaces: builder.query({
query: ({ calendarId }) => ({
url: `places?excludeContainsPlace=true`,
url: `places?excludeContainsPlace=true&page=${1}&limit=${100}`,
method: 'GET',
headers: {
'calendar-id': calendarId,
Expand Down

0 comments on commit 30cdaf6

Please sign in to comment.