Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #1291

Merged
merged 5 commits into from
Aug 28, 2024
Merged

Develop #1291

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/components/Dropdown/Calendar/Calendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import { PathName } from '../../../constants/pathName';
import { contentLanguageBilingual } from '../../../utils/bilingual';
import { useSelector } from 'react-redux';
import { getUserDetails } from '../../../redux/reducer/userSlice';
import Cookies from 'js-cookie';

function Calendar({ children, allCalendarsData, setPageNumber }) {
const dispatch = useDispatch();
const { user } = useSelector(getUserDetails);
const calendarIdInCookies = Cookies.get('calendarId');
const calendarIdInCookies = sessionStorage.getItem('calendarId');

const [open, setOpen] = useState(false);
const items = allCalendarsData?.data?.map((item) => {
Expand Down Expand Up @@ -47,7 +46,7 @@ function Calendar({ children, allCalendarsData, setPageNumber }) {
const onClick = ({ key }) => {
if (calendarIdInCookies != key) {
dispatch(setSelectedCalendar(String(key)));
Cookies.set('calendarId', key);
sessionStorage.setItem('calendarId', key);
setPageNumber(1);
sessionStorage.clear();
setOpen(false);
Expand Down
10 changes: 5 additions & 5 deletions src/pages/Dashboard/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ function Dashboard() {
useEffect(() => {
const accessTokenFromCookie = Cookies.get('accessToken');
const refreshTokenFromCookie = Cookies.get('refreshToken');
const calendarIdFromCookie = Cookies.get('calendarId');
const calendarIdFromCookie = sessionStorage.getItem('calendarId');

const calId = calendarId || calendarIdFromCookie;
if (calendarId) Cookies.set('calendarId', calId);
if (calendarId) sessionStorage.setItem('calendarId', calId);

if (!checkToken(accessToken, accessTokenFromCookie)) navigate(PathName.Login);

Expand Down Expand Up @@ -111,7 +111,7 @@ function Dashboard() {

const checkedCalendarId = findActiveCalendar();
if (checkedCalendarId != null) {
Cookies.set('calendarId', checkedCalendarId);
sessionStorage.setItem('calendarId', checkedCalendarId);
}

if (calendarId && accessToken) {
Expand All @@ -130,12 +130,12 @@ function Dashboard() {
});
dispatch(setSelectedCalendar(String(calendarId)));
} else {
let activeCalendarId = Cookies.get('calendarId');
let activeCalendarId = sessionStorage.getItem('calendarId');
if (activeCalendarId && accessToken) {
navigate(`${PathName.Dashboard}/${activeCalendarId}${PathName.Events}`);
} else if (!isLoading && allCalendarsData?.data) {
activeCalendarId = allCalendarsData?.data[0]?.id;
Cookies.set('calendarId', activeCalendarId);
sessionStorage.setItem('calendarId', activeCalendarId);
navigate(`${PathName.Dashboard}/${activeCalendarId}${PathName.Events}`);
}
}
Expand Down
12 changes: 11 additions & 1 deletion src/pages/Dashboard/EventReadOnly/EventReadOnly.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function EventReadOnly() {
['openingHours']: initialPlace[0]?.openingHours?.uri,
};
let initialPlaceAccessibiltiy = [];
if (initialPlace[0]?.accessibility?.length > 0) {
if (initialPlace[0]?.accessibility?.length > 0 || initialPlace[0]?.regions?.length > 0) {
let taxonomyClassQuery = new URLSearchParams();
taxonomyClassQuery.append('taxonomy-class', taxonomyClass.PLACE);
getAllTaxonomy({
Expand All @@ -182,6 +182,15 @@ function EventReadOnly() {
...initialPlace[0],
['accessibility']: initialPlaceAccessibiltiy,
};
res?.data?.map((taxonomy) => {
if (taxonomy?.mappedToField == 'Region') {
taxonomy?.concept?.forEach((t) => {
if (initialPlace[0]?.regions[0]?.entityId == t?.id) {
initialPlace[0] = { ...initialPlace[0], regions: [t] };
}
});
}
});
setLocationPlace(placesOptions(initialPlace)[0], user, calendarContentLanguage);
})
.catch((error) => console.log(error));
Expand Down Expand Up @@ -670,6 +679,7 @@ function EventReadOnly() {
icon={locationPlace?.label?.props?.icon}
name={locationPlace?.name}
description={locationPlace?.description}
region={locationPlace?.region}
itemWidth="100%"
postalAddress={locationPlace?.postalAddress}
accessibility={locationPlace?.accessibility}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const Login = () => {
};
useEffect(() => {
const savedAccessToken = Cookies.get('accessToken');
const calenderId = Cookies.get('calendarId');
const calenderId = sessionStorage.getItem('calendarId');
if (location?.state?.previousPath === 'logout') {
dispatch(clearUser());
}
Expand All @@ -50,7 +50,7 @@ const Login = () => {
}, []);

useEffect(() => {
const calenderId = Cookies.get('calendarId');
const calenderId = sessionStorage.getItem('calendarId');
if (accessToken && accessToken != '' && calenderId && calenderId != '') {
navigate(PathName.Dashboard, { state: { previousPath: 'login' } });
}
Expand Down
16 changes: 10 additions & 6 deletions src/utils/clearSessionStoredSearchQueries.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
export const clearSessionStoredSearchQueries = () => {
sessionStorage.removeItem('query');
sessionStorage.removeItem('queryTaxonomy');
sessionStorage.removeItem('peopleSearchQuery');
sessionStorage.removeItem('organizationSearchQuery');
sessionStorage.removeItem('placesSearchQuery');
sessionStorage.removeItem('queryUserListing');
[
'query',
'queryTaxonomy',
'peopleSearchQuery',
'organizationSearchQuery',
'placesSearchQuery',
'queryUserListing',
].forEach((key) => {
sessionStorage.removeItem(key);
});
};
Loading