Skip to content

Commit

Permalink
UIORGS-391: add initial routing config and components
Browse files Browse the repository at this point in the history
  • Loading branch information
alisher-epam committed Oct 11, 2023
1 parent d5d736d commit 2b8e839
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Upgrade `Node.js` to `18` version in GitHub Actions. Refs UIORGS-378.
* *BREAKING* bump `react-intl` to `v6.4.4`. Refs UIORGS-386.
* Add a message indicating future functionality for EDI naming convention. Refs UIORGS-382.
* Settings for banking information. Refs UIORGS-391.

## [4.0.0](https://github.com/folio-org/ui-organizations/tree/v4.0.0) (2023-02-22)
[Full Changelog](https://github.com/folio-org/ui-organizations/compare/v3.3.1...v4.0.0)
Expand Down
54 changes: 54 additions & 0 deletions src/Settings/AccountTypeSettings/AccountTypeSettings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React, { Component } from 'react';
import { FormattedMessage } from 'react-intl';

import { stripesShape } from '@folio/stripes/core';
import { ControlledVocab } from '@folio/stripes/smart-components';
import { getControlledVocabTranslations } from '@folio/stripes-acq-components';

class AccountTypeSettings extends Component {
constructor(props) {
super(props);
this.connectedControlledVocab = props.stripes.connect(ControlledVocab);
}

render() {
const { stripes } = this.props;
const columnMapping = {
value: <FormattedMessage id="ui-organizations.settings.name" />,
action: <FormattedMessage id="ui-organizations.settings.action" />,
};

const hasEditPerms = stripes.hasPerm('ui-organizations.settings');
const actionSuppressor = {
edit: () => !hasEditPerms,
delete: () => !hasEditPerms,
};

const ConnectedComponent = this.connectedControlledVocab;

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

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

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

import {
Button,
Checkbox,

Check warning on line 6 in src/Settings/BankingInformationSettings/BankingInformationSettings.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

'Checkbox' is defined but never used. Allowed unused vars must match /React/u
Col,
Headline,
Pane,
RadioButton,
RadioButtonGroup,
Row,
} from '@folio/stripes/components';

const BankingInformationSettings = () => {
const onSubmit = (values) => {
console.log(values);

Check warning on line 17 in src/Settings/BankingInformationSettings/BankingInformationSettings.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

Unexpected console statement
};

return (
<Pane
defaultWidth="fill"
dismissible
id="banking-information"
paneTitle={<FormattedMessage id="ui-organizations.settings.bankingInformation" />}
>
<Row>
<Col xs={12}>
<Headline margin="none">
<FormattedMessage id="ui-organizations.settings.bankingInformation" />
</Headline>
</Col>
<Col xs={12}>
<Form
onSubmit={onSubmit}
initialValues={{ enabled: false }}
render={({ handleSubmit }) => (
<form onSubmit={handleSubmit}>
<Field
name="enabled"
component={RadioButtonGroup}
>
<RadioButton
label={<FormattedMessage id="ui-organizations.settings.bankingInformation.enabled" />}
id="enabled"
value="true"
/>
<RadioButton
label={<FormattedMessage id="ui-organizations.settings.bankingInformation.disabled" />}
id="disabled"
value="false"
/>
</Field>
<Button type="submit" buttonStyle="primary">Save</Button>
</form>
)}
/>
</Col>
</Row>
</Pane>
);
};

export default BankingInformationSettings;
4 changes: 4 additions & 0 deletions src/Settings/BankingInformationSettings/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const typeStatus = [
{ value: 'Active' },
{ value: 'Inactive' },
];
1 change: 1 addition & 0 deletions src/Settings/BankingInformationSettings/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as BankingInformationSettings } from './BankingInformationSettings';
14 changes: 14 additions & 0 deletions src/Settings/SettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Settings } from '@folio/stripes/smart-components';

import { CategorySettings } from './CategorySettings';
import { TypeSettings } from './TypeSettings';
import { BankingInformationSettings } from './BankingInformationSettings';
import { AccountTypeSettings } from './AccountTypeSettings';

const pages = [
{
Expand All @@ -19,6 +21,18 @@ const pages = [
perm: 'settings.organizations.enabled',
route: 'type',
},
{
component: BankingInformationSettings,
label: <FormattedMessage id="ui-organizations.settings.bankingInformation" />,
perm: 'settings.organizations.enabled',
route: 'banking-information',
},
{
component: AccountTypeSettings,
label: <FormattedMessage id="ui-organizations.settings.accountTypes" />,
perm: 'settings.organizations.enabled',
route: 'account-types',
},
];

const SettingsPage = (props) => (
Expand Down
5 changes: 5 additions & 0 deletions translations/ui-organizations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,11 @@
"settings.type": "Type",
"settings.typeStatus.Active": "Active",
"settings.typeStatus.Inactive": "Inactive",
"settings.bankingInformation": "Banking information",
"settings.bankingInformation.enabled": "Enabled",
"settings.bankingInformation.disabled": "Disabled",
"settings.accountTypes": "Account types",

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

0 comments on commit 2b8e839

Please sign in to comment.