Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
vashjs committed Aug 5, 2024
1 parent 59dca29 commit dfa4aa1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,23 @@ const LocationFormContainer = ({

const callout = useContext(CalloutContext);

function showSubmitErrorCallout(error) {
const showSubmitErrorCallout = (error) => {
callout.sendCallout({
type: 'error',
message: error.message || error.statusText || <FormattedMessage id="ui-tenant-settings.settings.save.error.network" />,
});
}
};

const { setMapping } = useRemoteStorageApi();

const { createLocation } = useLocationCreate({
const sharedOptions = {
onSuccess: () => {
queryClient.invalidateQueries(SERVICE_POINTS);
queryClient.invalidateQueries(LOCATIONS);
},
});
};

const { updateLocation } = useLocationUpdate({
onSuccess: () => {
queryClient.invalidateQueries(SERVICE_POINTS);
queryClient.invalidateQueries(LOCATIONS);
},
});
const { createLocation } = useLocationCreate(sharedOptions);
const { updateLocation } = useLocationUpdate(sharedOptions);

const initiateSetMapping = (...args) => setMapping(...args).catch(showSubmitErrorCallout);

Expand Down
15 changes: 12 additions & 3 deletions src/settings/Plugins/Plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useRef } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage, useIntl } from 'react-intl';
import { map, omit } from 'lodash';
import { useQueryClient } from 'react-query';

import { modules } from 'stripes-config'; // eslint-disable-line import/no-unresolved, import/no-extraneous-dependencies
import {
Expand All @@ -13,12 +14,13 @@ import { TitleManager, useStripes } from '@folio/stripes/core';
import PluginForm from './PluginForm';
import { useConfigurationsCreate } from '../../hooks/useConfigurationsCreate';
import { useConfigurationsUpdate } from '../../hooks/useConfigurationsUpdate';
import { useConfigurations } from '../../hooks/useConfigurations';
import { CONFIGURATIONS, useConfigurations } from '../../hooks/useConfigurations';


const Plugins = ({ label }) => {
const intl = useIntl();
const stripes = useStripes();
const queryClient = useQueryClient();
const callout = useRef(null);

const { configs } = useConfigurations({
Expand All @@ -27,8 +29,15 @@ const Plugins = ({ label }) => {
limit: '1000',
},
});
const { createConfiguration } = useConfigurationsCreate();
const { updateConfiguration } = useConfigurationsUpdate();

const sharedOptions = {
onSuccess: () => {
queryClient.invalidateQueries(CONFIGURATIONS);
},
};

const { createConfiguration } = useConfigurationsCreate(sharedOptions);
const { updateConfiguration } = useConfigurationsUpdate(sharedOptions);

const pluginTypes = (() => {
const plugins = modules.plugin || [];
Expand Down
6 changes: 3 additions & 3 deletions src/settings/ServicePoints/LocationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ import {
const LocationList = ({ locations, expanded, servicePoint, onToggle }) => {
const intl = useIntl();

const renderLocation = (location) => {
const renderLocation = (location, index) => {
if (!location) return (<div />);

const { name, code, primaryServicePoint } = location;
const primary = (primaryServicePoint === servicePoint.id)
? intl.formatMessage({ id: 'ui-tenant-settings.settings.servicePoints.primary' }) :
'';
const title = `${name} - ${code} ${primary}`;
return (<li key={title}>{title}</li>);
return (<li key={index}>{title}</li>);
};

const renderLocations = () => {
return (
<List
items={locations}
itemFormatter={location => renderLocation(location)}
itemFormatter={renderLocation}
isEmptyMessage={<FormattedMessage id="ui-tenant-settings.settings.servicePoints.noLocationsFound" />}
/>
);
Expand Down
3 changes: 2 additions & 1 deletion src/settings/ServicePoints/ServicePointForm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, {
useCallback,
useMemo,
useState,
} from 'react';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -75,7 +76,7 @@ const ServicePointForm = ({
const [isConfirmPickupLocationChangeModal, setIsConfirmPickupLocationChangeModal] = useState(false);
const stripes = useStripes();
const intl = useIntl();
const CViewMetaData = stripes.connect(ViewMetaData);
const CViewMetaData = useMemo(() => stripes.connect(ViewMetaData), []);

Check warning on line 79 in src/settings/ServicePoints/ServicePointForm.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

React Hook useMemo has a missing dependency: 'stripes'. Either include it or remove the dependency array

Check warning on line 79 in src/settings/ServicePoints/ServicePointForm.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

React Hook useMemo has a missing dependency: 'stripes'. Either include it or remove the dependency array

const servicePoint = initialValues || {};
const locations = servicePoint.id
Expand Down

0 comments on commit dfa4aa1

Please sign in to comment.