Skip to content

Commit

Permalink
refactor: improve code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
alisher-epam committed Dec 7, 2023
1 parent 0c19860 commit 230af51
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lib/PrivilegedDonorContacts/ContactsContainer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const renderComponent = (props = {}) => (render(
</MemoryRouter>,
));

describe('DonorsContainer', () => {
describe('ContactsContainer', () => {
beforeEach(() => {
useCategories.mockClear().mockReturnValue({
donors: [],
Expand Down
49 changes: 35 additions & 14 deletions lib/PrivilegedDonorContacts/constants.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,51 @@
import { FormattedMessage } from 'react-intl';

export const PRIVILEGED_CONTACT_URL = 'privileged-contacts';

const COLUMN_NAMES = {
categories: 'categories',
email: 'email',
name: 'name',
notes: 'notes',
phone: 'phone',
status: 'status',
unassignContact: 'unassignContact',
};

const {
categories,
email,
name,
notes,
phone,
status,
unassignContact,
} = COLUMN_NAMES;

export const defaultVisibleColumns = [
'name',
'categories',
'email',
'phone',
'status',
'notes',
name,
categories,
email,
phone,
status,
notes,
];

export const defaultColumnMapping = {
categories: <FormattedMessage id="stripes-acq-components.privilegedContacts.categories" />,
email: <FormattedMessage id="stripes-acq-components.privilegedContacts.email" />,
name: <FormattedMessage id="stripes-acq-components.privilegedContacts.name" />,
notes: <FormattedMessage id="stripes-acq-components.privilegedContacts.note" />,
phone: <FormattedMessage id="stripes-acq-components.privilegedContacts.phone" />,
status: <FormattedMessage id="stripes-acq-components.privilegedContacts.status" />,
unassignContact: null,
[categories]: <FormattedMessage id="stripes-acq-components.privilegedContacts.categories" />,
[email]: <FormattedMessage id="stripes-acq-components.privilegedContacts.email" />,
[name]: <FormattedMessage id="stripes-acq-components.privilegedContacts.name" />,
[notes]: <FormattedMessage id="stripes-acq-components.privilegedContacts.note" />,
[phone]: <FormattedMessage id="stripes-acq-components.privilegedContacts.phone" />,
[status]: <FormattedMessage id="stripes-acq-components.privilegedContacts.status" />,
[unassignContact]: null,
};

export const sortableColumns = defaultVisibleColumns;

export const defaultContainerVisibleColumns = [
...defaultVisibleColumns,
'unassignContact',
unassignContact,
];

export const alignRowProps = { alignLastColToEnd: true };
2 changes: 0 additions & 2 deletions lib/PrivilegedDonorContacts/hooks/constants.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import {
useOkapiKy,
} from '@folio/stripes/core';

import { PRIVILEGED_CONTACTS_API } from '../../../constants';
import { batchRequest } from '../../../utils';
import {
DEFAULT_DATA,
PRIVILEGED_CONTACTS_API,
} from '../constants';

const DEFAULT_DATA = [];

export const useFetchPrivilegedContacts = (privilegedContactIds = DEFAULT_DATA, options = {}) => {
const ky = useOkapiKy();
Expand Down
2 changes: 2 additions & 0 deletions lib/constants/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const ACQUISITIONS_UNITS_API = 'acquisitions-units/units';
export const ACQUISITIONS_UNIT_MEMBERSHIPS_API = 'acquisitions-units/memberships';
export const BATCH_GROUPS_API = 'batch-groups';
export const BUDGETS_API = 'finance/budgets';
export const CATEGORIES_API = 'organizations-storage/categories';
export const CONFIG_API = 'configurations/entries';
export const CONTRIBUTOR_NAME_TYPES_API = 'contributor-name-types';
export const EXCHANGE_RATE_API = 'finance/exchange-rate';
Expand All @@ -19,6 +20,7 @@ export const MATERIAL_TYPE_API = 'material-types';
export const ORDERS_API = 'orders/composite-orders';
export const ORDER_PIECES_API = 'orders/pieces';
export const PREFIXES_API = 'orders/configuration/prefixes';
export const PRIVILEGED_CONTACTS_API = 'organizations-storage/privileged-contacts';
export const REQUESTS_API = 'circulation/requests';
export const SUFFIXES_API = 'orders/configuration/suffixes';
export const TAGS_API = 'tags';
Expand Down
1 change: 0 additions & 1 deletion lib/hooks/useCategories/constants.js

This file was deleted.

6 changes: 4 additions & 2 deletions lib/hooks/useCategories/useCategories.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import {
useOkapiKy,
} from '@folio/stripes/core';

import { LIMIT_MAX } from '../../constants';
import { CATEGORIES_API } from './constants';
import {
CATEGORIES_API,
LIMIT_MAX,
} from '../../constants';
import { useTranslatedCategories } from '../useTranslatedCategories';

const DEFAULT_DATA = [];
Expand Down

0 comments on commit 230af51

Please sign in to comment.