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 1 commit
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
4 changes: 2 additions & 2 deletions src/BursarExportPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,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 @@ -85,7 +85,7 @@ export default function BursarExportPlugin() {
formApiRef.current?.change('buttonClicked', 'save')
}
>
Save
<FormattedMessage id="ui-plugin-bursar-export.bursarExports.button.save" />
</Button>
}
/>
Expand Down
37 changes: 27 additions & 10 deletions src/components/AggregateCriteria/AggregateCriteriaCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ 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,14 @@ export default function AggregateCriteriaCard() {
}).input.value;

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

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,21 +33,29 @@ 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',
label: intl.formatMessage({
id: 'ui-plugin-bursar-export.bursarExports.aggregate.filter.numAccounts',
}),
value: CriteriaAggregateType.NUM_ROWS,
},
{
label: 'Total amount',
label: intl.formatMessage({
id: 'ui-plugin-bursar-export.bursarExports.aggregate.filter.totalAmount',
}),
value: CriteriaAggregateType.TOTAL_AMOUNT,
},
]}
].sort((a, b) => a.label.localeCompare(b.label))}
/>
)}
</Field>
Expand All @@ -63,7 +77,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 +98,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 +113,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