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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 order by date desc", (res) => {
  11. onGetDepenses(res.rows._array);
  12. });
  13. });
  14. });
  15. let content = []
  16. if(depenses.length > 0)
  17. {
  18. // get latest and oldest depense
  19. let latest_depense = depenses[0];
  20. let oldest_depense = depenses[depenses.length - 1]
  21. }
  22. depenses
  23. .forEach( function(depense){
  24. content.push(
  25. <DepenseListEntry key={"depense_list_depense"+depense.id} depense={depense}/>
  26. )
  27. });
  28. return(
  29. <View>
  30. {content}
  31. </View>
  32. )
  33. }
  34. const depense_list_style = StyleSheet.create({
  35. depense_list_entry: {
  36. display: "flex",
  37. flexDirection: "row",
  38. justifyContent: "space-between",
  39. // flex: 1,
  40. // backgroundColor: '#00FF00',
  41. // alignItems: 'center',
  42. // justifyContent: 'center',
  43. }
  44. });
  45. export default DepensesList