import * as React from 'react';
import PropTypes from 'prop-types';

import './Zeile.css';
import Besorgung from './Besorgung';

export default function Zeile({besorgung, onSelect, selectedLine})
{
    return(
                                <tr key = {besorgung.name} 
                                    className={selectedLine === besorgung.name ? 'active' : ''}
                                    onClick={() => {onSelect(besorgung.name)}}
                                >

                                {Object.keys(Besorgung.properties).map(property =>{
                                    const besorgungsprop = Besorgung.properties[property];
                                    return(
                                        <td>{besorgung[property]}</td>
                                    );

                                })}
                                </tr>
    );
}


Zeile.propTypes = {
    besorgung: PropTypes.object.isRequired,
    onSelect: PropTypes.func,
    selectedLine: PropTypes.string,
};