Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Add translations #38

Merged
merged 18 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/BursarExportPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import useManualSchedulerMutation from './api/mutators/useManualSchedulerMutatio
import ConfigurationForm, { FORM_ID } from './form/ConfigurationForm';
import useInitialValues from './hooks/useInitialValues';
import FormValues from './types/FormValues';
import { FormattedMessage } from 'react-intl';

export default function BursarExportPlugin() {
const stripes = useStripes();
Expand All @@ -39,7 +40,9 @@ export default function BursarExportPlugin() {
if (initialValues === null) {
return (
<LoadingPane
paneTitle="Transfer configuration"
paneTitle={
<FormattedMessage id="ui-plugin-bursar-export.bursarExports.paneTitle" />
}
defaultWidth="fill"
footer={
<PaneFooter
Expand Down Expand Up @@ -69,7 +72,7 @@ export default function BursarExportPlugin() {
formApiRef.current?.change('buttonClicked', 'manual')
}
>
Run manually
<FormattedMessage id="ui-plugin-bursar-export.bursarExports.button.runManually" />
</Button>
}
renderEnd={
Expand All @@ -82,13 +85,15 @@ export default function BursarExportPlugin() {
formApiRef.current?.change('buttonClicked', 'save')
}
>
Save
<FormattedMessage id="ui-plugin-bursar-export.bursarExports.button.save" />
</Button>
}
/>
}
id="pane-batch-group-configuration"
paneTitle="Transfer configuration"
paneTitle={
<FormattedMessage id="ui-plugin-bursar-export.bursarExports.paneTitle" />
}
>
<ConfigurationForm
initialValues={initialValues}
Expand Down
57 changes: 41 additions & 16 deletions src/components/AggregateCriteria/AggregateCriteriaCard.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Card, Col, Row, Select, TextField } from '@folio/stripes/components';
import React from 'react';
import React, { useMemo } from 'react';
import { CriteriaAggregateType } from '../../types/CriteriaTypes';
import { Field, useField } from 'react-final-form';
import OperatorSelect from '../Criteria/OperatorSelect';
import useMonetaryOnBlur from '../../hooks/useMonetaryOnBlur';
import { FormattedMessage, useIntl } from 'react-intl';

export default function AggregateCriteriaCard() {
const selectedType = useField<CriteriaAggregateType>('aggregateFilter.type', {
Expand All @@ -12,9 +13,33 @@ export default function AggregateCriteriaCard() {
}).input.value;

const monetaryOnBlur = useMonetaryOnBlur('aggregateFilter.amountDollars');
const intl = useIntl();

const criteriaOptions = useMemo(
() =>
[
{
label: intl.formatMessage({
id: 'ui-plugin-bursar-export.bursarExports.aggregate.filter.numAccounts',
}),
value: CriteriaAggregateType.NUM_ROWS,
},
{
label: intl.formatMessage({
id: 'ui-plugin-bursar-export.bursarExports.aggregate.filter.totalAmount',
}),
value: CriteriaAggregateType.TOTAL_AMOUNT,
},
].sort((a, b) => a.label.localeCompare(b.label)),
[intl]
);

return (
<Card headerStart="Only include patrons with:">
<Card
headerStart={
<FormattedMessage id="ui-plugin-bursar-export.bursarExports.aggregate.filter.header" />
}
>
<Row>
<Col xs={12} md={4}>
<Field
Expand All @@ -27,20 +52,17 @@ export default function AggregateCriteriaCard() {
fullWidth
marginBottom0
required
label="Filter type"
label={
<FormattedMessage id="ui-plugin-bursar-export.bursarExports.aggregate.filter" />
}
dataOptions={[
{
nhanaa marked this conversation as resolved.
Show resolved Hide resolved
label: 'None (include all patrons)',
label: intl.formatMessage({
id: 'ui-plugin-bursar-export.bursarExports.aggregate.filter.none',
}),
value: CriteriaAggregateType.PASS,
},
{
label: 'Number of accounts',
value: CriteriaAggregateType.NUM_ROWS,
},
{
label: 'Total amount',
value: CriteriaAggregateType.TOTAL_AMOUNT,
},
...criteriaOptions,
]}
/>
)}
Expand All @@ -63,7 +85,9 @@ export default function AggregateCriteriaCard() {
marginBottom0
required
type="number"
label="Number of accounts"
label={
<FormattedMessage id="ui-plugin-bursar-export.bursarExports.aggregate.filter.numAccounts.amount" />
}
min={1}
step={1}
/>
Expand All @@ -82,7 +106,9 @@ export default function AggregateCriteriaCard() {
marginBottom0
required
type="number"
label="Amount"
label={
<FormattedMessage id="ui-plugin-bursar-export.bursarExports.aggregate.filter.totalAmount.amount" />
}
min={0}
step={0.01}
onBlur={monetaryOnBlur}
Expand All @@ -95,8 +121,7 @@ export default function AggregateCriteriaCard() {

<p style={{ marginBottom: 0 }}>
<i>
This will be applied after accounts are evaluated per the
&ldquo;Criteria&rdquo; specified above.
<FormattedMessage id="ui-plugin-bursar-export.bursarExports.aggregate.filter.description" />
</i>
</p>
</Card>
Expand Down
5 changes: 4 additions & 1 deletion src/components/Criteria/CriteriaAge.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Col, TextField } from '@folio/stripes/components';
import React from 'react';
import { Field } from 'react-final-form';
import { FormattedMessage } from 'react-intl';

export default function CriteriaAge({ prefix }: { prefix: string }) {
return (
Expand All @@ -13,7 +14,9 @@ export default function CriteriaAge({ prefix }: { prefix: string }) {
marginBottom0
required
type="number"
label="Older than (days)"
label={
<FormattedMessage id="ui-plugin-bursar-export.bursarExports.criteria.age.value" />
}
min={1}
step={1}
/>
Expand Down
5 changes: 4 additions & 1 deletion src/components/Criteria/CriteriaAmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import { Field } from 'react-final-form';
import useMonetaryOnBlur from '../../hooks/useMonetaryOnBlur';
import OperatorSelect from './OperatorSelect';
import { FormattedMessage } from 'react-intl';

export default function CriteriaAmount({ prefix }: { prefix: string }) {
const monetaryOnBlur = useMonetaryOnBlur(`${prefix}amountDollars`);
Expand All @@ -21,7 +22,9 @@ export default function CriteriaAmount({ prefix }: { prefix: string }) {
marginBottom0
required
type="number"
label="Amount"
label={
<FormattedMessage id="ui-plugin-bursar-export.bursarExports.criteria.select.amount" />
}
min={0}
step={0.01}
onBlur={monetaryOnBlur}
Expand Down
65 changes: 49 additions & 16 deletions src/components/Criteria/CriteriaCardSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
CriteriaGroupType,
CriteriaTerminalType,
} from '../../types/CriteriaTypes';
import { useIntl } from 'react-intl';

export default function CriteriaCardSelect({
name,
Expand All @@ -23,20 +24,28 @@ export default function CriteriaCardSelect({
}
}, [root]);

const intl = useIntl();

const selectOptions = useMemo(() => {
const options: SelectOptionType<
CriteriaGroupType | CriteriaTerminalType
>[] = [
{
label: 'All of:',
label: intl.formatMessage({
id: 'ui-plugin-bursar-export.bursarExports.criteria.select.allOf',
}),
value: CriteriaGroupType.ALL_OF,
},
{
label: 'Any of:',
label: intl.formatMessage({
id: 'ui-plugin-bursar-export.bursarExports.criteria.select.anyOf',
}),
value: CriteriaGroupType.ANY_OF,
},
{
label: 'None of:',
label: intl.formatMessage({
id: 'ui-plugin-bursar-export.bursarExports.criteria.select.noneOf',
}),
value: CriteriaGroupType.NONE_OF,
},

Expand All @@ -48,42 +57,66 @@ export default function CriteriaCardSelect({

// TODO: sort these alphabetically per i18n
...(patronOnly
? []
? [
{
label: intl.formatMessage({
id: 'ui-plugin-bursar-export.bursarExports.criteria.select.patronGroup',
}),
value: CriteriaTerminalType.PATRON_GROUP,
},
]
: [
{
label: 'Age',
label: intl.formatMessage({
id: 'ui-plugin-bursar-export.bursarExports.criteria.select.age',
}),
value: CriteriaTerminalType.AGE,
},
{
label: 'Amount',
label: intl.formatMessage({
id: 'ui-plugin-bursar-export.bursarExports.criteria.select.amount',
}),
value: CriteriaTerminalType.AMOUNT,
},
{
label: 'Fee/fine owner',
label: intl.formatMessage({
id: 'ui-plugin-bursar-export.bursarExports.criteria.select.owner',
}),
value: CriteriaTerminalType.FEE_FINE_OWNER,
},
{
label: 'Fee/fine type',
label: intl.formatMessage({
id: 'ui-plugin-bursar-export.bursarExports.criteria.select.type',
}),
value: CriteriaTerminalType.FEE_FINE_TYPE,
},
{
label: 'Item location',
label: intl.formatMessage({
id: 'ui-plugin-bursar-export.bursarExports.criteria.select.location',
}),
value: CriteriaTerminalType.LOCATION,
},
{
label: 'Item service point',
label: intl.formatMessage({
id: 'ui-plugin-bursar-export.bursarExports.criteria.select.servicePoint',
}),
value: CriteriaTerminalType.SERVICE_POINT,
},
]),
{
label: 'Patron group',
value: CriteriaTerminalType.PATRON_GROUP,
},
{
label: intl.formatMessage({
id: 'ui-plugin-bursar-export.bursarExports.criteria.select.patronGroup',
}),
value: CriteriaTerminalType.PATRON_GROUP,
},
]
).sort((a, b) => a.label.localeCompare(b.label)),
];

if (root) {
options.unshift({
label: 'No criteria (always run)',
label: intl.formatMessage({
id: 'ui-plugin-bursar-export.bursarExports.criteria.select.none',
}),
value: CriteriaTerminalType.PASS,
});
}
Expand Down
9 changes: 7 additions & 2 deletions src/components/Criteria/CriteriaFeeFineOwner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Col, Select } from '@folio/stripes/components';
import React, { useMemo } from 'react';
import { Field } from 'react-final-form';
import useFeeFineOwners from '../../api/queries/useFeeFineOwners';
import { FormattedMessage } from 'react-intl';

export default function CriteriaFeeFineOwner({ prefix }: { prefix: string }) {
const feeFineOwners = useFeeFineOwners();
Expand All @@ -27,10 +28,14 @@ export default function CriteriaFeeFineOwner({ prefix }: { prefix: string }) {
fullWidth
marginBottom0
required
label="Fee/fine owner"
label={
<FormattedMessage id="ui-plugin-bursar-export.bursarExports.criteria.select.owner" />
}
dataOptions={[
{ label: '', value: '', disabled: true },
...ownersSelectOptions,
...ownersSelectOptions.sort((a, b) =>
a.label.localeCompare(b.label)
),
]}
/>
)}
Expand Down
21 changes: 16 additions & 5 deletions src/components/Criteria/CriteriaFeeFineType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import React, { useMemo } from 'react';
import { Field, useField } from 'react-final-form';
import useFeeFineOwners from '../../api/queries/useFeeFineOwners';
import useFeeFineTypes from '../../api/queries/useFeeFineTypes';
import { FormattedMessage, useIntl } from 'react-intl';

export default function CriteriaFeeFineType({ prefix }: { prefix: string }) {
const feeFineOwners = useFeeFineOwners();
const feeFineTypes = useFeeFineTypes();
const intl = useIntl();

const selectedOwner = useField<string | undefined>(
`${prefix}feeFineOwnerId`,
Expand Down Expand Up @@ -60,11 +62,18 @@ export default function CriteriaFeeFineType({ prefix }: { prefix: string }) {
fullWidth
marginBottom0
required
label="Fee/fine owner"
label={
<FormattedMessage id="ui-plugin-bursar-export.bursarExports.criteria.select.owner" />
}
dataOptions={[
{ label: 'Automatic', value: 'automatic' },
{
label: intl.formatMessage({
id: 'ui-plugin-bursar-export.bursarExports.criteria.type.automatic',
}),
value: 'automatic',
},
...ownersSelectOptions,
]}
].sort((a, b) => a.label.localeCompare(b.label))}
/>
)}
</Field>
Expand All @@ -77,11 +86,13 @@ export default function CriteriaFeeFineType({ prefix }: { prefix: string }) {
fullWidth
marginBottom0
required
label="Fee/fine type"
label={
<FormattedMessage id="ui-plugin-bursar-export.bursarExports.criteria.select.type" />
}
dataOptions={[
{ label: '', value: undefined },
...typeSelectOptions,
]}
].sort((a, b) => a.label.localeCompare(b.label))}
/>
)}
</Field>
Expand Down
Loading