Skip to content

Commit

Permalink
Merge pull request #1758 from openmsupply/#1744-ReportTable-component
Browse files Browse the repository at this point in the history
#1744 Create ReportTable component
  • Loading branch information
diegoevangelisti committed Dec 20, 2019
2 parents 264b58e + 7218d46 commit 4f7a366
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/widgets/ReportTable/ReportTable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* eslint-disable react/prop-types */
/* eslint-disable react/forbid-prop-types */
/**
* mSupply Mobile
* Sustainable Solutions (NZ) Ltd. 2018
*/

import React from 'react';
import { StyleSheet, FlatList, View } from 'react-native';
import PropTypes from 'prop-types';
import { LIGHT_GREY } from '../../globalStyles';
import { ReportRow } from './ReportRow';

export const ReportTable = ({ rows, header }) => {
const renderItem = ({ item, index }) => <ReportRow rowData={item} rowIndex={index} />;

const renderHeader = () => <ReportRow rowData={header} rowIndex={0} />;

// TODO: KeyExtractor should be altered to not use the index.
return (
<View style={localStyles.container}>
<FlatList
data={rows}
ListHeaderComponent={renderHeader}
renderItem={renderItem}
keyExtractor={(_, index) => `${index}`}
/>
</View>
);
};

ReportTable.propTypes = {
header: PropTypes.array.isRequired,
rows: PropTypes.array.isRequired,
};

const localStyles = StyleSheet.create({
container: {
backgroundColor: LIGHT_GREY,
},
});

0 comments on commit 4f7a366

Please sign in to comment.