client/src/components/NotesList.js
author Alexandre Segura <mex.zktk@gmail.com>
Wed, 31 May 2017 17:51:54 +0200
changeset 12 48ddaa42b810
parent 2 b52921a63e77
child 18 dab2a16500e0
permissions -rw-r--r--
Draft implementation of sessions. - Introduce react-router & add some pages. - Add login page (does nothing). - Allow creating a new session. - Allow adding notes into a session.

import React from 'react';

import PropTypes from 'prop-types';
import Immutable from 'immutable';

import { ListGroup, ListGroupItem, Alert } from 'react-bootstrap';

import Note from './Note';

const NotesList = ({notes}) => {

  if (notes.size === 0) {
    return (
      <Alert bsStyle="warning">No notes yet. Add notes with the textarea below.</Alert>
    );
  }

  return (
    <ListGroup>
      {notes.map((note) =>
        <ListGroupItem key={note.id}><Note note={note} /></ListGroupItem>
      )}
    </ListGroup>
  );
};

NotesList.propTypes = {
  notes: PropTypes.instanceOf(Immutable.List).isRequired
};

export default NotesList;