Skip to content

Commit

Permalink
fix ecs
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaSedyx committed Oct 30, 2024
1 parent fd4d46d commit 3eb1e32
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import {
Loading,
Layout,
} from '@folio/stripes/components';
import { useStripes } from '@folio/stripes/core';
import {
checkIfUserInCentralTenant,
useStripes,
} from '@folio/stripes/core';

import { BulkEditInAppTitle } from './BulkEditInAppTitle/BulkEditInAppTitle';
import { ContentUpdatesForm } from './ContentUpdatesForm/ContentUpdatesForm';
Expand Down Expand Up @@ -42,10 +45,8 @@ export const BulkEditInApp = ({
onContentUpdatesChanged,
}) => {
const { title } = useContext(RootContext);
const { user, okapi } = useStripes();
const centralTenant = user?.user?.consortium?.centralTenantId;
const tenantId = okapi.tenant;
const isCentralTenant = tenantId === centralTenant;
const stripes = useStripes();
const isCentralTenant = checkIfUserInCentralTenant(stripes);

const { formatMessage } = useIntl();
const { currentRecordType } = useSearchParams();
Expand All @@ -60,8 +61,8 @@ export const BulkEditInApp = ({
const { holdingsNotes, isHoldingsNotesLoading } = useHoldingsNotes({ enabled: isHoldingsRecordType });
const { instanceNotes, isInstanceNotesLoading } = useInstanceNotes({ enabled: isInstanceRecordType });
const { data: tenants } = useBulkOperationTenants(bulkOperationId);
const { notesEsc: itemNotesEsc, isFetching: isItemsNotesEscLoading } = useItemNotesEsc(tenants, 'option', { enabled: isItemRecordType && Boolean(tenants?.length) });
const { notesEsc: holdingsNotesEsc, isFetching: isHoldingsNotesEscLoading } = useHoldingsNotesEsc(tenants, 'option', { enabled: isHoldingsRecordType && (Boolean(tenants?.length)) });
const { notesEsc: itemNotesEsc, isFetching: isItemsNotesEscLoading } = useItemNotesEsc(tenants, 'option', { enabled: isItemRecordType && isCentralTenant });
const { notesEsc: holdingsNotesEsc, isFetching: isHoldingsNotesEscLoading } = useHoldingsNotesEsc(tenants, 'option', { enabled: isHoldingsRecordType && isCentralTenant });

const options = useMemo(() => ({
[CAPABILITIES.ITEM]: getItemsOptions(formatMessage, removeDuplicatesByValue(isCentralTenant ? itemNotesEsc : itemNotes, tenants)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import React from 'react';
import { useIntl } from 'react-intl';
import PropTypes from 'prop-types';

import { useStripes } from '@folio/stripes/core';
import {
checkIfUserInCentralTenant,
useStripes,
} from '@folio/stripes/core';
import {
Datepicker,
Select,
Expand Down Expand Up @@ -61,15 +64,13 @@ import {
} from '../../../../../utils/helpers';

export const ValuesColumn = ({ action, allActions, actionIndex, onChange, option }) => {
const { user, okapi } = useStripes();
const stripes = useStripes();
const { formatMessage } = useIntl();
const {
currentRecordType,
} = useSearchParams();
const { id: bulkOperationId } = usePathParams('/bulk-edit/:id');
const centralTenant = user?.user?.consortium?.centralTenantId;
const tenantId = okapi.tenant;
const isCentralTenant = tenantId === centralTenant;
const isCentralTenant = checkIfUserInCentralTenant(stripes);

const isUserCapability = currentRecordType === CAPABILITIES.USER;
const isItemCapability = currentRecordType === CAPABILITIES.ITEM;
Expand All @@ -82,13 +83,13 @@ export const ValuesColumn = ({ action, allActions, actionIndex, onChange, option
const { itemNotes, usItemNotesLoading } = useItemNotes({ enabled: isItemCapability });
const { instanceNotes, isInstanceNotesLoading } = useInstanceNotes({ enabled: isInstanceCapability });
const { data: tenants } = useBulkOperationTenants(bulkOperationId);
const { notesEsc: itemsNotes, isFetching: isItemsNotesEscLoading } = useItemNotesEsc(tenants, 'action', { enabled: isItemCapability && Boolean(tenants?.length) });
const { notesEsc: holdingsNotesEsc, isFetching: isHoldingsNotesEscLoading } = useHoldingsNotesEsc(tenants, 'action', { enabled: isHoldingsCapability && Boolean(tenants?.length) });
const { locationsEsc, isFetching: isLocationEscLoading } = useLocationEsc(tenants, { enabled: Boolean(tenants?.length) });
const { escData: loanTypesEsc, isFetching: isLoanTypesEscLoading } = useLoanTypesEsc(tenants, { enabled: Boolean(tenants?.length) });
const { notesEsc: itemsNotes, isFetching: isItemsNotesEscLoading } = useItemNotesEsc(tenants, 'action', { enabled: isItemCapability && isCentralTenant });
const { notesEsc: holdingsNotesEsc, isFetching: isHoldingsNotesEscLoading } = useHoldingsNotesEsc(tenants, 'action', { enabled: isHoldingsCapability && isCentralTenant });
const { locationsEsc, isFetching: isLocationEscLoading } = useLocationEsc(tenants, { enabled: isCentralTenant });
const { escData: loanTypesEsc, isFetching: isLoanTypesEscLoading } = useLoanTypesEsc(tenants, { enabled: isCentralTenant });

const { electronicAccessRelationships, isElectronicAccessLoading } = useElectronicAccessRelationships({ enabled: isHoldingsCapability });
const { escData: urlRelationshipsEsc, isFetching: isElectronicAccessEscLoading } = useElectronicAccessEsc(tenants, { enabled: Boolean(tenants?.length) });
const { escData: urlRelationshipsEsc, isFetching: isElectronicAccessEscLoading } = useElectronicAccessEsc(tenants, { enabled: isCentralTenant });
// exclude from second action the first action value
const filteredElectronicAccessRelationships = electronicAccessRelationships.filter(item => actionIndex === 0 || item.value !== allActions[0]?.value);
const filteredElectronicAccessRelationshipsEsc = urlRelationshipsEsc?.filter(item => actionIndex === 0 || item.value !== allActions[0]?.value);
Expand Down

0 comments on commit 3eb1e32

Please sign in to comment.