import React, { Fragment, ReactElement } from 'react'; import Divider from '@material-ui/core/Divider'; import Package from '../Package'; import Help from '../Help'; import { formatLicense } from '../../utils/package'; import { PackageInterface } from '../Package/Package'; import * as classes from './styles'; interface Props { packages: PackageInterface[]; } export default class PackageList extends React.Component { public render(): ReactElement { return (
{this.hasPackages() ? this.renderPackages() : }
); } private hasPackages(): boolean { const { packages } = this.props; return packages.length > 0; } private renderPackages = () => { return <>{this.renderList()}; }; private renderList = () => { const { packages } = this.props; return packages.map((pkg, i) => { const { name, version, description, time, keywords, dist, homepage, bugs, author } = pkg; // TODO: move format license to API side. const license = formatLicense(pkg.license); return ( {i !== 0 && } ); }); }; }