forked from folio-org/ui-users
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoanActionsHistoryProxy.js
43 lines (36 loc) · 1.14 KB
/
LoanActionsHistoryProxy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React from 'react';
import PropTypes from 'prop-types';
import Link from 'react-router-dom/Link';
import KeyValue from '@folio/stripes-components/lib/KeyValue';
import { getFullName } from './util';
class LoanActionsHistoryProxy extends React.Component {
static propTypes = {
id: PropTypes.string,
onClick: PropTypes.func.isRequired,
resources: PropTypes.shape({
proxy: PropTypes.shape({
records: PropTypes.arrayOf(PropTypes.object),
}),
}),
}
static manifest = Object.freeze({
proxy: {
type: 'okapi',
path: 'users/!{id}',
},
});
getUserFullName() {
const proxy = (this.props.resources.proxy || {}).records || [];
if (proxy.length === 1 && proxy[0].id === this.props.id) {
return <Link to={`/users/view/${this.props.id}?query=${proxy[0].username}`} onClick={this.props.onClick}>{getFullName(proxy[0])}</Link>;
}
return this.props.id;
}
render() {
if (this.props.id) {
return <KeyValue label="Proxy Borrower" value={this.getUserFullName()} />;
}
return <KeyValue label="Proxy Borrower" value="-" />;
}
}
export default LoanActionsHistoryProxy;