summaryrefslogtreecommitdiff
path: root/app/presentation/components/exercise-summary.js
blob: b4316d76a23cac02bb57958ab16ec21eb8eff162 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import React, { Component } from 'react';
import { View } from 'react-native';
import { Card, CardItem, Text, Thumbnail, Button, Icon, ListItem } from 'native-base';

export default class ExerciseSummary extends Component {
  render() {
    return (
      <View>
        <ListItem itemDivider>
          <Text>{this.props.name}</Text>
        </ListItem>
        {
          this.workSets().map((set) =>
            <ListItem key={set.id}>
              <Text>{this.summaryFor(set)}</Text>
            </ListItem>
          )
        }
      </View>
    );
  }

  workSets() {
    return this.props.sets.filter((set) => set.type == "WorkSet");
  }

  summaryFor(set) {
    let actual_repetitions = set.actual_repetitions || 0;
    return `${actual_repetitions}/${set.target_repetitions} @ ${set.target_weight.amount} ${set.target_weight.unit}`;
  }
}