2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt odlux
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
18 import React from 'react';
19 import { withRouter, RouteComponentProps } from 'react-router-dom';
21 import Table from '@mui/material/Table';
22 import TableBody from '@mui/material/TableBody';
23 import TableCell from '@mui/material/TableCell';
24 import TableHead from '@mui/material/TableHead';
25 import TableRow from '@mui/material/TableRow';
26 import Paper from '@mui/material/Paper'; // means border
28 import { connect } from '../../../../framework/src/flux/connect';
30 import { loadAllAuthorsAsync } from '../actions/authorActions';
31 import { IAuthor } from '../models/author';
33 interface IAuthorsListProps {
36 onLoadAllAuthors: () => void;
39 class AuthorsListComponent extends React.Component<RouteComponentProps & IAuthorsListProps> {
41 render(): JSX.Element {
42 const { authors, busy } = this.props;
51 <Table padding="normal" >
54 <TableCell align="right">Id</TableCell>
55 <TableCell >First Name</TableCell>
56 <TableCell >Last Name</TableCell>
60 {authors.map(author => (
61 <TableRow key={author.id} onClick={(_e) => this.editAuthor(author)}>
62 <TableCell>{author.id}</TableCell>
63 <TableCell>{author.firstName}</TableCell>
64 <TableCell>{author.lastName}</TableCell>
73 public componentDidMount() {
74 this.props.onLoadAllAuthors();
77 private editAuthor = (author: IAuthor) => {
78 if (author) this.props.history.push(this.props.match.path + '/' + author.id);
82 export const AuthorsList = withRouter(
84 ({ demo: state }) => ({
85 authors: state.listAuthors.authors,
86 busy: state.listAuthors.busy,
89 onLoadAllAuthors: () => {
90 dispatcher.dispatch(loadAllAuthorsAsync);
92 }))(AuthorsListComponent));
93 export default AuthorsList;