A few changes:
Auto fill amount category edit Empty list component calendar filtering in category screen, expenses can be added directly
This commit is contained in:
parent
e0f3cf947c
commit
8149ec234f
10 changed files with 97 additions and 42 deletions
|
|
@ -1,18 +1,20 @@
|
|||
import { View, Text, StyleSheet, Alert } from 'react-native'
|
||||
import React, { useRef, useState } from 'react'
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import { SIZES } from '../../constants/theme'
|
||||
import { useTheme } from '../contexts/ThemeContext'
|
||||
import { AutoDecimalInput, CategorySelector, CategorySelectorModal, DateSelectorButton, RoundedButton, TextInputBar } from '../../components'
|
||||
import { Category } from '../../types/dbItems'
|
||||
import DateTimePicker from '@react-native-community/datetimepicker';
|
||||
import { addExpense } from '../../services/database'
|
||||
import { addExpense, executeQuery } from '../../services/database'
|
||||
import { SimpleDate } from '../../util/SimpleDate'
|
||||
import { useRouter } from 'expo-router'
|
||||
import { useLocalSearchParams, useRouter } from 'expo-router'
|
||||
|
||||
export default function AddItem() {
|
||||
const {colors} = useTheme();
|
||||
const router = useRouter();
|
||||
|
||||
const searchParams = useLocalSearchParams()
|
||||
|
||||
const [formatedValue, setFormatedValue] = useState<string>("");
|
||||
const [selectorModalVisible, setSelecorModalVisible] = useState<boolean>(false);
|
||||
const [selectedCategory, setSelectedCategory] = useState<Category|undefined>()
|
||||
|
|
@ -50,6 +52,20 @@ export default function AddItem() {
|
|||
|
||||
}
|
||||
|
||||
useEffect(()=>{
|
||||
if(searchParams.category !== undefined){
|
||||
console.log(searchParams.category)
|
||||
executeQuery({sql: "SELECT * FROM category WHERE guid = ?", args: [searchParams.category]}).then((result) =>{
|
||||
console.log("then")
|
||||
if("rows" in result[0]){
|
||||
const category = result[0]["rows"][0];
|
||||
setSelectedCategory({name: category["name"], color: category["color"], guid: category["guid"]})
|
||||
}
|
||||
//setSelectedCategory({name: category["name"], color: category["color"], guid: category["guid"]})
|
||||
})
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<CategorySelectorModal visible={selectorModalVisible} onRequestClose={()=>{setSelecorModalVisible(false)}} onCategoryTap={handleCategorySelect}></CategorySelectorModal>
|
||||
|
|
|
|||
Reference in a new issue