You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

depenses_list.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import React, { useEffect } from 'react';
  2. import { StyleSheet, Text, View, TextInput } from 'react-native';
  3. import { sqlite_exec_query } from '../db/query';
  4. import DepenseListEntry from './depense_list_entry';
  5. function DepensesList(props)
  6. {
  7. const [depenses, onGetDepenses] = React.useState([]);
  8. useEffect( () => {
  9. sqlite_exec_query(`create table if not exists expense (id integer primary key not null, value real, description text, date integer);`,(res)=>{
  10. sqlite_exec_query("select * from expense", (res) => {
  11. onGetDepenses(res.rows._array);
  12. });
  13. });
  14. });
  15. let content = []
  16. depenses
  17. .sort((a,b) => (a.date > b.date) ? -1 : (b.date > a.date) ? 1 : 0)
  18. .forEach( function(depense){
  19. content.push(
  20. <DepenseListEntry key={"depense_list_depense"+depense.id} depense={depense}/>
  21. )
  22. });
  23. return(
  24. <View>
  25. {content}
  26. </View>
  27. )
  28. }
  29. const depense_list_style = StyleSheet.create({
  30. depense_list_entry: {
  31. display: "flex",
  32. flexDirection: "row",
  33. justifyContent: "space-between",
  34. // flex: 1,
  35. // backgroundColor: '#00FF00',
  36. // alignItems: 'center',
  37. // justifyContent: 'center',
  38. }
  39. });
  40. export default DepensesList