-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UIORGS-389 Implement organization's banking information details view
- Loading branch information
1 parent
31f09ca
commit 3878265
Showing
7 changed files
with
187 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...anizationDetails/OrganizationBankingInfo/BankingInformationCard/BankingInformationCard.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import PropTypes from 'prop-types'; | ||
import { useCallback } from 'react'; | ||
import { FormattedMessage } from 'react-intl'; | ||
|
||
import { | ||
Card, | ||
Col, | ||
KeyValue, | ||
LayoutHeader, | ||
Row, | ||
} from '@folio/stripes/components'; | ||
|
||
const invalidReference = <FormattedMessage id="stripes-acq-components.invalidReference" />; | ||
|
||
export const BankingInformationCard = ({ | ||
bankingAccountTypesMap, | ||
bankingInformation, | ||
categoriesMap, | ||
}) => { | ||
const { | ||
isPrimary, | ||
bankName, | ||
bankAccountNumber, | ||
transitNumber, | ||
categoryId, | ||
accountTypeId, | ||
notes, | ||
} = bankingInformation; | ||
|
||
const renderHeader = useCallback(() => ( | ||
<LayoutHeader | ||
level={4} | ||
title={<FormattedMessage id={`ui-organizations.${isPrimary ? 'primaryItem' : 'alternateItem'}`} />} | ||
noActions | ||
/> | ||
), [isPrimary]); | ||
|
||
return ( | ||
<Card headerComponent={renderHeader}> | ||
<Row> | ||
<Col xs={4}> | ||
<KeyValue | ||
label={<FormattedMessage id="ui-organizations.data.bankingInformation.bankName" />} | ||
value={bankName} | ||
/> | ||
</Col> | ||
<Col xs={4}> | ||
<KeyValue | ||
label={<FormattedMessage id="ui-organizations.data.bankingInformation.bankAccountNumber" />} | ||
value={bankAccountNumber} | ||
/> | ||
</Col> | ||
<Col xs={4}> | ||
<KeyValue | ||
label={<FormattedMessage id="ui-organizations.data.bankingInformation.transitNumber" />} | ||
value={transitNumber} | ||
/> | ||
</Col> | ||
<Col xs={4}> | ||
<KeyValue | ||
label={<FormattedMessage id="ui-organizations.data.bankingInformation.addressCategory" />} | ||
value={categoryId && (categoriesMap[categoryId]?.value ?? invalidReference)} | ||
/> | ||
</Col> | ||
<Col xs={4}> | ||
<KeyValue | ||
label={<FormattedMessage id="ui-organizations.data.bankingInformation.accountType" />} | ||
value={accountTypeId && (bankingAccountTypesMap[accountTypeId]?.name ?? invalidReference)} | ||
/> | ||
</Col> | ||
<Col xs={4}> | ||
<KeyValue | ||
label={<FormattedMessage id="ui-organizations.data.bankingInformation.notes" />} | ||
value={notes} | ||
/> | ||
</Col> | ||
</Row> | ||
</Card> | ||
); | ||
}; | ||
|
||
BankingInformationCard.propTypes = { | ||
bankingAccountTypesMap: PropTypes.object.isRequired, | ||
bankingInformation: PropTypes.shape({ | ||
isPrimary: PropTypes.bool, | ||
bankName: PropTypes.string, | ||
bankAccountNumber: PropTypes.string, | ||
transitNumber: PropTypes.string, | ||
categoryId: PropTypes.string, | ||
accountTypeId: PropTypes.string, | ||
notes: PropTypes.string, | ||
}).isRequired, | ||
categoriesMap: PropTypes.object.isRequired, | ||
}; |
1 change: 1 addition & 0 deletions
1
...Organizations/OrganizationDetails/OrganizationBankingInfo/BankingInformationCard/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { BankingInformationCard } from './BankingInformationCard'; |
53 changes: 53 additions & 0 deletions
53
src/Organizations/OrganizationDetails/OrganizationBankingInfo/OrganizationBankingInfo.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import keyBy from 'lodash/keyBy'; | ||
import PropTypes from 'prop-types'; | ||
import { useMemo } from 'react'; | ||
|
||
import { Loading } from '@folio/stripes/components'; | ||
|
||
import { | ||
useBankingAccountTypes, | ||
useCategories, | ||
useOrganizationBankingInformation, | ||
} from '../../../common/hooks'; | ||
import { BankingInformationCard } from './BankingInformationCard'; | ||
|
||
export const OrganizationBankingInfo = ({ organization }) => { | ||
const { | ||
bankingInformation, | ||
isFetching: isBankingInformationFetching, | ||
} = useOrganizationBankingInformation(organization.id); | ||
|
||
const { | ||
categories, | ||
isFetching: isCategoriesFetching, | ||
} = useCategories(); | ||
|
||
const { | ||
bankingAccountTypes, | ||
isFetching: isBankingAccountTypesFetching, | ||
} = useBankingAccountTypes(); | ||
|
||
const categoriesMap = useMemo(() => keyBy(categories, 'id'), [categories]); | ||
const bankingAccountTypesMap = useMemo(() => keyBy(bankingAccountTypes, 'id'), [bankingAccountTypes]); | ||
|
||
const isFetching = ( | ||
isBankingInformationFetching | ||
|| isCategoriesFetching | ||
|| isBankingAccountTypesFetching | ||
); | ||
|
||
if (isFetching) return <Loading />; | ||
|
||
return bankingInformation.map(info => ( | ||
<BankingInformationCard | ||
key={info.id} | ||
bankingInformation={info} | ||
bankingAccountTypesMap={bankingAccountTypesMap} | ||
categoriesMap={categoriesMap} | ||
/> | ||
)); | ||
}; | ||
|
||
OrganizationBankingInfo.propTypes = { | ||
organization: PropTypes.object.isRequired, | ||
}; |
1 change: 1 addition & 0 deletions
1
src/Organizations/OrganizationDetails/OrganizationBankingInfo/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { OrganizationBankingInfo } from './OrganizationBankingInfo'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters