Skip to content

Commit

Permalink
UIU-1968: Show default fee/fine types
Browse files Browse the repository at this point in the history
  • Loading branch information
annamelnyk authored and zburke committed Nov 17, 2020
1 parent 19887a9 commit 501342c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change history for ui-users

## 5.0.6

* New Fee/Fine page not listing Fee/Fine Types for selected Fee/Fine Owner. Refs UIU-1968.

## [5.0.5](https://github.com/folio-org/ui-users/tree/v5.0.5) (2020-11-13)
[Full Changelog](https://github.com/folio-org/ui-users/compare/v5.0.4...v5.0.5)

Expand Down
4 changes: 3 additions & 1 deletion src/components/Accounts/ChargeFeeFine/ChargeFeeFine.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ class ChargeFeeFine extends React.Component {
if (owner !== undefined) { list.push(owner); }
}
});
const feefines = (this.state.ownerId !== '0') ? (resources.feefines || {}).records || [] : [];
const feefines = _.get(resources, ['allfeefines', 'records'], []);
const payments = _.get(resources, ['payments', 'records'], []).filter(p => p.ownerId === this.state.ownerId);
const accounts = _.get(resources, ['accounts', 'records'], []);
const settings = _.get(resources, ['commentRequired', 'records', 0], {});
Expand Down Expand Up @@ -462,6 +462,7 @@ class ChargeFeeFine extends React.Component {
const servicePointOwnerId = loadServicePoints({ owners: (shared ? owners : list), defaultServicePointId, servicePointsIds });
const initialOwnerId = ownerId !== '0' ? ownerId : servicePointOwnerId;
const selectedFeeFine = feefines.find(f => f.id === feeFineTypeId);
const currentOwnerFeeFineTypes = feefines.filter(f => f.ownerId === resources.activeRecord.ownerId);
const selectedOwner = owners.find(o => o.id === initialOwnerId);
const initialChargeValues = {
ownerId: resources.activeRecord.ownerId || '',
Expand All @@ -482,6 +483,7 @@ class ChargeFeeFine extends React.Component {
form="feeFineChargeForm"
initialValues={initialChargeValues}
defaultServicePointId={defaultServicePointId}
feeFineTypeOptions={currentOwnerFeeFineTypes}
servicePointsIds={servicePointsIds}
onSubmit={this.onSubmitCharge}
user={user}
Expand Down
9 changes: 5 additions & 4 deletions src/components/Accounts/ChargeFeeFine/ChargeForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class ChargeForm extends React.Component {
history: PropTypes.object,
initialValues: PropTypes.object,
match: PropTypes.object,
feeFineTypeOptions: PropTypes.arrayOf(PropTypes.object).isRequired,
}

constructor(props) {
Expand All @@ -97,15 +98,15 @@ class ChargeForm extends React.Component {
}
}

onChangeFeeFine(e) {
async onChangeFeeFine(e) {
const {
feefines,
form: { change },
} = this.props;

if (e?.target?.value) {
const feeFineId = e.target.value;
this.props.onChangeFeeFine(e);
await this.props.onChangeFeeFine(e);
const feefine = feefines.find(f => f.id === feeFineId) || {};
change('feeFineId', feefine.id);
this.amount = feefine.defaultAmount || 0;
Expand Down Expand Up @@ -142,6 +143,7 @@ class ChargeForm extends React.Component {
onSubmit,
handleSubmit,
initialValues,
feeFineTypeOptions,
form,
form : {
getState,
Expand Down Expand Up @@ -180,7 +182,7 @@ class ChargeForm extends React.Component {
if (own.owner !== 'Shared') ownerOptions.push({ label: own.owner, value: own.id });
});

this.props.feefines.forEach((feefineItem) => {
feeFineTypeOptions.forEach((feefineItem) => {
const fee = {};
fee.label = feefineItem.feeFineType;
fee.value = feefineItem.id;
Expand Down Expand Up @@ -252,7 +254,6 @@ class ChargeForm extends React.Component {
isPending={isPending}
onChangeOwner={this.onChangeOwner}
onChangeFeeFine={this.onChangeFeeFine}
feefines={this.props.feefines}
feefineList={feefineList}
/>
<br />
Expand Down
1 change: 0 additions & 1 deletion src/components/Accounts/ChargeFeeFine/FeeFineInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class FeeFineInfo extends React.Component {
onChangeOwner: PropTypes.func,
ownerOptions: PropTypes.arrayOf(PropTypes.object),
onChangeFeeFine: PropTypes.func,
feefines: PropTypes.arrayOf(PropTypes.object),
isPending: PropTypes.object,
};

Expand Down

0 comments on commit 501342c

Please sign in to comment.