client/src/components/SessionSummary.js
author ymh <ymh.work@gmail.com>
Fri, 30 Nov 2018 10:53:15 +0100
changeset 183 f8f3af9e5c83
parent 174 ac1a026edd58
child 190 01ad654237d5
permissions -rw-r--r--
Change the settings to avoid using Session authentication for rest framework as it raise exceptions in case client and backend are on the same domain On the filter, adapt to take into account new version of django_filters
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
125
c653f49fabfb remove unecessary dependencies to Redux
ymh <ymh.work@gmail.com>
parents: 124
diff changeset
     1
import React from 'react';
63
4088f8dc6b52 Improve session page layout, introduce summary.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     2
import _ from 'lodash';
174
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
     3
import Color from 'color';
63
4088f8dc6b52 Improve session page layout, introduce summary.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     4
import '../App.css';
161
a642639dbc07 Split scss files and adapt session page design
salimr <riwad.salim@yahoo.fr>
parents: 151
diff changeset
     5
import './SessionSummary.css'
74
043477fd5c5c add api call to save notes. internally use ts for time data for notes and session
ymh <ymh.work@gmail.com>
parents: 73
diff changeset
     6
import {formatTimestamp} from '../utils';
63
4088f8dc6b52 Improve session page layout, introduce summary.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     7
125
c653f49fabfb remove unecessary dependencies to Redux
ymh <ymh.work@gmail.com>
parents: 124
diff changeset
     8
const SessionSummary = ({notes}) => (
174
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
     9
  <div className="session-summary-list">
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    10
    <ul className="list-group sticky-left">
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    11
      {notes.map((note) => {
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    12
        const bgColor = note.categories.length > 0 ? Color(note.categories[0].color).lighten(0.5).hex() : "transparent";
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    13
        return (
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    14
        <li className="list-group-item border-0 py-1" key={note._id}>
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    15
            <a href={'#note-' + note._id}>
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    16
              <small className="note-time text-irinotes-time px-1 bg-irinotes-headers border-0 text-center">{formatTimestamp(note.startedAt)}</small>
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    17
              <small className="note-length font-weight-bold text-muted text-center badge" style={{ backgroundColor: bgColor }}>{_.words(note.plain).length} mots</small>
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    18
              <small className="note-time text-irinotes-time px-1 bg-irinotes-headers border-0 text-center">{formatTimestamp(note.finishedAt)}</small>
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    19
            </a>
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    20
        </li>
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    21
        )
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    22
      })}
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    23
    </ul>
ac1a026edd58 Correct display of protocol
ymh <ymh.work@gmail.com>
parents: 170
diff changeset
    24
  </div>
125
c653f49fabfb remove unecessary dependencies to Redux
ymh <ymh.work@gmail.com>
parents: 124
diff changeset
    25
)
63
4088f8dc6b52 Improve session page layout, introduce summary.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    26
125
c653f49fabfb remove unecessary dependencies to Redux
ymh <ymh.work@gmail.com>
parents: 124
diff changeset
    27
export default SessionSummary;