Skip to content

Commit

Permalink
feat: add CRUD for banking account types
Browse files Browse the repository at this point in the history
  • Loading branch information
alisher-epam committed Oct 18, 2023
1 parent cdcf2cf commit 4ca7e50
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/Settings/AccountTypeSettings/index.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { stripesShape } from '@folio/stripes/core';
import { ControlledVocab } from '@folio/stripes/smart-components';
import { getControlledVocabTranslations } from '@folio/stripes-acq-components';

class AccountTypeSettings extends Component {
class BankingAccountTypeSettings extends Component {
constructor(props) {
super(props);
this.connectedControlledVocab = props.stripes.connect(ControlledVocab);
Expand All @@ -26,29 +26,44 @@ class AccountTypeSettings extends Component {

const ConnectedComponent = this.connectedControlledVocab;

const setUniqValidation = (value, index, items) => {
const errors = {};

const isAccountTypeExist = items.some(({ id, name }) => {
return name?.toLowerCase() === value?.name?.toLowerCase() && id !== value?.id;
});

if (isAccountTypeExist) {
errors.name = <FormattedMessage id="ui-organizations.settings.accountTypes.save.error.accountTypeMustBeUnique" />;
}

return errors;
};

return (
<ConnectedComponent
actionSuppressor={actionSuppressor}
canCreate={hasEditPerms}
stripes={stripes}
baseUrl="organizations-storage/categories"
records="categories"
baseUrl="organizations-storage/banking-account-types"
records="bankingAccountTypes"
label={<FormattedMessage id="ui-organizations.settings.accountTypes" />}
translations={getControlledVocabTranslations('ui-organizations.settings.accountTypes')}
objectLabel="Categories"
visibleFields={['value']}
objectLabel="BankingAccountTypes"
visibleFields={['name']}
columnMapping={columnMapping}
hiddenFields={['lastUpdated', 'numberOfObjects']}
nameKey="categories"
id="categories"
sortby="value"
nameKey="bankingAccountTypes"
id="bankingAccountTypes"
validate={setUniqValidation}
sortby="name"
/>
);
}
}

AccountTypeSettings.propTypes = {
BankingAccountTypeSettings.propTypes = {
stripes: stripesShape.isRequired,
};

export default AccountTypeSettings;
export default BankingAccountTypeSettings;
1 change: 1 addition & 0 deletions src/Settings/BankingAccountTypeSettings/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as BankingAccountTypeSettings } from './BankingAccountTypeSettings';
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Field, Form } from 'react-final-form';

import {
Button,
Checkbox,
Col,
Headline,
Pane,
Expand Down
4 changes: 2 additions & 2 deletions src/Settings/SettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Settings } from '@folio/stripes/smart-components';
import { CategorySettings } from './CategorySettings';
import { TypeSettings } from './TypeSettings';
import { BankingInformationSettings } from './BankingInformationSettings';
import { AccountTypeSettings } from './AccountTypeSettings';
import { BankingAccountTypeSettings } from './BankingAccountTypeSettings';

const pages = [
{
Expand All @@ -28,7 +28,7 @@ const pages = [
route: 'banking-information',
},
{
component: AccountTypeSettings,
component: BankingAccountTypeSettings,
label: <FormattedMessage id="ui-organizations.settings.accountTypes" />,
perm: 'settings.organizations.enabled',
route: 'account-types',
Expand Down
5 changes: 3 additions & 2 deletions translations/ui-organizations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,10 @@
"settings.typeStatus.Active": "Active",
"settings.typeStatus.Inactive": "Inactive",
"settings.bankingInformation": "Banking information",
"settings.bankingInformation.enabled": "Enabled",
"settings.bankingInformation.disabled": "Disabled",
"settings.bankingInformation.enabled": "Enable",
"settings.bankingInformation.disabled": "Disable",
"settings.accountTypes": "Account types",
"settings.accountTypes.save.error.accountTypeMustBeUnique": "Account type must be uniq",

"permission.view": "Organizations: View",
"permission.edit": "Organizations: View, edit",
Expand Down

0 comments on commit 4ca7e50

Please sign in to comment.