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.

depense_list_entry.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React, { useEffect } from 'react';
  2. import { StyleSheet, Text, View, TextInput, Pressable } from 'react-native';
  3. import DepenseForm from './depense_edit/depense_form';
  4. export default function DepenseListEntry(props){
  5. const [editing, toggleEdit] = React.useState(false);
  6. return(<View style={depense_list_entry_style.depense_list_entry}>
  7. <Pressable
  8. onPress={() => {
  9. toggleEdit(!editing);
  10. }}
  11. style={depense_list_entry_style.pressable_depense_list_entry}>
  12. <Text >{props.depense.description}</Text>
  13. <Text >{new Date(props.depense.date).toDateString()}</Text>
  14. <Text >{props.depense.value}</Text>
  15. </Pressable>
  16. {editing ?
  17. <DepenseForm fetchDepenses={props.fetchDepenses} onUpdateDepense={(res) => {toggleEdit(res)}} depense={props.depense}/> :
  18. <View/>
  19. }
  20. </View>
  21. )
  22. }
  23. const depense_list_entry_style = StyleSheet.create({
  24. depense_list_entry: {
  25. borderBottomWidth: 0.5
  26. },
  27. pressable_depense_list_entry: {
  28. display: "flex",
  29. flexDirection: "row",
  30. justifyContent: "space-between",
  31. margin: 2,
  32. }
  33. });